[ros-users] Rosbag Code API and Topic Names

Tim Field tfield at willowgarage.com
Fri Dec 3 06:11:04 UTC 2010


On Thu, Dec 2, 2010 at 9:31 PM, Chad Rockey <chadrockey at gmail.com> wrote:

> So it appears the Rosbag Code API does not handle the topic names like the
> other ROS tools regarding the first '/'.
>

odom and /odom are different Graph Resource
Names<http://www.ros.org/wiki/ROS/Concepts#Names.Graph_Resource_Names>.
 The rosbag code API doesn't require you to initialize a node before reading
the bag.  Thus, relative topic names (such as 'odom') aren't resolved when
they're read from a bag.

For example, if you ran the following launch file:

<launch>
  <group ns="my_ns">
    <node pkg="rosbag" type="record" name="record" args="-O odom.bag odom
/odom"/>
  </group>
</launch>


and then published to the two topics, /my_ns/odom and /odom:

$ rostopic pub /my_ns/odom std_msgs/String foo
$ rostopic pub /odom std_msgs/String bar


then the bag file would contain two separate topics:

$ rosbag info odom.bag
path:        odom.bag
version:     2.0
duration:    5.9s
start:       Dec 02 2010 21:46:02.39 (1291355162.39)
end:         Dec 02 2010 21:46:08.30 (1291355168.30)
size:        5.3 KB
messages:    2
compression: none [1/1 chunks]
types:       std_msgs/String [992ce8a1687cec8c8bd883ec73ca41d1]
topics:      /odom   1 msg     : std_msgs/String
             odom    1 msg     : std_msgs/String


and the rosbag Python API recognizes that distinction:

$ rospython rosbag
>>> import rosbag
>>> with rosbag.Bag('~/.ros/odom.bag') as b:
...     print b.read_messages(topics=['odom']).next()[1]
...     print b.read_messages(topics=['/odom']).next()[1]
...
data: foo
data: bar


Tim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20101202/01873ea5/attachment-0003.html>


More information about the ros-users mailing list