rigid_body_motion.ros.RosbagReader

class rigid_body_motion.ros.RosbagReader(bag_file)[source]

Bases: object

Reader for motion topics from rosbag files.

__init__(bag_file)[source]

Constructor.

Parameters
bag_file: str

Path to rosbag file.

Methods

__init__(bag_file)

Constructor.

export(topic[, output_file])

Export messages from topic as netCDF4 file.

get_topics_and_types()

Get topics and corresponding message types included in rosbag.

load_dataset(topic[, cache])

Load messages from topic as xarray.Dataset.

load_messages(topic)

Load messages from topic as dict.

export(topic, output_file=None)[source]

Export messages from topic as netCDF4 file.

Parameters
topic: str

Topic to read.

output_file: str, optional

Path to output file. By default, the path to the bag file, but with a different extension depending on the export format.

get_topics_and_types()[source]

Get topics and corresponding message types included in rosbag.

Returns
topics: dict

Names of topics and corresponding message types included in the rosbag.

load_dataset(topic, cache=False)[source]

Load messages from topic as xarray.Dataset.

Only nav_msgs/Odometry and geometry_msgs/TransformStamped topics are supported so far.

Parameters
topic: str

Name of the topic to load.

cache: bool, default False

If True, cache the dataset in cache/<topic>.nc in the same folder as the rosbag.

Returns
ds: xarray.Dataset

Messages as dataset.

load_messages(topic)[source]

Load messages from topic as dict.

Only nav_msgs/Odometry and geometry_msgs/TransformStamped topics are supported so far.

Parameters
topic: str

Name of the topic to load.

Returns
messages: dict

Dict containing arrays of timestamps and other message contents.