-
Notifications
You must be signed in to change notification settings - Fork 0
40 beginning pipeline simulation #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
DanielRhee
wants to merge
2
commits into
main
Choose a base branch
from
40-beginning-pipeline-simulation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
|
|
||
| '''Take vechile postion, speed, and last current as input from state.py and use numpy to find the | ||
| postions of the cones and the car and graph it on a coordinate system.''' | ||
|
|
||
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| # Veichel state form state.py | ||
| stepSize = 0.1 | ||
| position = np.array([12.5, 7.8]) # (x, y) | ||
| speed = 18.2 # m/s | ||
| heading = np.deg2rad(15) # radians | ||
| acceleration = 1.3 # m/s^2 | ||
| throttle = 0.65 # 0–1 | ||
| brakes = 0.1 # 0–1 | ||
| lastCurrent = 42.0 # amps | ||
|
|
||
| # cones postions coming from a json file | ||
| cones = np.array([ | ||
| [5, 5], | ||
| [8, 6], | ||
| [10, 7], | ||
| [13, 8], | ||
| [16, 9], | ||
| [18, 10] | ||
| ]) | ||
|
|
||
| # finding velcoity from heading | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why aren't you using the code in the sims for this? |
||
| velocity = np.array([ | ||
| np.cos(heading), | ||
| np.sin(heading) | ||
| ]) * speed | ||
|
|
||
| #creating layout | ||
| fig, axs = plt.subplots(3, 1, figsize=(9, 12)) | ||
|
|
||
| # cones and psition | ||
| axs[0].scatter(cones[:, 0], cones[:, 1], | ||
| marker="^", s=150, label="Cones") | ||
|
|
||
| axs[0].scatter(position[0], position[1], | ||
| marker="o", s=200, label="Vehicle") | ||
|
|
||
| axs[0].arrow( | ||
| position[0], position[1], | ||
| velocity[0] * 0.2, velocity[1] * 0.2, | ||
| head_width=0.4, | ||
| length_includes_head=True, | ||
| label="Velocity" | ||
| ) | ||
|
|
||
| axs[0].text( | ||
| position[0] + 0.5, | ||
| position[1] + 0.5, | ||
| f"Speed: {speed:.1f} m/s", | ||
| fontsize=10 | ||
| ) | ||
|
|
||
| axs[0].set_title("Vehicle & Cone Map") | ||
| axs[0].set_xlabel("X Position (m)") | ||
| axs[0].set_ylabel("Y Position (m)") | ||
| axs[0].axis("equal") | ||
| axs[0].grid(True) | ||
| axs[0].legend() | ||
|
|
||
| #Motion data | ||
| axs[1].bar( | ||
| ["Speed (m/s)", "Acceleration (m/s²)"], | ||
| [speed, acceleration] | ||
| ) | ||
|
|
||
| axs[1].set_title("Vehicle Motion State") | ||
| axs[1].grid(True) | ||
|
|
||
| #electrical data | ||
| axs[2].bar( | ||
| ["Throttle", "Brakes", "Motor Current (A)"], | ||
| [throttle, brakes, lastCurrent] | ||
| ) | ||
|
|
||
| axs[2].set_title("Control & Electrical State") | ||
| axs[2].grid(True) | ||
|
|
||
| plt.tight_layout() | ||
| plt.show() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi there's a large update coming to the format of this @goob10000 knows more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already on main if y'all wanna use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah definitely move to it then.