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

How to play rosbag using launch file ?

asked 2013-05-15 06:12:58 -0500

Maytheewat gravatar image

updated 2013-05-15 06:14:30 -0500

I'm trying to play a bagfile using following launch file.

<launch>
  <node pkg="rosbag" type="play" name="rosbag" args="8tags.bag"/>
</launch>

However, it gave me an error like this when I launch it.

[FATAL] [1368634083.754058723]: Error opening file: 8tags.bag
[rosbag-1] process has died [pid 14246, exit code 1, cmd /opt/ros/groovy/lib/rosbag/play $8tags.bag __name:=rosbag __log:=/home/mayara/.ros/log/7e11c8fc-bd77-11e2-ae06-ac72890c90a9/rosbag-1.log].
log file: /home/mayara/.ros/log/7e11c8fc-bd77-11e2-ae06-ac72890c90a9/rosbag-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done
edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
44

answered 2013-05-16 01:36:36 -0500

You have to explicitly give the path to the file, for example :

<node pkg="rosbag" type="play" name="player" output="screen" args="--clock /home/me/ros_files/my_file.bag"/>

You can also use arguments, if you have multiple files to include

<arg name="path" default="/home/me/ros_files/" />
<arg name="file_1" default="my_file_1" />
<arg name="file_2" default="my_file_2" />
<node pkg="rosbag" type="play" name="player" output="screen" args="--clock $(arg path)$(arg file_1).bag $(arg path)$(arg file_2).bag"/>

I hope it helped you. Go to this page to have more info on options you can use.

Have a good day,

Bests regards,

Stéphane

edit flag offensive delete link more

Comments

What does the --clock option do and if you want to specify a relative path, will it be relative to the package directory, or the launchfile directory?

max11gen gravatar image max11gen  ( 2018-11-13 03:11:51 -0500 )edit
2

@max11gen:

re: --clock: #q12577.

re: relative path: #q235337.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-13 03:36:39 -0500 )edit

@gvdhoorn thanks a lot.

max11gen gravatar image max11gen  ( 2018-11-13 03:46:23 -0500 )edit
5

answered 2013-05-15 08:09:57 -0500

tfoote gravatar image

You should look in the referenced log file. But in general processes launched with roslaunch have a working directory in $ROS_HOME (default ~/.ros) you need to make sure to pass a full path to the bag file for it to be able to find the bag file.

edit flag offensive delete link more
2

answered 2021-02-26 12:48:19 -0500

Combinacijus gravatar image

For relative path use this just change MY_PACKAGE to your package name. Tested on Noetic:

<launch>
  <arg name="bag_file_name" value="my_bag"/>

  <node pkg="rosbag" type="play" name="rosbag_play" output="screen" args="--clock $(find MY_PACKAGE)/bags/$(arg bag_file_name).bag"/>
</launch>
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-05-15 06:12:58 -0500

Seen: 37,391 times

Last updated: Feb 26 '21