Skip to content
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

Velocity port done #20

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Velocity port done #20

wants to merge 16 commits into from

Conversation

JoyceZhu2486
Copy link

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

This velocity-port branch is created to avoid the conflicting files on the old simulation-velocity-port branch. velocity_updater.py and its related files including checkpoints.json (the checkpoints data), sim_2d_single_velocity.xml (the launch file) and an edited CMakeList.txt are copy-pasted from the old branch. The old branch is an undone refactor from velocity_updater.py and velocity_ui.py from RoboBuggy2 repo.

velocity_updater.py subscribes to sim_2d/utm to get position data and publishes to sim/velocity for the velocity to be subscribed and used by the simulator in engine.py. It reads from checkpoints.json to get a list of checkpoints, and use the velocity corresponding to the checkpoints to update velocity, instead of the old method of depending on the currently not working velocity.ui (which is now deleted) and instead of calculating from acceleration corresponding to checkpoints (which is now also deleted).

This feature would allow us to take the change in the velocity of the buggy in different parts of the course into consideration when doing simulation. The added feature of reading from json would allow us to give the change in velocity data to the simulator in a simpler way.

QA Instructions, Screenshots, Recordings

The changes are tested by running the simulator and monitoring the "SC/sim/velocity" topic in foxglove. For the current checkpoints, the buggy should start at velocity of 15, then change to velocity of 12.345, then continue the course after the first turn with velocity of 17.234. The simulation results are expected.

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

The checkpoints.json file is currently filled with made-up data for debugging. The data needs to be later updated to fit in actual change in buggy velocity on the course. Maybe another function that reads from a rosbag to record the velocity data into a json file can be later implemented to get accurate data of the change in velocity.

Sorry, something went wrong.

@JoyceZhu2486 JoyceZhu2486 changed the title Velocity port Velocity port done Jan 23, 2025
# Bubbles for updating acceleration based on position
# represented as {x-pos, y-pos, radius, velocity}
# imported from checkpoints.json
checkpoints_path = "/rb_ws/src/buggy/scripts/simulator/checkpoints.json"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be environment-variable-ized. do we have a process for that now? @mehulgoel873 or @TiaSinghania

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let me quickly add that in.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path is now environment-variable-ized!

# Bubbles for updating acceleration based on position
# represented as {x-pos, y-pos, radius, velocity}
# imported from checkpoints.json
checkpoints_path = "/rb_ws/src/buggy/scripts/simulator/checkpoints.json"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let me quickly add that in.

@JoyceZhu2486
Copy link
Author

Environment variables added and debugged. Everything should be working now.


<node pkg="foxglove_bridge" exec="foxglove_bridge" name="foxglove" namespace="SC"/>
<node pkg="buggy" exec="engine.py" name="SC_sim_single" namespace="SC">
<param name="velocity" value="12"/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use params like this, look at main sim_2d_single launch file to see how we specify a parameter file at the top. Include this in this launch file, and update that parameter file to include parameters for your code

*if your launch file is not being run the extra parameters wouldn't matter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add parameter file "sim_single_velocity.yaml" and changed launch file accordingly. Tested.

"checkpoints":
[
{
"x-pos": 589700,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to label these points, at least in the JSON for visual reference?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a txt file to record the corresponding traj file, data source and comments for each checkpoints.json file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants