Working with ROS bag files can be a bit tricky. This guide lays out the tools in CRS to work with ROS bags.
The following are instructions on how to play parts (or all) of a ROS bag, allowing for testing ROS nodes on data recorded in a previous simulation or hardware experiment.
Rosbag Docs¶
Check out the rosbag package documentation, especially the Commandline section, for more information on how to work with rosbags.
Replaying a ROS bag file¶
-
Add your
.bagfile to thebagsfolder. Create a new experiment in theexperimentsfolder and include all of the config files from your ROS bag file (estimator.yaml,controller.yaml, etc.). -
Determine the topics to publish from the ROS bag.
-
Check out the
bags/play.shscript. This script allows you to set the topics you wish to use from the rosbag. Note that$2refers to namespace of the, e.g., car used during the experiment. This will be set in the terminal when running the script.$1refers to the bag name you wish to use, and will also be set in the terminal when running the script. -
Start a ROS master in a terminal attached to the container.
- In a second, also attached, terminal, make ROS use the time published from the bag.
- Run the script by navigating to the
bagsfolder and execute
E.g:
./play.sh myBag.bag car1
- In a new terminal attached to the container, run the experiment.
For example, set namespace:=car1 and experiment_name:=myBagExperiment.
- Play around with the simulation. If you wish to make changes to, e.g., the estimator, you will need to change the
.yamlfile in your newly created experiment. By pressing the space bar the simulation will pause/resume.
CLI Car Plotter¶
You can use the bags/car_plotter.py to visualize the trajectories of the car from a rosbag.
Usage (assuming your located in the bags folder):
for all the info. TLDR:
The functions should be relatively self contained and embeddable in your own custom script if you need custom plots with custom layouts (for reports, papers, etc.).