Main Content

ros2message

Create ROS 2 message structures

Description

example

msg = ros2message(msgType) creates a structure compatible with ROS 2 messages of type msgType.

Examples

collapse all

Create a ROS 2 string message.

strMsg = ros2message('std_msgs/String')
strMsg = struct with fields:
    data: ''

Create an empty ROS 2 laser scan message.

scanMsg = ros2message("sensor_msgs/LaserScan")
scanMsg = struct with fields:
             header: [1x1 struct]
          angle_min: 0
          angle_max: 0
    angle_increment: 0
     time_increment: 0
          scan_time: 0
          range_min: 0
          range_max: 0
             ranges: 0
        intensities: 0

Input Arguments

collapse all

Message type for a ROS 2 topic, specified as a character vector.

Output Arguments

collapse all

ROS 2 message for a given topic, returned as an object handle.

Introduced in R2019b