ros2message
Description
Examples
Create a String Message
Create a ROS 2 string message.
strMsg = ros2message('std_msgs/String')
strMsg = struct with fields:
MessageType: 'std_msgs/String'
data: ''
Create an empty laser scan message
Create an empty ROS 2 laser scan message.
scanMsg = ros2message("sensor_msgs/LaserScan")
scanMsg = struct with fields:
MessageType: 'sensor_msgs/LaserScan'
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
msgType
— Message type for a ROS 2 topic
character vector
Message type for a ROS 2 topic, specified as a character vector.
client
— ROS 2 action client
ros2actionclient
object handle
ROS 2 action client, specified as a ros2actionclient
object handle.
Output Arguments
msg
— ROS 2 message for a given topic
structure
ROS 2 message for a given topic, returned as a message structure.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
This function supports C/C++ code generation with the limitations:
For messages with fields containing cell array of strings, such as
sensor_msgs/JointState
, accessing those fields in the MATLAB® function is not supported.
Version History
Introduced in R2019bR2022a: Deprecation of Messages
The following messages in std_msgs
is deprecated in ROS 2 Foxy Fitzroy.
Messages |
---|
std_msgs/msg/Bool |
std_msgs/msg/Byte |
std_msgs/msg/ByteMultiArray |
std_msgs/msg/Char |
std_msgs/msg/Float32 |
std_msgs/msg/Float32MultiArray |
std_msgs/msg/Float64 |
std_msgs/msg/Float64MultiArray |
std_msgs/msg/Int16 |
std_msgs/msg/Int16MultiArray |
std_msgs/msg/Int32 |
std_msgs/msg/Int32MultiArray |
std_msgs/msg/Int64 |
std_msgs/msg/Int64MultiArray |
std_msgs/msg/Int8 |
std_msgs/msg/Int8MultiArray |
std_msgs/msg/MultiArrayDimension |
std_msgs/msg/MultiArrayLayout |
std_msgs/msg/String |
std_msgs/msg/UInt16 |
std_msgs/msg/UInt16MultiArray |
std_msgs/msg/UInt32 |
std_msgs/msg/UInt32MultiArray |
std_msgs/msg/UInt64 |
std_msgs/msg/UInt64MultiArray |
std_msgs/msg/UInt8 |
std_msgs/msg/UInt8MultiArray |
See Also
ros2node
| ros2publisher
| ros2subscriber
| ros2actionclient
| ros2
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)