ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi, Just in case anyone wondering how to solve this there is one non-ROS method. I used the subprocess package from python to do that.

import subprocess
process = subprocess.Popen(['/bin/sh', '-c', 'ros2 bag play '+bag_file_path+'/'])
process.communicate()
process.terminate()

this way I send a command to the terminal which will run a bag file and on another end my ROS topic will read it.
This is not the best way I assume but it's the least coding way I was able to do it. But still, if anyone has a better solution or ROS solution please let me know.
Just to give a background about the problem I am running thetest node which subscribes to topics and then does some testing on that data. For that, I need the sensor data that I can either read from hardware or from the bag file.