Run Ros Nodes Sequentially

asked 2020-10-30 16:26:03 -0500

frankm gravatar image

I am trying to create a script that enables offline evaluation of a SLAM method end-to-end (from input rosbag (laser & odometry data) to output rosbag (trajectory data)). The entire pipeline consists of several parts:

  • a SLAM (gmapping, hector_mapping, etc.) node
  • a node to listen to the robot pose output produced by the SLAM node (hector_trajectory_server) publishing the trajectory
  • a node to save the map (ros map_server)
  • a node to run a recorded rosbag (rosbag player)
  • a node to request the trajectory and write it out as a rosbag.

My question is how I can achieve this sequential processing, requesting the trajectory only after the input rosbag is completely played back.

I was creating my own node that plays the input rosbag (using ROS API rosbag/player.cpp ) and after the bag reached the end calls a service to get the trajectory from the trajectory server and writes the trajectory out to disk. My problem is that using the rosbag player comes with a downside that after the bag is completely processed the player shuts ros down obviously causing the rest of my code (service call, rosbag writing, map saving) in my node not to be executed. I also checked if there is an easy way to prevent the rosbag player to shut ros down but that is a dead end as almost all members and functions of the rosbag player class are private ruling out implementing a child class.

The option I am currently considering is to write my own player. Before starting with that I wanted to check with the community and see if my approach makes sense or if there are easier ways to reach my goal.

edit retag flag offensive close merge delete