Skip to content

Simulation Testing

Toya Takahashi edited this page Aug 4, 2024 · 13 revisions

How to test the boat in sim

First, run the heartbeat: ros2 run all_seaing_vehicle onshore_node.py. If you want to run everything else in launch file (recommended), run ros2 launch all_seaing_vehicle xdrive_full_test_sim.launch.py. If you want to disable running tasks (like if you're not testing the full comp routine), then run ros2 launch all_seaing_vehicle xdrive_full_test_sim.launch.py run_tasks:=False.

If you don't want to run this launch file, here are all the nodes to run:

If you want to be able to quick e-stop or switch between autonomous and teleop, run the keyboard as well: ros2 run keyboard keyboard and ros2 run keyboard keyboard_to_joy.py. A keyboard popup window will open up, and if you have it selected then you can press Enter to toggle between auto and teleop and press Space to quick e-stop. While in teleop mode, use WASD QE to control the boat.

To launch the simulation and odometry, ros2 launch all_seaing_vehicle xdrive_sim.launch.py

This will launch the controller as well by default, but you can disable that using ros2 launch all_seaing_vehicle xdrive_sim.launch.py with_control:=False and then run the controller separately using ros2 run all_seaing_vehicle xdrive_controller.py --ros-args -p in_sim:=True

If you want to run our actual autonomous missions, ros2 run all_seaing_vehicle task_manager.py. This will try and run the missions as long as you're in auto mode and pause while in teleop mode.

If you want to save data on odometry while testing, be sure to run the rviz helper (and cd into a nice directory when you run it, bag files will be stored there): ros2 run rviz_testing_helper.py

Optionally, run rviz: rviz2 and set it up to view the path (click Add, click By Topic, click on the green squiggly Path, and click Ok - also be sure to set your frame to odom instead of map by double-clicking the thing that says 'map' next to Fixed Frame and renaming it).

Viewing paths in rviz

When the boat loses or changes heartbeat, the rviz helper will push the entire path to rviz so you can view it, and it will also store it in a bag file. For example, when you're done executing a test, you can Ctrl+C the heartbeat so the file is saved separately, then simply restart the heartbeat and the controller (you can leave the rviz helper open, it can make multiple bag files). Switching between teleop and autonomous will also trigger the rviz helper, so you can just click to the keyboard popup and hit Enter to toggle this and make a bag file/plot on rviz.

Bag files

Paths will also be stored in bag files, located in the bag directory inside of all_seaing_ros2. These will be gitignored by default so you don't push them by accident, but you can use them later to revisit tests and analyze them.

Clone this wiki locally