Main Content

Visualize Messages from Live ROS or ROS 2 Topics

Connect to Source ROS or ROS 2 Network

To connect the ROS Data Analyzer app to a live ROS or ROS 2 network, use the Open > Live Network Data option from the app toolstrip.

Open live network in ROS Data Analyzer

To visualize topics in a live ROS network, provide the ROS Master URI in the Enter Network Details dialog box after clicking Live ROS network data. The default ROS Master URI is set to http://localhost:11311. You can also choose from the latest 10 ROS Master URI entries stored in the dropdown.

ROS Master URI in ROS Data Analyzer

To visualize topics in a live ROS 2 network, provide the ROS Domain ID. The default ROS Domain ID is set to 0. You can also choose from the latest 10 ROS Domain ID entries stored in the dropdown, similar to ROS Master URI.

ROS 2 Domain ID for ROS Data Analyzer

The toolstrip also contains the list of supported visualizers under the Visualize tab, and allows you to choose the layout between Default and Grid.

View Live Network Details

The details of live network are found on the left side under the app toolstrip.

  • Upon accessing a live network for visualization, the toolstrip automatically configures itself, displaying the Start Start Live Viewer Icon icon.

  • The Topic List shows the available topics in the ROS or ROS 2 live network. Click Refresh to update the Topic List with latest topics added to the opened live network.

  • The Source Details lists the ROS Master URI if you have opened a live ROS network. In case of a live ROS 2 network, it shows the ROS Domain ID.

app interface at opening of live network

Create Visualizers for Topics

You can configure the grid layout from the Layout tab and choose one or multiple viewers to visualize the messages in a topic. Choose the data source that you want to visualize from the dropdown of the selected viewer and click Start Start Live Viewer Icon icon from the toolstrip to commence the visualization of the live network topic. Upon initiating the visualization, the Start icon transitions to a Stop icon Stop Live Viewer Icon which enables you to halt the visualization at any specific instant.

Types of Viewer

ViewerViewer IconInterfaceDescription
Image Viewer

Image Viewer Icon

Image viewer in ROS Bag Viewer App

  1. Load a bag file containing sensor_msgs/Image or sensor_msgs/CompressedImage message type.

  2. Select Image Viewer from the toolstrip and choose the data source from the drop down to visualize the image.

  3. Use the top-right corner options to zoom in and out, and pan the image in all directions.

Point Cloud Viewer

Point cloud Viewer Icon

Point Cloud Viewer in ROS Bag Viewer App

  1. Load a bag file containing sensor_msgs/PointCloud2 message type.

  2. Select Point Cloud Viewer from the toolstrip and choose the data source from the drop down to visualize the point cloud message.

  3. Use the top-right corner options to zoom in and out, pan, and rotate the message in 3D.

Laser Scan Viewer

Laser Scan Viewer Icon

Laser Scan Viewer of the ROS Bag Viewer App

  1. Load a bag file containing sensor_msgs/LaserScan message type.

  2. Select Laser Scan Viewer from the toolstrip and choose the data source from the drop down to visualize the laser scan message.

  3. Use the options on the top to zoom in and out, pan, and rotate the message 3D.

Odometry Viewer

Odometry Viewer Icon

Odometry Viewer of the ROS Bag Viewer App

  1. Load a bag file containing nav_msgs/Odometry message type.

  2. Select Odometry Viewer from the toolstrip and choose the data source from the drop down to visualize the odometry message.

  3. See the indicator to view the instantaneous location of the robot in the trajectory.

  4. Use the top-right corner options to zoom in and out, and pan in all directions.

XY Plot Viewer

XY Plot Viewer Icon

XY Plot Viewer of ROS BAG Viewer App

  1. Load a bag file containing geometry_msgs/Point or nav_msgs/Odometry message type.

  2. Select XY Plot Viewer from the toolstrip and choose the data source from the drop down to visualize how the numeric message field changes across the XY axes.

  3. See the indicator to view the instantaneous location of the robot across the XY axes.

  4. Use the top-right corner options to zoom in and out, and pan in all directions.

Time Plot Viewer

Time Plot Icon

Time Plot Viewer of ROS BAG Viewer App

  1. Load a bag file containing geometry_msgs/Point or nav_msgs/Odometry message type.

  2. Select Time Plot Viewer from the toolstrip and choose the data source from the drop down to visualize how the numeric message field changes with respect to time.

  3. See the indicator to view the instantaneous location of the robot.

  4. Use the top-right corner options to zoom in and out, and pan in all directions.

Message Viewer

Message viewer Icon

Message Viewer of the ROS Bag Viewer App

  1. Load a bag file containing any message type.

  2. Select Message Viewer from the toolstrip and choose the data source from the drop down to visualize the raw message stored in the rosbag.

Map Viewer

Map Viewer Icon

Map Viewer of the ROS Bag Viewer App

  1. Load a bag file containing sensor_msgs/NavSatFix or gps_common/GPSFix message types.

  2. Select Map Viewer from the toolstrip and choose the data source from the drop down to visualize the GPS message.

  3. See the indicator to view the instantaneous location of the GPS coordinate in the trajectory.

  4. Use the top-right corner options to zoom in and out, and pan in all directions.

3D Viewer

3D Viewer Icon

3D Viewer of the ROS Bag Viewer App

  1. Load a bag file containing sensor_msgs/PointCloud2, sensor_msgs/LaserScan, visualization_msgs/Marker or visualization_msgs/MarkerArray message type.

  2. Select 3D viewer from the toolstrip to open the 3D Settings tab at the top-right edge of the app canvas.

  3. Select one or multiple topics from the table in the 3D Settings tab for overlaid 3D visualization.

  4. Specify the visualization color of the selected topics between these options from the dropdown:

    • Default — Message appears in the viewer in its default color, based on PARULA default colors and theme.

    • Flat Color — Opens color picker to choose from a set of Standard Colors and Custom Colors (RGB) options and overwrite the default color data stored in the message.

  5. Click Base Frame ID to choose the coordinate frame for rendering the scene. The camera position and orientation are relative to the origin of this frame.

    To render a scene, you must have a transform from its frame to the selected coordinate frame in the Base Frame ID parameter. If the scene's frame matches the Base Frame ID, you do not need to apply an additional transform.

    For more information on transform between coordinate frames for scene rendering, see the Transforms for Marker and 3D Visualization table.

  6. Use the top-right corner options in the viewer to zoom in and out, pan, and rotate the messages in 3-D.

Marker Viewer

Marker Viewer Icon

Marker Viewer of the ROS Bag Viewer App

  1. Load a bag file containing visualization_msgs/Marker or visualization_msgs/MarkerArray message types.

  2. Select Marker Viewer from the toolstrip and choose the data source from the drop down in the Visualizer Settings tab to visualize the marker message.

  3. Click Base Frame ID to specify the frame ID which you want to be the global frame for marker visualization.

    To render a marker, you must have a transform from its frame to the selected coordinate frame in the Base Frame ID parameter. If the scene's frame matches the Base Frame ID, you do not need to apply an additional transform.

    For more information on transform between coordinate frames for scene rendering, see the Transforms for Marker and 3D Visualization table.

  4. Use the top-right corner options to zoom in and out, pan, and rotate the message in 3-D.

  5. From the Tools section on the app toolstrip, you can:

    • Toggle the marker visualizer view between 2-D and 3-D axes.

    • Select two marker points and measure distance between them. Use the data tips option in the top-right corner to select the two points of interest.

Example

Visualize Messages from Topic in Live ROS 2 Network

This example shows how to create a ROS 2 node, publish messages to a topic in that node and visualize those messages live in the ROS Data Analyzer app.

Create a ROS 2 node in the network specified by the default Domain ID 0.

node = ros2node("myNode")
node = 
  ros2node with properties:

    Name: '/myNode'
      ID: 0

Create a ROS 2 publisher object to publish messages on a topic of the message type std_msgs/Int32. Add the topic to the network topic list.

pub = ros2publisher(node,"myTopic","std_msgs/Int32")
pub = 
  ros2publisher with properties:

        TopicName: '/myTopic'
      MessageType: 'std_msgs/Int32'
          History: 'keeplast'
            Depth: 10
      Reliability: 'reliable'
       Durability: 'volatile'
         Deadline: Inf
         Lifespan: Inf
       Liveliness: 'automatic'
    LeaseDuration: Inf

You can now see the list of topic names in the publisher pub registered in the ROS 2 network.

ros2 topic list
/myTopic
/parameter_events
/rosout

Create an empty message determined by the topics published by the ROS 2 publisher pub.

msg = ros2message(pub)
msg = struct with fields:
    MessageType: 'std_msgs/Int32'
           data: 0

Create for loop to change the message being published to pub every second with an increment of 1.

for ctr=1:1000
    msg.data=int32(ctr);
    pub.send(msg)
    pause(1)
end

Open ROS Data Analyzer using this command in the Command Window. You can also open the app from the Apps tab in MATLAB® toolstrip.

rosDataAnalyzer

Open the live ROS 2 Network from the app toolstrip and you can verify the topics present in this live network under Topic List.

Select the Message Viewer from the Visualize tab and select the data source /myTopic from the dropdown of the viewer. Click the Start icon from the Visualization tab in the toolstrip to visualize the messages in this live network. You can stop the visualization at any specific time by clicking the Stop icon.

Next Steps

Load and Play ROS or ROS 2 Bag File

See Also