0% fanden dieses Dokument nützlich (0 Abstimmungen)
10 Ansichten6 Seiten

3 4 Rosbag

Das Dokument beschreibt die ROS-Bag-Dateiformat zur Aufzeichnung und Wiedergabe von ROS-Nachrichtendaten. ROSBag kann verwendet werden, um Daten von laufenden ROS-Systemen aufzuzeichnen und wiederzugeben, um ähnliches Verhalten zu reproduzieren.

Hochgeladen von

Hrithik Verma
Copyright
© All Rights Reserved
Wir nehmen die Rechte an Inhalten ernst. Wenn Sie vermuten, dass dies Ihr Inhalt ist, beanspruchen Sie ihn hier.
Verfügbare Formate
Als PDF, TXT herunterladen oder online auf Scribd lesen
0% fanden dieses Dokument nützlich (0 Abstimmungen)
10 Ansichten6 Seiten

3 4 Rosbag

Das Dokument beschreibt die ROS-Bag-Dateiformat zur Aufzeichnung und Wiedergabe von ROS-Nachrichtendaten. ROSBag kann verwendet werden, um Daten von laufenden ROS-Systemen aufzuzeichnen und wiederzugeben, um ähnliches Verhalten zu reproduzieren.

Hochgeladen von

Hrithik Verma
Copyright
© All Rights Reserved
Wir nehmen die Rechte an Inhalten ernst. Wenn Sie vermuten, dass dies Ihr Inhalt ist, beanspruchen Sie ihn hier.
Verfügbare Formate
Als PDF, TXT herunterladen oder online auf Scribd lesen

ROSBAG

● A bag is a file format in ROS for storing ROS message data. The rosbag command can
record, replay and manipulate bags.

● Rosbag can be activated from the command-line or from C++ or Python using the code
API.

ROSBAG Example recording all topics


We will record data from a running Turtlesim system into a .bag file, and then to play back the
data to produce similar behavior in the turtle.

1. Start turtlesim_node and turtle_teleop_key

$ roscore
$ rosrun turtlesim turtlesim_node
$ rosrun turtlesim turtle_teleop_key

2. To record data, make a temporary directory and change to that directory:

$ mkdir bagfile_turtle
$ cd bagfile_turtle

3. To record all published topics to the rosbag use the -a option in the command:

~/bagfile_turtle $ rosbag record -a

[ WARN] [1516929192.715955108]: --max-splits is ignored without --split


[ INFO] [1516929192.740506516]: Subscribing to /turtle1/color_sensor
[ INFO] [1516929192.762675745]: Subscribing to /turtle1/cmd_vel
[ INFO] [1516929192.778155235]: Recording to [Link].
[ INFO] [1516929192.788542210]: Subscribing to /rosout
[ INFO] [1516929192.799721071]: Subscribing to /rosout_agg
[ INFO] [1516929192.815919017]: Subscribing to /turtle1/pose

4. Move the turtle around with the arrow keys until you are satisfied (make sure you have
selected the teleop_key window). To stop recording in the bag file, select the window
running the rosbag command and press Ctrl + C to stop the process.

1
5. Examine the bagfile_turtle directory and you should see a file with a name that begins
with the year, date and time and the suffix .bag. This is the bag file that contains all the
topics published by any node in the time that rosbag was running.

~/bagfile_turtle$ ls

[Link]

6. To examine information on what was recorded in the bag, use the command:

$ rosbag info <name of bag file>

~/bagfile_turtle$ rosbag info [Link]

2
This tells us topic names and types as well as the number (count) of each message topic
contained in the bag file. We can see that of the topics being advertised that we saw in
the rostopic output, four topics were actually published over our recording interval. As
we ran rosbag record with the -a flag it recorded all messages published by all nodes.

7. The next step is to replay the bag file to reproduce behavior in the running system. First
kill the teleop program that may be still running from the previous section - Ctrl-c in the
terminal where you started turtle_teleop_key.
8. You may use the same turtlesim window or restart with a “fresh” turtlesim .
9. Change directory to the bagfile_turtle and use the command to play the bag file:
$ cd bagfile_turtle
$ rosbag play <name of bag file>

~/bagfile_turtle$ rosbag play [Link]

[ INFO] [1516929606.882610386]: Opening [Link]

Waiting 0.2 seconds after advertising topics... done.

Hit space to toggle paused, or 's' to step.


[DELAYED] Bag Time: 1516929192.832566 Duration: 0.000000 / 102.652806 Dela [RUNNING] Bag
Time: 1516929192.832566 Duration: 0.000000 / 102.652806 [RUNNING] Bag Time:
1516929192.832566 Duration: 0.000000 / 102.652806

[RUNNING] Bag Time: 1516929295.453951 Duration: 102.621385 / 102.652806
Done.

3
For this exercise, the turtle began executing the messages from its last location.

In its default mode rosbag play will wait for a certain period (.2 seconds) after advertising each
message before it actually begins publishing the contents of the bag file. Waiting for some
duration allows any subscriber of a message to be alerted that the message has been
advertised and that messages may follow. If rosbag play publishes messages immediately upon
advertising, subscribers may not receive the first several published messages. The waiting
period can be specified with the -d option.

Eventually the topic /turtle1/cmd_vel will be published and the turtle should start moving in
Turtlesim in a pattern similar to the one you executed from the teleop program. The duration
between running rosbag play and the turtle moving should be approximately equal to the time
between the original rosbag record execution and issuing the commands from the keyboard in
the beginning part of the tutorial.

You can have rosbag play not start at the beginning of the bag file but instead start some
duration past the beginning using the -s argument.

A final option that may be of interest is the -r option, which allows you to change the rate of
publishing by a specified factor. If you execute:

$ rosbag play –r 2 <name of bag file>

You should see the turtle execute a slightly different trajectory - this is the trajectory that would
have resulted had you issued your keyboard commands twice as fast.

ROSBAG Example recording a subset of topics


Many times systems have hundreds of topics being published and some topics, like camera
image streams, can potentially publish huge amounts of data. In such a system, it is often
impractical to write log files consisting of all topics to memory in a single bag file. The rosbag
command supports logging only particular topics to a bag file, allowing a user to only record the
topics of interest to them. To selectively record topics, use the –O option (capital letter O) and
list the topics to record:
$ rosbag record -O cmdvel /turtle1/cmd_vel /turtle1/pose

[ WARN] [1516930297.434663897]: --max-splits is ignored without --split


[ INFO] [1516930297.464320935]: Subscribing to /turtle1/cmd_vel
[ INFO] [1516930297.475858860]: Subscribing to /turtle1/pose
[ INFO] [1516930297.493070220]: Recording to [Link].

4
This -O argument tells rosbag record to log to a file named [Link], and the topic
arguments cause rosbag record to only subscribe to these two topics. Move the turtle around
for several seconds using the keyboard arrow commands, and then Ctrl-c in the rosbag window
to stop the rosbag record.

Then use the rosbag info and rosbag play commands as described previously.

The limitations of rosbag record/play


In the previous section you may have noted that the turtle's path may not have exactly mapped
to the original keyboard input - the rough shape should have been the same, but the turtle may
not have exactly tracked the same path. The reason for this is that the path tracked by turtlesim
is very sensitive to small changes in timing in the system, and rosbag is limited in its ability to
exactly duplicate the behavior of a running system in terms of when messages are recorded and
processed by rosrecord, and when messages are produced and processed when using rosplay.
For nodes like turtlesim, where minor timing changes in when command messages are
processed can subtly alter behavior, the user should not expect perfectly mimicked behavior.

$ rosbag help
Usage: rosbag <subcommand> [options] [args]
Available subcommands:
check Determine whether a bag is playable in the current system, or if it can be migrated.
compress Compress one or more bag files.
decompress Decompress one or more bag files.
filter Filter the contents of the bag.
fix Repair the messages in a bag file so that it can be played in the current system.
help
info Summarize the contents of one or more bag files.
play Play back the contents of one or more bag files in a time-synchronized fashion.
record Record a bag file with the contents of specified topics.
reindex Reindexes one or more bag files.

5
ROSBAG References
● For general information, refer to [Link]

● For command-line tutorial:


[Link]

● For command-line options: [Link]

● For code API for C++ and Python: [Link]

● For code API examples: [Link]

● For ROS bag format: [Link]

Das könnte Ihnen auch gefallen