ros2message
Create ROS 2 message structures
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.
Output Arguments
msg
— ROS 2 message for a given topic
object handle
ROS 2 message for a given topic, returned as an object handle.
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
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
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)