如何用matlab打开rosbag文件,ROS Log Files (rosbags)

ROS Log Files (rosbags)Introduction

A rosbag or bag is a file format in ROS for storing ROS message

data. These bags are often created by subscribing to one or more ROS

topics, and storing the received message data in an efficient file

structure. MATLAB® can read these rosbag files and help with

filtering and extracting message data. The following sections detail

the structure of rosbags in MATLAB® and the workflow for extracting

data from them.MATLAB rosbag Structure

When accessing rosbag log files, call rosbag and specify the file path to the object. MATLAB then creates a BagSelection object that contains an

index of all the messages from the rosbag.

The BagSelection object has the following

properties related to the rosbag:

FilePath: a character vector of

the absolute path to the rosbag file.

StartTime: a scalar indicating

the time the first message was recorded

EndTime: a scalar indicating the

time the last message was recorded

NumMessages: a scalar indicating

how many messages are contained in the file

AvailableTopics: a list of what topic and message types

were recorded in the bag. This is stored as table data that lists the number of

messages, message type, and message definition for each topic. For more

information on table data types, see Access Data in Tables. Here is

an example output of this table:

ans =

NumMessages MessageType MessageDefinition

___________ ______________________ _________________

/clock 12001 rosgraph_msgs/Clock [1x185 char]

/gazebo/link_states 11999 gazebo_msgs/LinkStates [1x1247 char]

/odom 11998 nav_msgs/Odometry [1x2918 char]

/scan 965 sensor_msgs/LaserScan [1x2123 char]

MessageList: a list of every message in the bag with rows

sorted by time stamp of when the message was recorded. This list can be indexed

and you can select a portion of the list this way. Calling select allows you to select subsets

based on time stamp, topic or message type.

Also, note that the BagSelection object contains an index for all the

messages. However, you must still use functions to extract the data. For extracting this

information, see readMessages for getting messages based on

indices as a cell array or see timeseries for reading the data of specified properties as a time

series.Workflow for rosbag Selection

When working with rosbags, there is a general procedure of how

you should extract data.

Load a rosbag: Call rosbag and the file path to load

file and create BagSelection.

Examine available messages:

Examine BagSelection properties (AvailableTopics, NumMessages, StartTime, EndTime,

and MessageList) to determine how to select a subset

of messages for analysis.

Select messages: Call select to create a selection of

messages based on your desired properties.

Extract message data: Call readMessages or timeseries to get message data as

either a cell array or time series data structure.

Visualize, analyze or process

data: Use the extracted data for your specific application.

You can plot data or develop algorithms to process data.

The following figure also shows the workflow.

4f3ebdb6f34beb7bcf9de960ff97b3a8.pngLimitations

There are a few limitations in the rosbag support within MATLAB:

MATLAB can only parse uncompressed rosbags. See the ROS

Wiki for a tool to decompress a compressed rosbag.

Only rosbags in the v2.0 format are supported. See the ROS Wiki for more

information on different bag formats

The file path to the rosbag must always be accessible.

Because the message selection process does not retrieve any data,

the file needs to be available for reading when the message data is

accessed.

See Also

Related Topics

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值