build details

Show: section status errors & todos local changes recent changes last change in-page changes feedback controls

Exercise: Bag in, bag out

Modified 2019-09-22 by Andrea Censi

Skills learned

Modified 2019-09-22 by Andrea Censi

  • Processing the contents of a bag to produce another bag.

Instructions

Modified 2019-09-22 by Andrea Censi

Implement the program dt-bag-decimate as specified below.

Specification of dt-bag-decimate

Modified 2019-09-22 by Andrea Censi

The program dt-bag-decimate takes as argument a bag filename, an integer value greater than zero, and an output bag file:

$ dt-bag-decimate "input bag" n "output bag"

The output bag contains the same topics as the input bag, however, only 1 in n messages from each topic are written. (If n is 1, the output is the same as the input.)

Useful new APIs

Modified 2019-09-22 by Andrea Censi

Create a new Bag

Modified 2019-09-22 by Andrea Censi

In ROS, a new bag can be created by specifying the mode w (i.e., write) while instantiating the class rosbag.Bag.

For example:

from rosbag import Bag
new_bag = Bag('./output_bag.bag', mode='w')

Visit the documentation page for the class rosbag.Bag for further information.

Write message to a Bag

Modified 2019-09-22 by Andrea Censi

A ROS bag instantiated in write mode accepts messages through the function write().

Check that it works

Modified 2019-09-22 by Andrea Censi

To check that the program works, you can compute the statistics of the data using the program dt-bag-analyze that you have created in (unknown ref exercises/exercise-bag-analysis)

previous warning next (50 of 57) index
warning
I will ignore this because it is an external link. 

 > I do not know what is indicated by the link '#exercises/exercise-bag-analysis'.

Location not known more precisely.

Created by function n/a in module n/a.
.

You should see that the statistics have changed.