Skip to content

hrelab/rosbag-recorder

Repository files navigation

HRELab ROS 2 Rosbag-Recorder

This folder can be pulled for all custom ROS 2 topic recordings. You will need to change the bash script(s) named run-recorder.bash and rosbag2csv.py for each set, but the package is completely built and robust.

Making a New Recording

Use run-recorder.bash to choose the rosbag tag/key and optionally enter custom topics and topic types at runtime.

If your project uses different topic names or message types, update the following:

  • In run-recorder.bash, change DEFAULT_TOPICS and DEFAULT_TOPIC_TYPES to match your new ROS topic names and message types.
  • In rosbag2csv.py, update the topic strings (raw_delsys_topic, raw_telemed_topic, proc_emg_topic, proc_imu_topic, proc_smg_topic) to match your recording.
  • Also update the corresponding column lists (delsys_cols, emg_cols, imu_cols, smg_cols) so they match the selected message payload fields.

Make sure the number of topics and topic types always stays in sync if you enter custom values interactively. This ensures the conversion logic can read the correct message types and export the right CSV files for your current project.

How to Run Recorder

First, start the Docker container you are in, in the ros2_ws environment. Run the following command:

bash src/rosbag_recorder/run-recorder.bash

And follow with prompts. You can use hard-coded defaults (set in the section above) or input the wanted topics each time. For example:

"Enter a tag or key to identify this rosbag:"

test1

"Record all currently published topics from ROS? [Y/n]"

n

"Use a YAML file for topics and types? [Y/n]"

n

"Enter topics as a comma-separated list, e.g. /topic1,/topic2:"

/raw_data/imu,/processed/imu

"Enter matching topic types as a comma-separated list, e.g. package/msg/Type1,package/msg/Type2:"

hre_interfaces/msg/Imu,hre_interfaces/msg/Orient

YAML Option

If you choose to run with a YAML file (option 2), then have the YAML file named topics.yaml and put it in the ros2_ws folder, alongside the src/ folder. The format of the file is such:

topics: [ '/raw_data/imu', '/processed/imu' ]
topic_types: [ 'hre_interfaces/msg/Imu', 'hre_interfaces/msg/Orient' ]

How to Run rosbag2csv

First, start the Docker container you are in, in the ros2_ws environment. Run the following command:

python3 src/rosbag_recorder/rosbag2csv.py

About

Gives a general script for recording any number of topics, needing only to edit one shell script

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors