Main Content

timetable

Create timetable for selected message properties in ROS 2 bag file

Since R2024a

Description

tb = timetable(bag) returns a timetable object tb for all the numeric and scalar message properties in the ros2bagreader object, bag. The first column of the timetable consists of timestamps and the rest of the columns consist of message property values for all messages in bag.

You can use the returned timetable object with all the time-specific functions to align, combine, and perform calculations with other timetables. The returned timetable object is memory-efficient because it only stores specific message properties and not whole messages.

tb = timetable(bag,property) creates a timetable for a specific message property, property. Property names can also be nested, for example, Pose.Pose.Position.X for the x-axis position of a robot.

tb = timetable(bag,property,...,propertyN) creates a timetable for range-specific message properties. Each property is a different column in the timetable object.

Examples

collapse all

Extract the ZIP file which contains the ROS 2 bag log file and specify the full path to the log folder.

unzip("ros2_mcap_bag.zip");
folderPath = fullfile(pwd,"ros2_netwrk_bag");

Create a ros2bagreader object to read all the messages in the bag file.

bagrdr = ros2bagreader(folderPath);

Select a specific topic. Timetable supports only single topics.

bagSel = select(bagrdr,Topic="/odom");

Create a timetable for all the fields in the /odom topic.

tt1 = timetable(bagSel)
tt1=5275×15 timetable
        Time         /odom_header.stamp.sec    /odom_header.stamp.nanosec    /odom_pose.pose.position.x    /odom_pose.pose.position.y    /odom_pose.pose.position.z    /odom_pose.pose.orientation.x    /odom_pose.pose.orientation.y    /odom_pose.pose.orientation.z    /odom_pose.pose.orientation.w    /odom_twist.twist.linear.x    /odom_twist.twist.linear.y    /odom_twist.twist.linear.z    /odom_twist.twist.angular.x    /odom_twist.twist.angular.y    /odom_twist.twist.angular.z
    _____________    ______________________    __________________________    __________________________    __________________________    __________________________    _____________________________    _____________________________    _____________________________    _____________________________    __________________________    __________________________    __________________________    ___________________________    ___________________________    ___________________________

    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec          {1x1 cell}                  {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                       {1x1 cell}                       {1x1 cell}                       {1x1 cell}                      {1x1 cell}                    {1x1 cell}                    {1x1 cell}                    {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
      ⋮

Create a new timetable for the Pose.Pose.Position.X property in the /odom topic.

tt2 = timetable(bagSel,"pose.pose.position.x")
tt2=5275×1 timetable
        Time         /odom_pose.pose.position.x
    _____________    __________________________

    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
    1.602e+09 sec            {1x1 cell}        
      ⋮

Create a new timetable for all the angular Twist properties in the /odom topic.

tt3 = timetable(bagSel,"twist.twist.angular.x","twist.twist.angular.y","twist.twist.angular.z")
tt3=5275×3 timetable
        Time         /odom_twist.twist.angular.x    /odom_twist.twist.angular.y    /odom_twist.twist.angular.z
    _____________    ___________________________    ___________________________    ___________________________

    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
    1.602e+09 sec            {1x1 cell}                     {1x1 cell}                     {1x1 cell}         
      ⋮

Input Arguments

collapse all

Index of the messages in the rosbag, specified as a ros2bagreader object.

Property names, specified as a string scalar or character vector. You can specify multiple properties. Each property name is a separate input and represents a different column in the time series object.

Output Arguments

collapse all

Timetable containing the message properties, returned as a timetable object. The first column of the timetable consists of timestamps and the rest of the columns consist of message property values for all messages in bag.

Version History

Introduced in R2024a