4  14-Jul-2022 01:36  8 / 8  ](https://build.ros.org//job/Mdev__image_pipeline__ubuntu_bionic_amd64/4/)

Documented

Single image rectification and color processing.

  * Maintainer status: developed
  * Maintainer: Vincent Rabaud <vincent.rabaud AT gmail DOT com>, Steven Macenski <stevenmacenski AT gmail DOT com>, Autonomoustuff team <software AT autonomoustuff DOT com>
  * Author: Patrick Mihelich, Kurt Konolige, Jeremy Leibs
  * License: BSD
  * Source: git [ https://github.com/ros-perception/image_pipeline.git ](https://github.com/ros-perception/image_pipeline) (branch: melodic)

_**[ image_pipeline ](/image_pipeline?distro=noetic) ** : [ camera_calibration
](/camera_calibration?distro=noetic) | [ depth_image_proc
](/depth_image_proc?distro=noetic) | image_proc | [ image_publisher
](/image_publisher?distro=noetic) | [ image_rotate
](/image_rotate?distro=noetic) | [ image_view ](/image_view?distro=noetic) | [
stereo_image_proc ](/stereo_image_proc?distro=noetic) _

**Package Links**

  * **[ Code API ](http://docs.ros.org/en/noetic/api/image_proc/html) **
  * [ Tutorials ](/image_proc/Tutorials)
  * [ FAQ ](http://answers.ros.org/questions/scope:all/sort:activity-desc/tags:image_proc/page:1/)
  * [ Changelog ](http://docs.ros.org/en/noetic/changelogs/image_proc/changelog.html)
  * [ Change List ](/image_pipeline/ChangeList)
  * [ Reviews ](/image_proc/Reviews)

** Dependencies  (9) **

  * [ catkin ](/catkin?distro=noetic)
  * [ cv_bridge ](/cv_bridge?distro=noetic)
  * [ dynamic_reconfigure ](/dynamic_reconfigure?distro=noetic)
  * [ image_geometry ](/image_geometry?distro=noetic)
  * [ image_transport ](/image_transport?distro=noetic)
  * [ nodelet ](/nodelet?distro=noetic)
  * [ nodelet_topic_tools ](/nodelet_topic_tools?distro=noetic)
  * [ roscpp ](/roscpp?distro=noetic)
  * [ sensor_msgs ](/sensor_msgs?distro=noetic)


See the documentation pages of [ rviz ](http://www.ros.org/wiki/rviz) and [
rosbag ](http://www.ros.org/wiki/rosbag) for more information.


  Page

  * Immutable Page
  * Comments
  * [ Info ](/action/info/image_proc?action=info)
  * [ Attachments ](/action/AttachFile/image_proc?action=AttachFile)
  * More Actions:  Raw Text  Print View  Render as Docbook  Delete Cache  \------------------------  Check Spelling  Like Pages  Local Site Map  \------------------------  Rename Page  Copy Page  Delete Page  \------------------------  My Pages  Subscribe User  \------------------------  Remove Spam  Revert to this revision  Package Pages  Sync Pages  \------------------------  CreatePdfDocument  Load  RawFile  Save  SlideShow


Relying on the OpenCV library, the  [ lane_detection
](https://github.com/wilselby/diy_driverless_car_ROS/tree/master/rover_cv/lane_detection
"lane_detection") package contains the nodes and functions to support lane
detection and tracking. For this project, we will focus on identifying the
center lane and providing the position of the lane to a control algorithm. The
control algorithm then computes the desired velocities required to keep the
autonomous car centered on the lane.


  * [ nodelet_topic_tools ](/nodelet_topic_tools?distro=jade)
  * [ roscpp ](/roscpp?distro=jade)
  * [ sensor_msgs ](/sensor_msgs?distro=jade)

** Used by  (10) **

  * [ fetch_gazebo ](/fetch_gazebo?distro=jade)
  * [ image_pipeline ](/image_pipeline?distro=jade)
  * [ openni2_launch ](/openni2_launch?distro=jade)
  * [ opt_camera ](/opt_camera?distro=jade)
  * [ pointgrey_camera_dri... ](/pointgrey_camera_driver?distro=jade)
  * [ rgbd_launch ](/rgbd_launch?distro=jade)
  * [ roseus_tutorials ](/roseus_tutorials?distro=jade)
  * [ stereo_image_proc ](/stereo_image_proc?distro=jade)
  * [ visp_hand2eye_calibr... ](/visp_hand2eye_calibration?distro=jade)
  * [ visp_tracker ](/visp_tracker?distro=jade)


https://pypi.org/project/opencv-python/
https://numpy.org/install/
Run the script, setting the --path argument to what you specified for the <save> tag in the SDF file. Since we set the panoptic save path to segmentation_data/instance_camera, we'd run the following command to view the panoptic segmentation data:


For debugging purposes, it is helpful to visualize the output of this process
on the original image. The pixels identified as lane pixels are highlighted
and the line fitting the lane pixels are both displayed on top of the original
image.


39  17-Jan-2024 15:45  8 / 8  ](https://build.ros.org//job/Ndev__image_pipeline__ubuntu_focal_amd64/39/)
  * [


    def perspective_transform(image, corners, xoffset=0):

         height, width = image.shape[0:2]
         output_size = height/2

         new_top_left=np.array([corners[0,0],0])
         new_top_right=np.array([corners[3,0],0])
         offset=[xoffset,0]
         img_size = (image.shape[1], image.shape[0])
         src = np.float32([corners[0],corners[1],corners[2],corners[3]])
         dst = np.float32([corners[0]+offset,new_top_left+offset,new_top_right-offset ,corners[3]-offset])

         M = cv2.getPerspectiveTransform(src, dst)

         warped = cv2.warpPerspective(image, M, (width, height), flags=cv2.INTER_LINEAR)

    return warped, src, dst


Install the ROS visualization tools if you do not yet have them. From the
command line:


<topic>segmentation</topic>
In this scenario, the sensor data will publish the label map data to segmentation/labels_map, and the colored map data to segmentation/colored_map. We can write some c++ code that subscribes to these topics:


  Package Summary

Released

Continuous Integration

Documented

Single image rectification and color processing.

  * Maintainer status: maintained
  * Maintainer: Vincent Rabaud <vincent.rabaud AT gmail DOT com>
  * Author: Patrick Mihelich, Kurt Konolige, Jeremy Leibs
  * License: BSD
  * Source: git [ https://github.com/ros-perception/image_pipeline.git ](https://github.com/ros-perception/image_pipeline) (branch: groovy-devel)

_**[ image_pipeline ](/image_pipeline?distro=hydro) ** : [ camera_calibration
](/camera_calibration?distro=hydro) | [ depth_image_proc
](/depth_image_proc?distro=hydro) | image_proc | [ image_rotate
](/image_rotate?distro=hydro) | [ image_view ](/image_view?distro=hydro) | [
stereo_image_proc ](/stereo_image_proc?distro=hydro) _

**Package Links**

  * **[ Code API ](http://docs.ros.org/hydro/api/image_proc/html) **
  * [ Tutorials ](/image_proc/Tutorials)
  * [ FAQ ](http://answers.ros.org/questions/scope:all/sort:activity-desc/tags:image_proc/page:1/)
  * [ Changelog ](http://docs.ros.org/en/hydro/changelogs/image_proc/changelog.html)
  * [ Change List ](/image_pipeline/ChangeList)
  * [ Reviews ](/image_proc/Reviews)

** Dependencies  (12) **

  * [ boost ](/boost?distro=hydro)
  * [ camera_calibration_p... ](/camera_calibration_parsers?distro=hydro)
  * [ catkin ](/catkin?distro=hydro)
  * [ cv_bridge ](/cv_bridge?distro=hydro)
  * [ dynamic_reconfigure ](/dynamic_reconfigure?distro=hydro)
  * [ image_geometry ](/image_geometry?distro=hydro)
  * [ image_transport ](/image_transport?distro=hydro)


Now instead of the black screen, we want to actually visualize information. At
the bottom of the 'Displays' group, you'll find buttons 'Add', 'Remove',
'Rename' for adding items to visualize, removing items and renaming them.
Let's first add the robot model, so click 'Add' and scroll to 'rviz >
RobotModel' and click 'OK'. It should now look like the display below.


[ rosbag ](http://www.ros.org/wiki/rosbag) provides an easy tool for the
efficient storage of topic streams during robot operation.


of the diffusion model is Iimage and the output(generated
image) is ˆIimage. Given that the discriminator’s role is fundamentally to address a multi-class semantic segmentation
challenge, its training objective emanates from a foundational
cross-entropy loss:
LDis = −E


X
N
c=1
γc
H
X×W
i,j
li,j,c log(Dis(Iimage)i,j,c)]


−E


H
X×W
i,j
log(Dis(
ˆIimage)i,j,c=N+1)

 ,
(1)
where N is the number of the semantic categories with
H × W represents the spatial size of the input. To control
the importance of different objects
γc =
H × W
PE[li,j,c = 1] (2)
C. Object Detection and Grasping
To fulfill the object detection, the grasping agent framework utilizes dual-camera imagery as its primary input to
deduce the precise location for object grasping. This system
incorporates two distinct visual perspectives: one providing
a broad overview from the robot’s base, termed the global
view, and another offering a detailed focus on the gripper


<sensor name="instance_segmentation_camera" type="segmentation">
  <topic>panoptic</topic>
  <camera>
    <segmentation_type>instance</segmentation_type>
    <horizontal_fov>1.57</horizontal_fov>
    <image>
      <width>800</width>
      <height>600</height>
    </image>
    <clip>
      <near>0.1</near>
      <far>100</far>
    </clip>
    <save enabled="true">
      <path>segmentation_data/instance_camera</path>
    </save>
  </camera>
  <always_on>1</always_on>
  <update_rate>30</update_rate>
  <visualize>true</visualize>
</sensor>
For the semantic segmentation camera, colored map data is published to the semantic/colored_map topic, and label map data is published to the semantic/labels_map topic:


For the instance/panoptic segmentation camera, colored map data is published to the panoptic/colored_map topic, and label map data is published to the panoptic/labels_map topic:


[ ![ROS Gaazebo Lane Detection Position Estimation]( https://s3-us-
west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_gazebo_hist_image.png) ](
https://s3-us-west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_gazebo_hist_image.png)


##  Logging Sensor Data with rosbag


[ ![ROS Gaazebo Lane Detection Perspective Transform]( https://s3-us-
west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_gazebo_persepctive_transform.jpg)
]( https://s3-us-west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_gazebo_persepctive_transform.jpg)


###  Visualizing Sensor Information


    $ rosbag filter <original.bag> <output1.bag> "'topic=/raspicam_node/image/compressed' or topic='/joy_teleop/cmd_vel_stamped'"
    $ rosbag filter <output1.bag> <processed.bag> "t.to_sec() >= <start time>" "t.to_sec() <= <end time>"


###  Running Rviz


Once the camera has reached the ground plane, you can go ahead and close Gazebo. We will now discuss how to visualize the segmentation data that was just generated by Gazebo.


The label map: For semantic segmentation, each pixel contains the object's label. For panoptic segmentation, each pixel contains the label and object's instance count.
The colored map: A colored version of the label map. In semantic segmentation, all items of the same label will have the same color. In panoptic segmentation, each pixel contains a unique color for each instance in the scene (so, for panoptic segmentation, items of the same label will not have the same color).
Assigning a label to a model
Only models with labels (annotated classes) will be visible by the segmentation camera sensor. Unlabeled models will be considered as background.


You can save and load non default configurations by using "File > Save Config
as ... " and "File > Open Config" respectively.


[ Decode Theme ](https://www.machothemes.com/themes/decode/) by [ Macho Themes
](https://www.machothemes.com/ "Professional & Responsive WordPress Themes")


Gazebo is open-source licensed under [ Apache 2.0
](http://www.apache.org/licenses/LICENSE-2.0.html)


####  Software-in-the-loop Simulations


Once satisfied with the performance of the image segmentation algorithm and
the control system, it is time to test everything on the real vehicle.


Dataset Demo
Up to this point, we have left simulation paused. Go ahead and start simulation by pressing the play button at the bottom-left part of the GUI. You'll see the camera drop, capturing updated segmentation images along the way:


      </camera>
      <always_on>1</always_on>
      <update_rate>30</update_rate>
      <visualize>true</visualize>
    </sensor>
  </link>
</model>
Let’s take a closer look at the portion of the code above that focuses on the segmentation camera sensor:


    def region_of_interest(img, vertices):

        #defining a blank mask to start with
        mask = np.zeros_like(img)

        #defining a 3 channel or 1 channel color to fill the mask with depending on the input image
        if len(img.shape) > 2:
            channel_count = img.shape[2]  # i.e. 3 or 4 depending on your image
            ignore_mask_color = (255,) * channel_count
        else:
            ignore_mask_color = 255

        #filling pixels inside the polygon defined by "vertices" with the fill color
        cv2.fillPoly(mask, vertices, ignore_mask_color)

        #returning the image only where mask pixels are nonzero
        masked_image = cv2.bitwise_and(img, mask)
    return masked_image


sudo apt-get install ros-indigo-viz


arm, referred to as the local view. The global view guides
the movement of the robot base and the local view is
responsible for adjusting the position of the gripper. The
two cooperate to achieve accurate grasping of objects. Thus,
the system’s input is symbolized as x in the domain of
x ∈ R
B2×C×H×W , integrates these two visual feeds, where
B2 signifies the batch size coupled with the dual imagery
inputs, and C×H×W delineates the images’ channel (C),
height (H), and width (W) dimensions. To ensure effective
Sim-to-Real translation without prior real-world training, the
network outputs spatial coordinates of the intended grasp
target within the observed image, represented by a bounding
box (bounding box) notation. The output format is denoted
as a vector
a = [x
min
l
, ymin
l
, xmax
l
, ymax
l
, xmin
g
, ymin
g
, xmax
g
, ymax
g
] ∈ R
8
within the R8
space, captures the target’s bounding box
coordinates on both local (l) and global (g) images. This
output subsequently informs the robot’s grasping actions
through a closed-loop mechanism based on the computed
bounding box predictions.


#  Image Segmentation


computer vision tasks that demand a comprehensive
TABLE I: Comparison of sim-to-real transformation quality across different methods. Appearance fidelity is evaluated using
the Inception Score (IS), while Object Detection with YOLOv8 is assessed using typical metrics (Precision-P, Recall-R,
mAP50, and mAP50-90).
Method Appearance Fidelity Object Detection
IS ↑ P R mAP50 mAP50-95
Sim-Only - 0.421 0.353 0.460 0.255
CycleGAN [8] 3.656 0.575 0.444 0.554 0.284
ControlNet [12] 5.516 0.331 0.560 0.499 0.279
ALDM [14] 5.641 0.538 0.574 0.633 0.313 Gazebo Segmentation ALDM
1st Scene
2nd Scene
3rd Scene
4th Scene
5th Scene
ControlNet
Fig. 3: Experiment results in image generation. In the
Gazebo column, we constructed five simulation scenarios
in the Gazebo framework, meticulously designed to align
with the physical layout of the laboratory environment. In the
Segmentation column, the outcomes of object segmentation,
derived from the simulated settings, serve as the inputs for
the layout-to-diffusion model, delineated through predefined
labels. In the ControlNet column, the images show incorrect image contents and inaccurate object positions. In the
ALDM column, it shows the output generated by the image
synthesis model. Notably, the produced imagery not only
exhibits precise localization of the target objects but also
embodies a stylistic resemblance to the actual environmental
setting, demonstrating the model’s efficacy in bridging the
gap between the simulated images’ style and laboratory
environment.
understanding of both the broader scene and the finer
details of objects, including image segmentation and
scene analysis. The dataset’s extensive annotations,
which cover a broad spectrum of objects and their parts
with precision, make it an essential tool for researchers
aiming to advance the field of detailed scene interpretation.
• The Cityscapes dataset [31] offers a comprehensive
collection of over 25,000 urban scene images, designed
to enhance semantic understanding of urban street environments. It uniquely combines 5,000 pixel-level annotated images for detailed analysis and 20,000 coarsely


sudo apt-get install ros-groovy-rviz


[ ![ROS RasPiCam Lane Detection Verification]( https://s3-us-
west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_sitl_control_comparison.png) ](
https://s3-us-west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_sitl_control_comparison.png)


  Published Topics

` ~image ` ( [ sensor_msgs/Image
](http://docs.ros.org/en/api/sensor_msgs/html/msg/Image.html) )

  * Resized image.

` ~camera_info ` ( [ sensor_msgs/CameraInfo
](http://docs.ros.org/en/api/sensor_msgs/html/msg/CameraInfo.html) )

  * Resized camera info.


Processing the segmentation sensor via gz-transport
It's possible to process the segmentation data in real time via gz-transport. You will need to which topics to subscribe to in order to receive this information.


The node receives images from the camera and outputs a processed image. The
node also computes the desired speeds and publishes those commands with and
without a timestamp.


Setting up the segmentation camera
Here's an example of how to attach a segmentation camera sensor to a model in a SDF file:


**For drcsim >= 4.1.0 ** : If you are using atlas versions >= v3 (e.g.
atlas_v3.launch), use the following rosbag command instead:


* Holding scroll wheel and dragging pans the camera


Nodes


#  Overview


  User

  * [ Login ](/action/login/image_proc?action=login)

melodic  noetic  _Show EOL distros:_

_EOL distros:_ electric  fuerte  groovy  hydro  indigo  jade  kinetic  lunar

[ See image_proc on index.ros.org for more info including aything ROS 2
related. ](https://index.ros.org/p/image_proc)

[ Documentation Status ](javascript:toggleDocStatus\(\))

  * **diamondback:** _Only showing information from the released package extracted on Unknown. No API documentation available. Please see[ this page ](http://wiki.ros.org/rosdistro/Tutorials/Indexing%20Your%20ROS%20Repository%20for%20Documentation%20Generation) for information on how to submit your repository to our index. _

  * **electric:** _Documentation generated on Unknown_

  * **fuerte:** _Documentation generated on January 03, 2014 at 11:24 AM_

  * **groovy:** _Documentation generated on October 06, 2014 at 12:45 AM_

  * **hydro:** _Documentation generated on August 26, 2015 at 11:57 AM_ ( [ doc job ](http://jenkins.ros.org/job/doc-hydro-image_pipeline/) ).

  * **indigo:** _Documentation generated on May 01, 2019 at 10:44 AM_ ( [ doc job ](http://build.ros.org/view/Idoc/job/Idoc__image_pipeline__ubuntu_trusty_amd64) ).

  * **jade:** _Documentation generated on September 19, 2017 at 10:34 AM_ ( [ doc job ](http://build.ros.org/view/Jdoc/job/Jdoc__image_pipeline__ubuntu_trusty_amd64) ).

  * **kinetic:** _Documentation generated on November 07, 2019 at 03:32 AM_ ( [ doc job ](http://build.ros.org/view/Kdoc/job/Kdoc__image_pipeline__ubuntu_xenial_amd64) ).

  * **lunar:** _Documentation generated on May 03, 2019 at 10:55 AM_ ( [ doc job ](http://build.ros.org/view/Ldoc/job/Ldoc__image_pipeline__ubuntu_xenial_amd64) ).


The video below provides a quick summary of this section including the Elegoo
navigating autonomously around a track with a black center lane line.


[ ](https://wilselby.com/)


We will use a modified launch file,  [ rover_center_line_cam_hitl.launch
](https://github.com/wilselby/diy_driverless_car_ROS/blob/master/rover_cv/lane_detection/launch/rover_center_line_cam_hitl.launch
"rover_center_line_cam_hitl.launch") , to view the output of our image
segmentation algorithm and control calculations. This launch file plays the
refined bag file as well as the nodes required for autonomous navigation. It
does not run the rosserial node required for connecting to the Arduino since
this isn’t required for this test.


36  18-Oct-2022 19:45  8 / 8  ](https://build.ros.org//job/Ndev__image_pipeline__ubuntu_focal_amd64/36/)

Documented

Single image rectification and color processing.

  * Maintainer status: maintained
  * Maintainer: Vincent Rabaud <vincent.rabaud AT gmail DOT com>, Autonomoustuff team <software AT autonomoustuff DOT com>
  * Author: Patrick Mihelich, Kurt Konolige, Jeremy Leibs
  * License: BSD
  * Source: git [ https://github.com/ros-perception/image_pipeline.git ](https://github.com/ros-perception/image_pipeline) (branch: noetic)

Contents

  1. Overview
  2. Mini Tutorial
  3. Nodes
    1. image_proc
  4. Nodelets
    1. image_proc/debayer
    2. image_proc/rectify
    3. image_proc/crop_decimate
    4. image_proc/resize
  5. Launch files
    1. image_proc.launch


You can also attach this plugin to the model's <model> tag:


[ ![ROS Gaazebo Lane Detection ROS Bag Edits]( https://s3-us-
west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_rosbag_filter.png) ](
https://s3-us-west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_rosbag_filter.png)


Given the segmented image, the node computes the line of best fit for the
lane. If detected, the line is drawn on the output image.


**Bonus: actuate the laser.** The laser on the robot's head is mounted on a
spindle that rotates. To start it rotating:


[ ![ROS Gaazebo Lane Detection Visulaization]( https://s3-us-
west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_gazebo_control_image.png) ](
https://s3-us-west-2.amazonaws.com/selbystorage/wp-
content/uploads/2017/July/ros_driverless_car_gazebo_control_image.png)


When it comes time to bring down this process, press Control + C in the same
terminal window. Closing Gazebo from the GUI will not kill the additional
processes spawned with roslaunch.


Table I quantitatively evaluates the quality of sim-to-real
transfer. In the Appearance Fidelity section, we utilize the
Inception Score (IS) to determine whether the sim-to-real
generated images possess sufficient fidelity. In the Object
Detection section, considering that images transferred from
sim-to-real with superior spatial consistency are more effective as training data for detection, we incorporate sim-toreal images generated by different methods into the YOLOv8
detection training dataset and evaluate them using the same
real-image test set. As shown in Table I, ALDM outperforms
in both aspects, showcasing its exceptional zero-shot sim-toreal transfer capabilities. Interestingly, although the ControlNet model generates images of higher fidelity compared to
CycleGAN, its detection outcomes are inferior. This may
be attributed to ControlNet’s emphasis on appearance while
neglecting spatial consistency.
TABLE II: The success rates of grasping in 20 trials for
different methods with two types of backgrounds
Methods Plain background Complex background
Sim-Only 10% 0%
CycleGAN 0% 0%
ControlNet 25% 5%
ALDM 75% 65%
C. Experiments in Real Environment With Zero-Shot Sim-toReal Transfer
The experiment assessed the grasping success rate across
five real-world environments, ranging from basic to complex
setups augmented with novel visual noise to challenge the
segmentation model. As detailed in Table II, the experiment’s
results highlight the varying success rates of object grasping
methods in 20 trials across plain and complex backgrounds.
The failure of CycleGAN is attributed to its inability to
generalize to complex testing environments when faced with
varying backgrounds. ControlNet’s underperformance is due
to inadequate object generation quality and quantity. Conversely, our ALDM-based model excels not only in simple
backgrounds, achieving a 75% success rate in object grasping
tasks but also maintains a considerable 65% success rate in
complex environments. This robust performance of ALDM
can be credited to its capacity to generate high-quality images
and the robustness of the algorithm, which stands as a
testament to its superiority in handling object-grasping tasks
under diverse conditions.
V. CONCLUSION & DISCUSSION
This paper presents a groundbreaking framework, ALDMGrasping, that utilizes ALDM for zero-shot Sim-to-Real
transfer in visual grasping tasks. The model excels in generating controlled image content from textual descriptions,


####  Required Dependencies


  * [ bag_tools ](/bag_tools?distro=groovy)
  * [ cob_bringup ](/cob_bringup?distro=groovy)
  * [ cob_controller_confi... ](/cob_controller_configuration_gazebo?distro=groovy)
  * [ freenect_launch ](/freenect_launch?distro=groovy)
  * [ image_pipeline ](/image_pipeline?distro=groovy)
  * [ openni2_launch ](/openni2_launch?distro=groovy)
  * [ openni_launch ](/openni_launch?distro=groovy)
  * [ opt_camera ](/opt_camera?distro=groovy)
  * [ pr2_gazebo ](/pr2_gazebo?distro=groovy)
  * [ rosie_bringup ](/rosie_bringup?distro=groovy)
  * [ stereo_image_proc ](/stereo_image_proc?distro=groovy)
  * [ visp_hand2eye_calibr... ](/visp_hand2eye_calibration?distro=groovy)
  * [ visp_tracker ](/visp_tracker?distro=groovy)


[ Back ](/tutorials?cat=drcsim)


We assume that you've already done the [ installation step
](/tutorials?tut=drcsim_install&cat=drcsim) .


Once the image has been segmented, ideally with the lane detected, we need to
calculate the position of the lane. The position of the lane is estimated by
fitting a polynomial line to the lane pixels. This process is performed by the
fit_polynomials  function which is available in the  [
lane_detection_module.py
](https://github.com/wilselby/diy_driverless_car_ROS/blob/master/rover_cv/lane_detection/src/lane_detection/lane_detection_module.py
"lane_detection_module.py") fie for further review. In general, the function
performs the following steps:


** WARNING ** : This documentation is for Gazebo-classic, which has been
superseded by Gazebo. [ Click here to see the documentation for the latest
Gazebo release ](https://gazebosim.org/docs)


To navigate using a wheeled mouse:


  * [ nodelet_topic_tools ](/nodelet_topic_tools?distro=indigo)
  * [ roscpp ](/roscpp?distro=indigo)
  * [ sensor_msgs ](/sensor_msgs?distro=indigo)

** Used by  (16) **

  * [ astra_launch ](/astra_launch?distro=indigo)
  * [ bag_tools ](/bag_tools?distro=indigo)
  * [ cob_bringup ](/cob_bringup?distro=indigo)
  * [ fetch_gazebo ](/fetch_gazebo?distro=indigo)
  * [ freenect_launch ](/freenect_launch?distro=indigo)
  * [ image_pipeline ](/image_pipeline?distro=indigo)
  * [ mobility_base_bringu... ](/mobility_base_bringup?distro=indigo)
  * [ openni2_launch ](/openni2_launch?distro=indigo)
  * [ opt_camera ](/opt_camera?distro=indigo)
  * [ pointgrey_camera_dri... ](/pointgrey_camera_driver?distro=indigo)
  * [ pr2_gazebo ](/pr2_gazebo?distro=indigo)
  * [ rgbd_launch ](/rgbd_launch?distro=indigo)
  * [ roseus_tutorials ](/roseus_tutorials?distro=indigo)
  * [ stereo_image_proc ](/stereo_image_proc?distro=indigo)
  * [ visp_hand2eye_calibr... ](/visp_hand2eye_calibration?distro=indigo)
  * [ visp_tracker ](/visp_tracker?distro=indigo)


  Wiki

  * [ Distributions ](/Distributions)
  * [ ROS/Installation ](/ROS/Installation)
  * [ ROS/Tutorials ](/ROS/Tutorials)
  * [ RecentChanges ](/RecentChanges)
  * [ image_proc ](/image_proc)


A. Robot Training and Robotic Control Pipeline
To train a robot to grasp, the whole working pipeline can
be seen in Figure 2. The whole procedure contains two parts:
• Image generation model part firstly builds the simulation environments in the gazebo simulation platform.
The labels of different objects can be set into the
gazebo, thus the segmentation image can be easily
obtained. These segmentation images are fed into the
diffusion model as the condition images/layout images,
and the ground truth labels are used for the training of
object detection. In this part (Figure 2(a)), segmentation
images are set as the layout and passed with the prompt
to the ALDM, which is a U-Net [28] structure. The
generated images, produced by the diffusion model, will
be passed to a pre-trained segmenter-based discriminator. The discriminator will compare the segmentation
results of the generated image and the layout image
to guarantee the content of the generated realistic-style
image consistent with the input.
• Grasping Agent Network After the realistic-style images are generated based on the simulation environments, these generated images will be used as the training data for the object detection model (YOLOv8 [29]).
The segmentation images will be treated as labels. The
two RealSense RGB-D cameras on the physical robot
will pass the image data to the pre-trained YOLOv8
model to separately generate the bounding box. Finally,
the Control Unit will calculate the distance between
bounding boxes to decide the robot base and gripper
movement.
B. Layout-to-Image Diffusion Model
ALDM innovates the field of image synthesis by introducing adversarial supervision within the training framework of diffusion models. The key to this advancement is
the employment of a discriminator, a segmentation-based
model, that furnishes explicit, pixel-level feedback on the
alignment between the generated images and the input layout. This mechanism not only bolsters the fidelity of the
generated images to the specified layout but also preserves
the versatility of text-driven editability. Such advancements
are important for applications demanding high precision in
generated content, such as robotic grasping, where accurate
object positioning and count are paramount for effective
training.
The segmenter functions as a discriminator, tasked with
classifying per-pixel class labels in authentic images against
corresponding ground-truth maps. Simultaneously, it designates the synthetic outputs from the diffusion model as an
additional ”fake” category l. Suppose the input(layout image)


  Overview

This package contains the [ image_proc node
](/image_proc


####  Image Segmentation Algorithm


You should now be familiar with how to visualize ROS topics in rviz as well as
how to log them to a rosbag. You should also now be familiar with how to
replay rosbag files and visualize them in rviz.


  image_proc/debayer

Takes a raw camera stream and publishes monochrome and color versions of it.
If the raw images are Bayer pattern, it debayers using bilinear interpolation.


    * [ Documenting a ROS 2 package ](../../How-To-Guides/Documenting-a-ROS-2-Package.html)
    * [ ament_cmake user documentation ](../../How-To-Guides/Ament-CMake-Documentation.html)
    * [ ament_cmake_python user documentation ](../../How-To-Guides/Ament-CMake-Python-Documentation.html)
    * [ Migrating from ROS 1 to ROS 2 ](../../How-To-Guides/Migrating-from-ROS1.html)
      * [ Migrating Packages ](../../How-To-Guides/Migrating-from-ROS1/Migrating-Packages.html)
      * [ Migrating Interfaces ](../../How-To-Guides/Migrating-from-ROS1/Migrating-Interfaces.html)
      * [ Migrating C++ Packages ](../../How-To-Guides/Migrating-from-ROS1/Migrating-CPP-Packages.html)
      * [ Migrating Python Packages ](../../How-To-Guides/Migrating-from-ROS1/Migrating-Python-Packages.html)
      * [ Migrating Launch Files ](../../How-To-Guides/Migrating-from-ROS1/Migrating-Launch-Files.html)
      * [ Migrating Parameters ](../../How-To-Guides/Migrating-from-ROS1/Migrating-Parameters.html)
      * [ Migrating Scripts ](../../How-To-Guides/Migrating-from-ROS1/Migrating-Scripts.html)
    * [ Using Python, XML, and YAML for ROS 2 Launch Files ](../../How-To-Guides/Launch-file-different-formats.html)
    * [ Using ROS 2 launch to launch composable nodes ](../../How-To-Guides/Launching-composable-nodes.html)
    * [ Passing ROS arguments to nodes via the command-line ](../../How-To-Guides/Node-arguments.html)
    * [ Synchronous vs. asynchronous service clients ](../../How-To-Guides/Sync-Vs-Async.html)
    * [ DDS tuning information ](../../How-To-Guides/DDS-tuning.html)
    * [ rosbag2: Overriding QoS Policies ](../../How-To-Guides/Overriding-QoS-Policies-For-Recording-And-Playback.html)
    * [ Working with multiple ROS 2 middleware implementations ](../../How-To-Guides/Working-with-multiple-RMW-implementations.html)
    * [ Cross-compilation ](../../How-To-Guides/Cross-compilation.html)
    * [ Releasing a Package ](../../How-To-Guides/Releasing/Releasing-a-Package.html)
      * [ First Time Release ](../../How-To-Guides/Releasing/First-Time-Release.html)
      * [ Subsequent Releases ](../../How-To-Guides/Releasing/Subsequent-Releases.html)
      * [ Release Team / Repository ](../../How-To-Guides/Releasing/Release-Team-Repository.html)
      * [ Release Track ](../../How-To-Guides/Releasing/Release-Track.html)
    * [ Using Python Packages with ROS 2 ](../../How-To-Guides/Using-Python-Packages.html)
    * [ Porting RQt plugins to Windows ](../../How-To-Guides/RQt-Port-Plugin-Windows.html)
    * [ Running ROS 2 nodes in Docker [community-contributed] ](../../How-To-Guides/Run-2-nodes-in-single-or-separate-docker-containers.html)
    * [ Visualizing ROS 2 data with Foxglove Studio ](../../How-To-Guides/Visualizing-ROS-2-Data-With-Foxglove-Studio.html)
    * [ ROS 2 Package Maintainer Guide ](../../How-To-Guides/Package-maintainer-guide.html)
    * [ Building a custom Debian package ](../../How-To-Guides/Building-a-Custom-Debian-Package.html)
    * [ Building ROS 2 with tracing ](../../How-To-Guides/Building-ROS-2-with-Tracing.html)
    * [ Topics vs Services vs Actions ](../../How-To-Guides/Topics-Services-Actions.html)
    * [ Using variants ](../../How-To-Guides/Using-Variants.html)
    * [ Using the ` ros2  param  ` command-line tool ](../../How-To-Guides/Using-ros2-param.html)
    * [ Using ` ros1_bridge  ` with upstream ROS on Ubuntu 22.04 ](../../How-To-Guides/Using-ros1_bridge-Jammy-upstream.html)
    * [ Configure Zero Copy Loaned Messages ](../../How-To-Guides/Configure-ZeroCopy-loaned-messages.html)
    * [ ROS 2 on Raspberry Pi ](../../How-To-Guides/Installing-on-Raspberry-Pi.html)
    * [ Using Callback Groups ](../../How-To-Guides/Using-callback-groups.html)
    * [ IDEs and Debugging [community-contributed] ](../../How-To-Guides/ROS-2-IDEs.html)
    * [ Setup ROS 2 with VSCode and Docker [community-contributed] ](../../How-To-Guides/Setup-ROS-2-with-VSCode-and-Docker-Container.html)


Find the package that generates message code from msg/srv files:


* 4 Try it out


###  5 (Extra) Use an existing interface definition  ï


##  Messages  ï


* currently string values are not escaped


[ Python ](https://design.ros2.org/articles/generated_interfaces_python.html)


    install/setup.ps1
    ros2 topic echo /address_book


[ C++ ](https://design.ros2.org/articles/generated_interfaces_cpp.html)


Each constant definition is like a field description with a default value,
except that this value can never be changed programatically. This value
assignment is indicated by use of an equal â=â sign, e.g.


    int32 X=123
    int32 Y=-123
    string FOO="foo"
    string EXAMPLE='bar'


Default values can be set to any field in the message type. Currently default
values are not supported for string arrays and complex types (i.e. types not
present in the built-in-types table above; that applies to all nested
messages).


Other Versions  v: foxy


short

uint16


    * [ Demos ](../Tutorials/Demos.html)
      * [ Using quality-of-service settings for lossy networks ](../Tutorials/Demos/Quality-of-Service.html)
      * [ Managing nodes with managed lifecycles ](../Tutorials/Demos/Managed-Nodes.html)
      * [ Setting up efficient intra-process communication ](../Tutorials/Demos/Intra-Process-Communication.html)
      * [ Recording and playing back data with ` rosbag  ` using the ROS 1 bridge ](../Tutorials/Demos/Rosbag-with-ROS1-Bridge.html)
      * [ Understanding real-time programming ](../Tutorials/Demos/Real-Time-Programming.html)
      * [ Experimenting with a dummy robot ](../Tutorials/Demos/dummy-robot-demo.html)
      * [ Logging ](../Tutorials/Demos/Logging-and-logger-configuration.html)
    * [ Miscellaneous ](../Tutorials/Miscellaneous.html)
      * [ Packaging your ROS 2 application as a snap [community-contributed] ](../Tutorials/Miscellaneous/Packaging-your-ROS-2-application-as-a-snap.html)
      * [ Deploying on IBM Cloud Kubernetes [community-contributed] ](../Tutorials/Miscellaneous/Deploying-ROS-2-on-IBM-Cloud.html)
      * [ Using Eclipse Oxygen with ` rviz2  ` [community-contributed] ](../Tutorials/Miscellaneous/Eclipse-Oxygen-with-ROS-2-and-rviz2.html)
      * [ Building a real-time Linux kernel [community-contributed] ](../Tutorials/Miscellaneous/Building-Realtime-rt_preempt-kernel-for-ROS-2.html)
      * [ Building a package with Eclipse 2021-06 ](../Tutorials/Miscellaneous/Building-ROS2-Package-with-eclipse-2021-06.html)
  * [ How-to Guides ](../How-To-Guides.html)
    * [ Installation troubleshooting ](../How-To-Guides/Installation-Troubleshooting.html)
    * [ Developing a ROS 2 package ](../How-To-Guides/Developing-a-ROS-2-Package.html)
    * [ ament_cmake user documentation ](../How-To-Guides/Ament-CMake-Documentation.html)
    * [ ament_cmake_python user documentation ](../How-To-Guides/Ament-CMake-Python-Documentation.html)
    * [ Migrating launch files from ROS 1 to ROS 2 ](../How-To-Guides/Launch-files-migration-guide.html)
    * [ Using Python, XML, and YAML for ROS 2 Launch Files ](../How-To-Guides/Launch-file-different-formats.html)
    * [ Using ROS 2 launch to launch composable nodes ](../How-To-Guides/Launching-composable-nodes.html)
    * [ Migrating YAML parameter files from ROS 1 to ROS 2 ](../How-To-Guides/Parameters-YAML-files-migration-guide.html)
    * [ Passing ROS arguments to nodes via the command-line ](../How-To-Guides/Node-arguments.html)
    * [ Synchronous vs. asynchronous service clients ](../How-To-Guides/Sync-Vs-Async.html)
    * [ DDS tuning information ](../How-To-Guides/DDS-tuning.html)
    * [ rosbag2: Overriding QoS Policies ](../How-To-Guides/Overriding-QoS-Policies-For-Recording-And-Playback.html)
    * [ Working with multiple ROS 2 middleware implementations ](../How-To-Guides/Working-with-multiple-RMW-implementations.html)
    * [ Cross-compilation ](../How-To-Guides/Cross-compilation.html)
    * [ Releasing a Package ](../How-To-Guides/Releasing/Releasing-a-Package.html)
      * [ First Time Release ](../How-To-Guides/Releasing/First-Time-Release.html)
      * [ Subsequent Releases ](../How-To-Guides/Releasing/Subsequent-Releases.html)
      * [ Release Team / Repository ](../How-To-Guides/Releasing/Release-Team-Repository.html)
      * [ Release Track ](../How-To-Guides/Releasing/Release-Track.html)
    * [ Using Python Packages with ROS 2 ](../How-To-Guides/Using-Python-Packages.html)
    * [ Porting RQt plugins to Windows ](../How-To-Guides/RQt-Port-Plugin-Windows.html)
    * [ Running ROS 2 nodes in Docker [community-contributed] ](../How-To-Guides/Run-2-nodes-in-single-or-separate-docker-containers.html)
    * [ Visualizing ROS 2 data with Foxglove Studio ](../How-To-Guides/Visualizing-ROS-2-Data-With-Foxglove-Studio.html)
    * [ ROS 2 Package Maintainer Guide ](../How-To-Guides/Package-maintainer-guide.html)
    * [ Building a custom Debian package ](../How-To-Guides/Building-a-Custom-Debian-Package.html)


> Both file names must use an upper camel case name and only consist of
> alphanumeric characters.


  * [ ](../../index.html)
  * [ Tutorials ](../../Tutorials.html)
  * [ Beginner: Client libraries ](../Beginner-Client-Libraries.html)
  * Implementing custom interfaces
  * [ Edit on GitHub ](https://github.com/ros2/ros2_documentation/blob/foxy/source/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.rst)


    message.first_name = "John";
    message.last_name = "Doe";
    message.phone_number = "1234567890";
    message.phone_type = message.PHONE_TYPE_MOBILE;


Linux  macOS  Windows


* 1\. Background


    find_package(rosidl_tutorials_msgs REQUIRED)

    rosidl_generate_interfaces(${PROJECT_NAME}
      ${msg_files}
      DEPENDENCIES rosidl_tutorials_msgs
    )


And in ` CMakeLists.txt  ` :


    * [ Development process for a release ](../Releases/Release-Process.html)
  * [ Tutorials ](../Tutorials.html)
    * [ Beginner: CLI tools ](../Tutorials/Beginner-CLI-Tools.html)
      * [ Configuring environment ](../Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html)
      * [ Using ` turtlesim  ` , ` ros2  ` , and ` rqt  ` ](../Tutorials/Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.html)
      * [ Understanding nodes ](../Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Nodes/Understanding-ROS2-Nodes.html)
      * [ Understanding topics ](../Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Topics/Understanding-ROS2-Topics.html)
      * [ Understanding services ](../Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Services/Understanding-ROS2-Services.html)
      * [ Understanding parameters ](../Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Parameters/Understanding-ROS2-Parameters.html)
      * [ Understanding actions ](../Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.html)
      * [ Using ` rqt_console  ` to view logs ](../Tutorials/Beginner-CLI-Tools/Using-Rqt-Console/Using-Rqt-Console.html)
      * [ Launching nodes ](../Tutorials/Beginner-CLI-Tools/Launching-Multiple-Nodes/Launching-Multiple-Nodes.html)
      * [ Recording and playing back data ](../Tutorials/Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.html)
    * [ Beginner: Client libraries ](../Tutorials/Beginner-Client-Libraries.html)
      * [ Using ` colcon  ` to build packages ](../Tutorials/Beginner-Client-Libraries/Colcon-Tutorial.html)
      * [ Creating a workspace ](../Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.html)
      * [ Creating a package ](../Tutorials/Beginner-Client-Libraries/Creating-Your-First-ROS2-Package.html)
      * [ Writing a simple publisher and subscriber (C++) ](../Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Publisher-And-Subscriber.html)
      * [ Writing a simple publisher and subscriber (Python) ](../Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Publisher-And-Subscriber.html)
      * [ Writing a simple service and client (C++) ](../Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Cpp-Service-And-Client.html)
      * [ Writing a simple service and client (Python) ](../Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Service-And-Client.html)
      * [ Creating custom msg and srv files ](../Tutorials/Beginner-Client-Libraries/Custom-ROS2-Interfaces.html)
      * [ Implementing custom interfaces ](../Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.html)
      * [ Using parameters in a class (C++) ](../Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-CPP.html)
      * [ Using parameters in a class (Python) ](../Tutorials/Beginner-Client-Libraries/Using-Parameters-In-A-Class-Python.html)
      * [ Using ` ros2doctor  ` to identify issues ](../Tutorials/Beginner-Client-Libraries/Getting-Started-With-Ros2doctor.html)
      * [ Creating and using plugins (C++) ](../Tutorials/Beginner-Client-Libraries/Pluginlib.html)
    * [ Intermediate ](../Tutorials/Intermediate.html)
      * [ Managing Dependencies with rosdep ](../Tutorials/Intermediate/Rosdep.html)
      * [ Creating an action ](../Tutorials/Intermediate/Creating-an-Action.html)
      * [ Writing an action server and client (C++) ](../Tutorials/Intermediate/Writing-an-Action-Server-Client/Cpp.html)
      * [ Writing an action server and client (Python) ](../Tutorials/Intermediate/Writing-an-Action-Server-Client/Py.html)
      * [ Composing multiple nodes in a single process ](../Tutorials/Intermediate/Composition.html)
      * [ Launch ](../Tutorials/Intermediate/Launch/Launch-Main.html)
        * [ Creating a launch file ](../Tutorials/Intermediate/Launch/Creating-Launch-Files.html)
        * [ Integrating launch files into ROS 2 packages ](../Tutorials/Intermediate/Launch/Launch-system.html)
        * [ Using substitutions ](../Tutorials/Intermediate/Launch/Using-Substitutions.html)
        * [ Using event handlers ](../Tutorials/Intermediate/Launch/Using-Event-Handlers.html)
        * [ Managing large projects ](../Tutorials/Intermediate/Launch/Using-ROS2-Launch-For-Large-Projects.html)
      * [ ` tf2  ` ](../Tutorials/Intermediate/Tf2/Tf2-Main.html)


fieldtype fieldname fielddefaultvalue


sequence<T, N>

bounded string


Hey i know it’s an old thread but I’m learning ROS now and I’ve been trying to
find info on precisely this.
So what I gather is that the msg and or srv should be named with camel case
and then it will become an .hpp of the form "all lowercases and an underscore
before every upercase in the the original camelcase name + .hpp?


In ` more_interfaces/src  ` create a file called ` publish_address_book.cpp  `
and paste the following code:


      * [ Contributing to ROS 2 Documentation ](../../The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.html)
    * [ Features Status ](../../The-ROS2-Project/Features.html)
    * [ Feature Ideas ](../../The-ROS2-Project/Feature-Ideas.html)
    * [ Roadmap ](../../The-ROS2-Project/Roadmap.html)
    * [ ROSCon Talks ](../../The-ROS2-Project/ROSCon-Content.html)
    * [ Project Governance ](../../The-ROS2-Project/Governance.html)
      * [ ROS 2 Technical Steering Committee Charter ](../../The-ROS2-Project/Governance/ROS2-TSC-Charter.html)
      * [ ROS 2 TSC applicant intake process ](../../The-ROS2-Project/Governance/ROS2-TSC-Intake-process.html)
      * [ How to Start a Community Working Group ](../../The-ROS2-Project/Governance/How-To-Start-A-Community-Working-Group.html)
    * [ Marketing ](../../The-ROS2-Project/Marketing.html)
  * [ Related Projects ](../../Related-Projects.html)
    * [ Intel ROS 2 Projects ](../../Related-Projects/Intel-ROS2-Projects.html)
    * [ NVIDIA ROS 2 Projects ](../../Related-Projects/Nvidia-ROS2-Projects.html)
  * [ Glossary ](../../Glossary.html)
  * [ Citations ](../../Citations.html)


Note that at build time, we need ` rosidl_default_generators  ` , while at
runtime, we only need ` rosidl_default_runtime  ` .


Other Versions  v: foxy


[ togaen  ](https://discourse.ros.org/u/togaen) April 9, 2020, 1:41pm  5


**Time:** 15 minutes


bool


Constants names have to be UPPERCASE


In Development


To generate this message you would need to declare a dependency on `
Contact.msg's  ` package, ` rosidl_tutorials_msgs  ` , in ` package.xml  ` :


* currently string values are not escaped


_Built-in-types currently supported:_


    string str
    ---
    string str


Now we can start writing code that uses this message.


####  Field names  ï


###  Constants  ï


ROS Resources: [ ROS Homepage ](http://ros.org/) | [ Media and Trademarks
](https://www.ros.org/blog/media/) | [ Documentation ](http://docs.ros.org/) |
[ ROS Index ](https://index.ros.org/) | [ How to Get Help
](http://wiki.ros.org/Support) | [ Q&A Help Site
](https://robotics.stackexchange.com/) | [ Discussion Forum
](http://discourse.ros.org/) | [ Service Status ](http://status.ros.org/)
---

[ ROS Discourse ](/)


We assume youâve reviewed the basics in the [ Creating custom msg and srv
files  ](Custom-ROS2-Interfaces.html) tutorial before working through this
one.


Create a node and an ` AddressBook  ` publisher.


|  20  |  2086  |  June 20, 2023
[ Naming Convention for ROS 2 repositories
](https://discourse.ros.org/t/naming-convention-for-ros-2-repositories/9838)


####  3.2 Build the publisher  ï


    int32 order
    ---
    int32[] sequence
    ---
    int32[] sequence


##  2\. Message description specification  ï


octet

uint8


_Example of message definition using arrays and bounded types:_


##  1\. Background  ï


I dont know… i know i know nothing. ![:confused:](https://emoji.discourse-
cdn.com/twitter/confused.png?v=12)


        * [ Using substitutions ](../../Tutorials/Intermediate/Launch/Using-Substitutions.html)
        * [ Using event handlers ](../../Tutorials/Intermediate/Launch/Using-Event-Handlers.html)
        * [ Managing large projects ](../../Tutorials/Intermediate/Launch/Using-ROS2-Launch-For-Large-Projects.html)
      * [ ` tf2  ` ](../../Tutorials/Intermediate/Tf2/Tf2-Main.html)
        * [ Introducing ` tf2  ` ](../../Tutorials/Intermediate/Tf2/Introduction-To-Tf2.html)
        * [ Writing a static broadcaster (Python) ](../../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Static-Broadcaster-Py.html)
        * [ Writing a static broadcaster (C++) ](../../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Static-Broadcaster-Cpp.html)
        * [ Writing a broadcaster (Python) ](../../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.html)
        * [ Writing a broadcaster (C++) ](../../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.html)
        * [ Writing a listener (Python) ](../../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.html)
        * [ Writing a listener (C++) ](../../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.html)
        * [ Adding a frame (Python) ](../../Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.html)
        * [ Adding a frame (C++) ](../../Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.html)
        * [ Using time (Python) ](../../Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Py.html)
        * [ Using time (C++) ](../../Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.html)
        * [ Traveling in time (Python) ](../../Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Py.html)
        * [ Traveling in time (C++) ](../../Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Cpp.html)
        * [ Debugging ](../../Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.html)
        * [ Quaternion fundamentals ](../../Tutorials/Intermediate/Tf2/Quaternion-Fundamentals.html)
        * [ Using stamped datatypes with ` tf2_ros::MessageFilter  ` ](../../Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.html)
      * [ Testing ](../../Tutorials/Intermediate/Testing/Testing-Main.html)
        * [ Running Tests in ROS 2 from the Command Line ](../../Tutorials/Intermediate/Testing/CLI.html)
        * [ Writing Basic Tests with C++ with GTest ](../../Tutorials/Intermediate/Testing/Cpp.html)
        * [ Writing Basic Tests with Python ](../../Tutorials/Intermediate/Testing/Python.html)
      * [ URDF ](../../Tutorials/Intermediate/URDF/URDF-Main.html)
        * [ Building a visual robot model from scratch ](../../Tutorials/Intermediate/URDF/Building-a-Visual-Robot-Model-with-URDF-from-Scratch.html)
        * [ Building a movable robot model ](../../Tutorials/Intermediate/URDF/Building-a-Movable-Robot-Model-with-URDF.html)
        * [ Adding physical and collision properties ](../../Tutorials/Intermediate/URDF/Adding-Physical-and-Collision-Properties-to-a-URDF-Model.html)
        * [ Using Xacro to clean up your code ](../../Tutorials/Intermediate/URDF/Using-Xacro-to-Clean-Up-a-URDF-File.html)
        * [ Using URDF with ` robot_state_publisher  ` ](../../Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher.html)
        * [ Generating an URDF File ](../../Tutorials/Intermediate/URDF/Exporting-an-URDF-File.html)
      * [ RViz ](../../Tutorials/Intermediate/RViz/RViz-Main.html)
        * [ RViz User Guide ](../../Tutorials/Intermediate/RViz/RViz-User-Guide/RViz-User-Guide.html)
        * [ Building a Custom RViz Display ](../../Tutorials/Intermediate/RViz/RViz-Custom-Display/RViz-Custom-Display.html)
    * [ Advanced ](../../Tutorials/Advanced.html)
      * [ Enabling topic statistics (C++) ](../../Tutorials/Advanced/Topic-Statistics-Tutorial/Topic-Statistics-Tutorial.html)
      * [ Using Fast DDS Discovery Server as discovery protocol [community-contributed] ](../../Tutorials/Advanced/Discovery-Server/Discovery-Server.html)
      * [ Implementing a custom memory allocator ](../../Tutorials/Advanced/Allocator-Template-Tutorial.html)
      * [ Unlocking the potential of Fast DDS middleware [community-contributed] ](../../Tutorials/Advanced/FastDDS-Configuration.html)
      * [ Improved Dynamic Discovery ](../../Tutorials/Advanced/Improved-Dynamic-Discovery.html)


octet

char


string

wstring


###  Navigation
  * [ index ](../genindex.html "General Index")
  * [ next ](continue.html "continue") |
  * [ previous ](cmake_policy.html "cmake_policy") |
  * ![](../_static/cmake-logo-16.png)
  * [ CMake ](https://cmake.org/) »
  * 3.29.2  [ Documentation ](../index.html) »
  * [ cmake-commands(7) ](../manual/cmake-commands.7.html) »
  * [ configure_file ]()
#  configure_file  Â¶
Contents
  * configure_file
    * Options
    * Transformations
    * Example
    * See Also
Copy a file to another location and modify its contents.

    configure_file(<input> <output>
                   [NO_SOURCE_PERMISSIONS | USE_SOURCE_PERMISSIONS |
                    FILE_PERMISSIONS <permissions>...]
                   [COPYONLY] [ESCAPE_QUOTES] [@ONLY]
                   [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])

Copies an ` <input> ` file to an ` <output> ` file while performing
transformations  of the input file content.
If the input file is modified the build system will re-run CMake to re-
configure the file and generate the build system again. The generated file is
modified and its timestamp updated on subsequent cmake runs only if its
content is changed.
##  Options  Â¶
The options are:
` <input> `

Path to the input file. A relative path is treated with respect to the value
of  [ ` CMAKE_CURRENT_SOURCE_DIR  `
](../variable/CMAKE_CURRENT_SOURCE_DIR.html#variable:CMAKE_CURRENT_SOURCE_DIR
"CMAKE_CURRENT_SOURCE_DIR") . The input path must be a file, not a directory.
` <output> `


Action definitions have the following form:


[ jsquare  ](https://discourse.ros.org/u/jsquare) September 7, 2017, 9:22am  1


builtins.float*


#  Implementing custom interfaces  ï


In that case you could have defined ` AddressBook.msg  ` (an interface in the
package _with_ your nodes) as type ` Contact  ` (an interface in a _separate_
package). You could even define ` AddressBook.msg  ` as an _array_ of type `
Contact  ` , like so:


* 3\. Service description specification


unsigned short

int32


##  Prerequisites  ï


Services are described and defined in ` .srv  ` files in the ` srv/  `
directory of a ROS package.


##  3\. Service description specification  ï


Populate ` AddressBook  ` fields.


rosidl_tutorials_msgs/Contact[] address_book


This finds the relevant generated C++ code from ` AddressBook.msg  ` and
allows your target to link against it.


[ Next Generation ROS  ](/c/ng-ros/25)


For example:


builtins.int*


Is this also the case for ros2?


Actions are a long-running request/response communication, where the action
client (requester) is waiting for the action server (the responder) to take
some action and return a result. In contrast to services, actions can be long-
running (many seconds or minutes), provide feedback while they are happening,
and can be interrupted.


Built with [ Sphinx ](https://www.sphinx-doc.org/) using a [ theme
](https://github.com/readthedocs/sphinx_rtd_theme) provided by [ Read the Docs
](https://readthedocs.org) .


      * [ Contributing to ROS 2 Documentation ](../../The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.html)
    * [ Features Status ](../../The-ROS2-Project/Features.html)
    * [ Feature Ideas ](../../The-ROS2-Project/Feature-Ideas.html)
    * [ Roadmap ](../../The-ROS2-Project/Roadmap.html)
    * [ ROSCon Talks ](../../The-ROS2-Project/ROSCon-Content.html)
    * [ Project Governance ](../../The-ROS2-Project/Governance.html)
      * [ ROS 2 Technical Steering Committee Charter ](../../The-ROS2-Project/Governance/ROS2-TSC-Charter.html)
      * [ ROS 2 TSC applicant intake process ](../../The-ROS2-Project/Governance/ROS2-TSC-Intake-process.html)
      * [ About Working Groups ](../../The-ROS2-Project/Governance/Working-Groups.html)
      * [ How to Start a Community Working Group ](../../The-ROS2-Project/Governance/How-To-Start-A-Community-Working-Group.html)
    * [ Marketing ](../../The-ROS2-Project/Marketing.html)
    * [ Metrics ](../../The-ROS2-Project/Metrics.html)
  * [ Package Docs ](../../Package-Docs.html)
  * [ Related Projects ](../../Related-Projects.html)
    * [ Intel ROS 2 Projects ](../../Related-Projects/Intel-ROS2-Projects.html)
    * [ NVIDIA ROS 2 Projects ](../../Related-Projects/Nvidia-ROS2-Projects.html)
  * [ Glossary ](../../Glossary.html)
  * [ Citations ](../../Citations.html)


string

wstring


###  1 Create a package  ï


[ Python ](https://design.ros2.org/articles/generated_interfaces_python.html)


* Messages


A service description file consists of a request and a response msg type,
separated by ` ---  ` . Any two ` .msg  ` files concatenated with a ` ---  `
are a legal service description.


In this tutorial, you tried out different field types for defining interfaces,
then built an interface in the same package where itâs being used.


> the msg and or srv should be named with camel case


builtins.float*


Return to the root of the workspace to build the package:


The ROS 2 IDL is closely related to the [ ROS 1 IDL
](https://wiki.ros.org/msg) . Most existing ROS 1 ` .msg  ` and ` .srv  `
files should be usable as-is with ROS 2. Atop ROS 1âs existing feature set,
the ROS 2 IDL introduces some new features, namely:


© Copyright 2024, Open Robotics.


**Goal:** Learn more ways to implement custom interfaces in ROS 2.


double


[ gbiggs  ](https://discourse.ros.org/u/gbiggs) May 30, 2022, 11:17pm  7


     [ Iron (latest) ](../../../iron/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.html)
     [ Humble ](../../../humble/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.html)
     [ Galactic (EOL) ](../../../galactic/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-Use-Interface.html)
     [ Foxy (EOL) ](Single-Package-Define-And-Use-Interface.html)
     [ Eloquent (EOL) ](../../../eloquent/index.html)
     [ Dashing (EOL) ](../../../dashing/index.html)
     [ Crystal (EOL) ](../../../crystal/index.html)


builtins.int*


wstring

_Every built-in-type can be used to define arrays:_


##  Next steps  ï


#include "more_interfaces/msg/address_book.hpp"


builtins.list*


__ [ ROS 2 Documentation: Foxy ](../index.html)


Or using Powershell:


    #request constants
    int8 FOO=1
    int8 BAR=2
    #request fields
    int8 foobar
    another_pkg/AnotherMessage msg
    ---
    #response constants
    uint32 SECRET=123456
    #response fields
    another_pkg/YetAnotherMessage val
    CustomMessageDefinedInThisPackage value
    uint32 an_integer


unsigned short

int32


[ Next Generation ROS  ](/c/ng-ros/25)


###  2.2 Constants  ï


builtins.list


We wonât create a subscriber in this tutorial, but you can try to write one
yourself for practice (use [ Writing a simple publisher and subscriber (C++)
](Writing-A-Simple-Cpp-Publisher-And-Subscriber.html) to help).


constanttype CONSTANTNAME=constantvalue


std::vector


    int main(int argc, char * argv[])
    {
      rclcpp::init(argc, argv);
      rclcpp::spin(std::make_shared<AddressBookPublisher>());
      rclcpp::shutdown();

      return 0;
    }


[ BBelmar  ](https://discourse.ros.org/u/BBelmar) May 31, 2022, 2:18pm  10


####  2.1.3 Field default value  ï


Linux  macOS  Windows


builtins.int*


In this document we will describe the supported types:


![](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/48.png) BBelmar:


Create a callback to publish the messages periodically.


##  Tasks  ï


    set(msg_files
      "msg/Message1.msg"
      "msg/Message2.msg"
      # etc
      )

    set(srv_files
      "srv/Service1.srv"
      "srv/Service2.srv"
       # etc
      )


Here is a very simple example of a service that takes in a string and returns
a string:


Releases


    uint8 x 42
    int16 y -2000
    string full_name "John Doe"
    int32[] samples [-200, -100, 0, 100, 200]


There can be arbitrary numbers of request fields (including zero), arbitrary
numbers of response fields (including zero), and arbitrary numbers of feedback
fields (including zero).


###  2 Create a msg file  ï


float

float64


find_package(rosidl_default_generators REQUIRED)


builtins.list*


**You're reading the documentation for a version of ROS 2 that has reached its
EOL (end-of-life), and is no longer officially supported. If you want up-to-
date information, please have a look at[ Iron
](../../../iron/Tutorials/Beginner-Client-Libraries/Single-Package-Define-And-
Use-Interface.html) . **


    ros2 pkg create --build-type ament_cmake more_interfaces
    mkdir more_interfaces/msg


  * [ next ](continue.html "continue") |
  * [ previous ](cmake_policy.html "cmake_policy") |
  * ![](../_static/cmake-logo-16.png)
  * [ CMake ](https://cmake.org/) »
  * 3.29.2  [ Documentation ](../index.html) »
  * [ cmake-commands(7) ](../manual/cmake-commands.7.html) »
  * [ configure_file ]()
© Copyright 2000-2024 Kitware, Inc. and Contributors. Created using [ Sphinx
](https://www.sphinx-doc.org/) 6.2.1.


You can use an existing interface definition in a new interface definition.
For example, letâs say there is a message named ` Contact.msg  ` that
belongs to an existing ROS 2 package named ` rosidl_tutorials_msgs  ` . Assume
that its definition is identical to our custom-made ` AddressBook.msg  `
interface from earlier.


####  2.1.2 Field names  ï


custom_class<T, N>


####  2.1.1 Field types  ï


* last_name: of type string


##  Summary  ï


###  3 Use an interface from the same package  ï


builtins.float*


In ros1 wiki it is mentioned to put the name in camelcase and therefore no
underscore seems to be allowed: [ http://wiki.ros.org/ROS/Patterns/Conventions
](http://wiki.ros.org/ROS/Patterns/Conventions) under 2.3 Messages


    uint8 PHONE_TYPE_HOME=0
    uint8 PHONE_TYPE_WORK=1
    uint8 PHONE_TYPE_MOBILE=2

    string first_name
    string last_name
    string phone_number
    uint8 phone_type


* string values must be defined in single ` '  ` or double ` "  ` quotes


builtins.int*


[ Rolling ](../../rolling/index.html)


    * [ Building ROS 2 with tracing instrumentation ](../../How-To-Guides/Building-ROS-2-with-Tracing-Instrumentation.html)
    * [ Topics vs Services vs Actions ](../../How-To-Guides/Topics-Services-Actions.html)
    * [ Using variants ](../../How-To-Guides/Using-Variants.html)
    * [ Using the ` ros2  param  ` command-line tool ](../../How-To-Guides/Using-ros2-param.html)
    * [ ROS 2 on Raspberry Pi ](../../How-To-Guides/Installing-on-Raspberry-Pi.html)
    * [ Using Callback Groups ](../../How-To-Guides/Using-callback-groups.html)
    * [ Setup ROS 2 with VSCode and Docker [community-contributed] ](../../How-To-Guides/Setup-ROS-2-with-VSCode-and-Docker-Container.html)
    * [ Building RQt from source ](../../How-To-Guides/RQt-Source-Install.html)
      * [ Building RQt from source on macOS ](../../How-To-Guides/RQt-Source-Install-MacOS.html)
      * [ Building RQt from source on Windows 10 ](../../How-To-Guides/RQt-Source-Install-Windows10.html)
  * [ Concepts ](../../Concepts.html)
    * [ The ROS_DOMAIN_ID ](../../Concepts/About-Domain-ID.html)
    * [ About different ROS 2 DDS/RTPS vendors ](../../Concepts/About-Different-Middleware-Vendors.html)
    * [ About logging and logger configuration ](../../Concepts/About-Logging.html)
    * [ About Quality of Service settings ](../../Concepts/About-Quality-of-Service-Settings.html)
    * [ About ROS 2 client libraries ](../../Concepts/About-ROS-2-Client-Libraries.html)
    * [ About ROS 2 interfaces ](../../Concepts/About-ROS-Interfaces.html)
    * [ About parameters in ROS 2 ](../../Concepts/About-ROS-2-Parameters.html)
    * [ Executors ](../../Concepts/About-Executors.html)
    * [ About topic statistics ](../../Concepts/About-Topic-Statistics.html)
    * [ Introspection with command line tools ](../../Concepts/About-Command-Line-Tools.html)
    * [ Overview and usage of RQt ](../../Concepts/About-RQt.html)
    * [ About Composition ](../../Concepts/About-Composition.html)
    * [ On the mixing of ament and catkin (catment) ](../../Concepts/About-Catment.html)
    * [ About Cross-compilation ](../../Concepts/About-Cross-Compilation.html)
    * [ About tf2 ](../../Concepts/About-Tf2.html)
    * [ About the build system ](../../Concepts/About-Build-System.html)
    * [ About internal ROS 2 interfaces ](../../Concepts/About-Internal-Interfaces.html)
    * [ About ROS 2 middleware implementations ](../../Concepts/About-Middleware-Implementations.html)
    * [ About ROS 2 client libraries ](../../Concepts/About-ROS-2-Client-Libraries.html)
  * [ Contact ](../../Contact.html)
  * [ The ROS 2 Project ](../../The-ROS2-Project.html)
    * [ Contributing ](../../The-ROS2-Project/Contributing.html)
      * [ ROS 2 developer guide ](../../The-ROS2-Project/Contributing/Developer-Guide.html)
      * [ Code style and language versions ](../../The-ROS2-Project/Contributing/Code-Style-Language-Versions.html)
      * [ Quality guide: ensuring code quality ](../../The-ROS2-Project/Contributing/Quality-Guide.html)
      * [ Migration guide from ROS 1 ](../../The-ROS2-Project/Contributing/Migration-Guide.html)
        * [ Python migration guide from ROS 1 ](../../The-ROS2-Project/Contributing/Migration-Guide-Python.html)
      * [ ROS Build Farms ](../../The-ROS2-Project/Contributing/Build-Farms.html)
      * [ Windows Tips and Tricks ](../../The-ROS2-Project/Contributing/Windows-Tips-and-Tricks.html)


[ BBelmar  ](https://discourse.ros.org/u/BBelmar) May 30, 2022, 4:06pm  6


* names of Message descriptions defined on their own, such as âgeometry_msgs/PoseStampedâ


* 1 Create a package


> and also… why does it seem to be an obvious thing? i dont see it mentioned
> or explained anywhere. Granted im a noob to it all but is like everyone
> understands it and is obvious. But I dont see it explained. Is it a C++
> thing or a ROS thing?


char

float32


Field names must be lowercase alphanumeric characters with underscores for
separating words. They must start with an alphabetic character, and they must
not end with an underscore or have two consecutive underscores.


#  About ROS 2 interfaces  ï


[ DDS type ](https://design.ros2.org/articles/mapping_dds_types.html)

---|---|---|---

bool


##  4\. New features in ROS 2 interfaces  ï


Generate the messages:


For example:


You should see the publisher relaying the msg you defined, including the
values you set in ` publish_address_book.cpp  ` .


float


The ` <request_type> ` , ` <response_type> ` , and ` <feedback_type> ` follow
all of the same rules as the ` <type> ` for a message. The `
<request_fieldname> ` , ` <response_fieldname> ` , and ` <feedback_fieldname>
` follow all of the same rules as the ` <fieldname> ` for a message.


Next, we need to make sure that the msg file is turned into source code for
C++, Python, and other languages.


builtins.bool


Open ` CMakeLists.txt  ` and add the following lines:


ROS applications typically communicate through interfaces of one of three
types: messages, services and actions. ROS 2 uses a simplified description
language, the interface definition language (IDL), to describe these
interfaces. This description makes it easy for ROS tools to automatically
generate source code for the interface type in several target languages.


Thanks for any clarification


      * [ Contributing to ROS 2 Documentation ](../The-ROS2-Project/Contributing/Contributing-To-ROS-2-Documentation.html)
    * [ Features Status ](../The-ROS2-Project/Features.html)
    * [ Feature Ideas ](../The-ROS2-Project/Feature-Ideas.html)
    * [ Roadmap ](../The-ROS2-Project/Roadmap.html)
    * [ ROSCon Talks ](../The-ROS2-Project/ROSCon-Content.html)
    * [ Project Governance ](../The-ROS2-Project/Governance.html)
      * [ ROS 2 Technical Steering Committee Charter ](../The-ROS2-Project/Governance/ROS2-TSC-Charter.html)
      * [ ROS 2 TSC applicant intake process ](../The-ROS2-Project/Governance/ROS2-TSC-Intake-process.html)
      * [ How to Start a Community Working Group ](../The-ROS2-Project/Governance/How-To-Start-A-Community-Working-Group.html)
    * [ Marketing ](../The-ROS2-Project/Marketing.html)
  * [ Related Projects ](../Related-Projects.html)
    * [ Intel ROS 2 Projects ](../Related-Projects/Intel-ROS2-Projects.html)
    * [ NVIDIA ROS 2 Projects ](../Related-Projects/Nvidia-ROS2-Projects.html)
  * [ Glossary ](../Glossary.html)
  * [ Citations ](../Citations.html)


    * [ Development process for a release ](../../Releases/Release-Process.html)
  * [ Tutorials ](../../Tutorials.html)
    * [ Beginner: CLI tools ](../Beginner-CLI-Tools.html)
      * [ Configuring environment ](../Beginner-CLI-Tools/Configuring-ROS2-Environment.html)
      * [ Using ` turtlesim  ` , ` ros2  ` , and ` rqt  ` ](../Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim.html)
      * [ Understanding nodes ](../Beginner-CLI-Tools/Understanding-ROS2-Nodes/Understanding-ROS2-Nodes.html)
      * [ Understanding topics ](../Beginner-CLI-Tools/Understanding-ROS2-Topics/Understanding-ROS2-Topics.html)
      * [ Understanding services ](../Beginner-CLI-Tools/Understanding-ROS2-Services/Understanding-ROS2-Services.html)
      * [ Understanding parameters ](../Beginner-CLI-Tools/Understanding-ROS2-Parameters/Understanding-ROS2-Parameters.html)
      * [ Understanding actions ](../Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.html)
      * [ Using ` rqt_console  ` to view logs ](../Beginner-CLI-Tools/Using-Rqt-Console/Using-Rqt-Console.html)
      * [ Launching nodes ](../Beginner-CLI-Tools/Launching-Multiple-Nodes/Launching-Multiple-Nodes.html)
      * [ Recording and playing back data ](../Beginner-CLI-Tools/Recording-And-Playing-Back-Data/Recording-And-Playing-Back-Data.html)
    * [ Beginner: Client libraries ](../Beginner-Client-Libraries.html)
      * [ Using ` colcon  ` to build packages ](Colcon-Tutorial.html)
      * [ Creating a workspace ](Creating-A-Workspace/Creating-A-Workspace.html)
      * [ Creating a package ](Creating-Your-First-ROS2-Package.html)
      * [ Writing a simple publisher and subscriber (C++) ](Writing-A-Simple-Cpp-Publisher-And-Subscriber.html)
      * [ Writing a simple publisher and subscriber (Python) ](Writing-A-Simple-Py-Publisher-And-Subscriber.html)
      * [ Writing a simple service and client (C++) ](Writing-A-Simple-Cpp-Service-And-Client.html)
      * [ Writing a simple service and client (Python) ](Writing-A-Simple-Py-Service-And-Client.html)
      * [ Creating custom msg and srv files ](Custom-ROS2-Interfaces.html)
      * Implementing custom interfaces
      * [ Using parameters in a class (C++) ](Using-Parameters-In-A-Class-CPP.html)
      * [ Using parameters in a class (Python) ](Using-Parameters-In-A-Class-Python.html)
      * [ Using ` ros2doctor  ` to identify issues ](Getting-Started-With-Ros2doctor.html)
      * [ Creating and using plugins (C++) ](Pluginlib.html)
    * [ Intermediate ](../Intermediate.html)
      * [ Managing Dependencies with rosdep ](../Intermediate/Rosdep.html)
      * [ Creating an action ](../Intermediate/Creating-an-Action.html)
      * [ Writing an action server and client (C++) ](../Intermediate/Writing-an-Action-Server-Client/Cpp.html)
      * [ Writing an action server and client (Python) ](../Intermediate/Writing-an-Action-Server-Client/Py.html)
      * [ Composing multiple nodes in a single process ](../Intermediate/Composition.html)
      * [ Launch ](../Intermediate/Launch/Launch-Main.html)
        * [ Creating a launch file ](../Intermediate/Launch/Creating-Launch-Files.html)
        * [ Integrating launch files into ROS 2 packages ](../Intermediate/Launch/Launch-system.html)
        * [ Using substitutions ](../Intermediate/Launch/Using-Substitutions.html)
        * [ Using event handlers ](../Intermediate/Launch/Using-Event-Handlers.html)
        * [ Managing large projects ](../Intermediate/Launch/Using-ROS2-Launch-For-Large-Projects.html)
      * [ ` tf2  ` ](../Intermediate/Tf2/Tf2-Main.html)


![](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/48.png) BBelmar:


Next you will create a simple ROS 2 package with a custom parameter that you
will learn to set from a launch file. Again, you can choose to write it in
either [ C++  ](Using-Parameters-In-A-Class-CPP.html) or [ Python  ](Using-
Parameters-In-A-Class-Python.html) .


####  3.3 Link against the interface  ï


unsigned long long

string


wstring

_Every built-in-type can be used to define arrays:_


|  1  |  725  |  October 4, 2022
[ Structured metadata for message files
](https://discourse.ros.org/t/structured-metadata-for-message-files/20965)


builtins.int*


In this document we will describe the supported types:


####  Field types  ï


        * [ Introducing ` tf2  ` ](../Tutorials/Intermediate/Tf2/Introduction-To-Tf2.html)
        * [ Writing a static broadcaster (Python) ](../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Static-Broadcaster-Py.html)
        * [ Writing a static broadcaster (C++) ](../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Static-Broadcaster-Cpp.html)
        * [ Writing a broadcaster (Python) ](../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.html)
        * [ Writing a broadcaster (C++) ](../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.html)
        * [ Writing a listener (Python) ](../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.html)
        * [ Writing a listener (C++) ](../Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.html)
        * [ Adding a frame (Python) ](../Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.html)
        * [ Adding a frame (C++) ](../Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.html)
        * [ Using time (Python) ](../Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Py.html)
        * [ Using time (C++) ](../Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.html)
        * [ Traveling in time (Python) ](../Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Py.html)
        * [ Traveling in time (C++) ](../Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Cpp.html)
        * [ Debugging ](../Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.html)
        * [ Quaternion fundamentals ](../Tutorials/Intermediate/Tf2/Quaternion-Fundamentals.html)
        * [ Using stamped datatypes with ` tf2_ros::MessageFilter  ` ](../Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.html)
      * [ Testing ](../Tutorials/Intermediate/Testing/Testing-Main.html)
        * [ Running Tests in ROS 2 from the Command Line ](../Tutorials/Intermediate/Testing/CLI.html)
        * [ Writing Basic Tests with C++ with GTest ](../Tutorials/Intermediate/Testing/Cpp.html)
        * [ Writing Basic Tests with Python ](../Tutorials/Intermediate/Testing/Python.html)
      * [ URDF ](../Tutorials/Intermediate/URDF/URDF-Main.html)
        * [ Building a visual robot model from scratch ](../Tutorials/Intermediate/URDF/Building-a-Visual-Robot-Model-with-URDF-from-Scratch.html)
        * [ Building a movable robot model ](../Tutorials/Intermediate/URDF/Building-a-Movable-Robot-Model-with-URDF.html)
        * [ Adding physical and collision properties ](../Tutorials/Intermediate/URDF/Adding-Physical-and-Collision-Properties-to-a-URDF-Model.html)
        * [ Using Xacro to clean up your code ](../Tutorials/Intermediate/URDF/Using-Xacro-to-Clean-Up-a-URDF-File.html)
        * [ Using URDF with ` robot_state_publisher  ` ](../Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher.html)
    * [ Advanced ](../Tutorials/Advanced.html)
      * [ Enabling topic statistics (C++) ](../Tutorials/Advanced/Topic-Statistics-Tutorial/Topic-Statistics-Tutorial.html)
      * [ Using Fast DDS Discovery Server as discovery protocol [community-contributed] ](../Tutorials/Advanced/Discovery-Server/Discovery-Server.html)
      * [ Implementing a custom memory allocator ](../Tutorials/Advanced/Allocator-Template-Tutorial.html)
      * [ Recording a bag from a node (C++) ](../Tutorials/Advanced/Recording-A-Bag-From-Your-Own-Node-CPP.html)
      * [ Simulators ](../Tutorials/Advanced/Simulators/Simulation-Main.html)
        * [ Webots ](../Tutorials/Advanced/Simulators/Webots/Simulation-Webots.html)
          * [ Installation (Ubuntu) ](../Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu.html)
          * [ Installation (Windows) ](../Tutorials/Advanced/Simulators/Webots/Installation-Windows.html)
          * [ Installation (macOS) ](../Tutorials/Advanced/Simulators/Webots/Installation-MacOS.html)
          * [ Setting up a robot simulation (Basic) ](../Tutorials/Advanced/Simulators/Webots/Setting-Up-Simulation-Webots-Basic.html)
          * [ Setting up a robot simulation (Advanced) ](../Tutorials/Advanced/Simulators/Webots/Setting-Up-Simulation-Webots-Advanced.html)
        * [ Ignition ](../Tutorials/Advanced/Simulators/Ignition/Simulation-Ignition.html)
          * [ Setting up a robot simulation (Ignition Gazebo) ](../Tutorials/Advanced/Simulators/Ignition/Ignition.html)


Create a 1 second timer to call our ` publish_msg  ` function every second.


     [ Iron (latest) ](../../../iron/Concepts/Basic/About-Interfaces.html)
     [ Humble ](../../../humble/Concepts/Basic/About-Interfaces.html)
     [ Galactic (EOL) ](../../../galactic/index.html)
     [ Foxy (EOL) ](../../../foxy/index.html)
     [ Eloquent (EOL) ](../../../eloquent/index.html)
     [ Dashing (EOL) ](../../../dashing/index.html)
     [ Crystal (EOL) ](../../../crystal/index.html)


    <buildtool_depend>rosidl_default_generators</buildtool_depend>

    <exec_depend>rosidl_default_runtime</exec_depend>

    <member_of_group>rosidl_interface_packages</member_of_group>


* Actions


  * [ ](../index.html)
  * [ Concepts ](../Concepts.html)
  * About ROS 2 interfaces
  * [ Edit on GitHub ](https://github.com/ros2/ros2_documentation/blob/foxy/source/Concepts/About-ROS-Interfaces.rst)


Field names must be lowercase alphanumeric characters with underscores for
separating words. They must start with an alphabetic character, and they must
not end with an underscore or have two consecutive underscores.


  * [ Installation ](../../Installation.html)
    * [ Ubuntu (Debian) ](../../Installation/Ubuntu-Install-Debians.html)
    * [ Windows (binary) ](../../Installation/Windows-Install-Binary.html)
    * [ Alternatives ](../../Installation/Alternatives.html)
      * [ Ubuntu (source) ](../../Installation/Alternatives/Ubuntu-Development-Setup.html)
      * [ Ubuntu (binary) ](../../Installation/Alternatives/Ubuntu-Install-Binary.html)
      * [ Windows (source) ](../../Installation/Alternatives/Windows-Development-Setup.html)
      * [ macOS (source) ](../../Installation/Alternatives/macOS-Development-Setup.html)
      * [ macOS (binary) ](../../Installation/Alternatives/macOS-Install-Binary.html)
      * [ Fedora (source) ](../../Installation/Alternatives/Fedora-Development-Setup.html)
      * [ Latest development (source) ](../../Installation/Alternatives/Latest-Development-Setup.html)
    * [ Maintain source checkout ](../../Installation/Maintaining-a-Source-Checkout.html)
    * [ Testing with pre-release binaries ](../../Installation/Testing.html)
    * [ DDS implementations ](../../Installation/DDS-Implementations.html)
      * [ Connext security plugins ](../../Installation/DDS-Implementations/Install-Connext-Security-Plugins.html)
      * [ RTI Connext DDS ](../../Installation/DDS-Implementations/Install-Connext-University-Eval.html)
      * [ Eclipse Cyclone DDS ](../../Installation/DDS-Implementations/Working-with-Eclipse-CycloneDDS.html)
      * [ GurumNetworks GurumDDS ](../../Installation/DDS-Implementations/Working-with-GurumNetworks-GurumDDS.html)
      * [ eProsima Fast DDS ](../../Installation/DDS-Implementations/Working-with-eProsima-Fast-DDS.html)
  * [ Distributions ](../../Releases.html)
    * [ Iron Irwini ( ` iron  ` ) ](../../Releases/Release-Iron-Irwini.html)
      * [ Iron Irwini Changelog ](../../Releases/Iron-Irwini-Complete-Changelog.html)
    * [ Humble Hawksbill ( ` humble  ` ) ](../../Releases/Release-Humble-Hawksbill.html)
      * [ Humble Hawksbill changelog ](../../Releases/Humble-Hawksbill-Complete-Changelog.html)
    * [ Rolling Ridley ( ` rolling  ` ) ](../../Releases/Release-Rolling-Ridley.html)
    * [ Development Distribution ](../../Releases/Development.html)
      * [ Jazzy Jalisco (codename âjazzyâ; May, 2024) ](../../Releases/Release-Jazzy-Jalisco.html)
    * [ End-of-Life Distributions ](../../Releases/End-of-Life.html)
      * [ Galactic Geochelone ( ` galactic  ` ) ](../../Releases/Release-Galactic-Geochelone.html)
        * [ Galactic Geochelone changelog ](../../Releases/Galactic-Geochelone-Complete-Changelog.html)
      * [ Foxy Fitzroy ( ` foxy  ` ) ](../../Releases/Release-Foxy-Fitzroy.html)
      * [ Eloquent Elusor ( ` eloquent  ` ) ](../../Releases/Release-Eloquent-Elusor.html)
      * [ Dashing Diademata ( ` dashing  ` ) ](../../Releases/Release-Dashing-Diademata.html)
      * [ Crystal Clemmys ( ` crystal  ` ) ](../../Releases/Release-Crystal-Clemmys.html)
      * [ Bouncy Bolson ( ` bouncy  ` ) ](../../Releases/Release-Bouncy-Bolson.html)
      * [ Ardent Apalone ( ` ardent  ` ) ](../../Releases/Release-Ardent-Apalone.html)
      * [ Beta 3 ( ` r2b3  ` ) ](../../Releases/Beta3-Overview.html)
      * [ Beta 2 ( ` r2b2  ` ) ](../../Releases/Beta2-Overview.html)
      * [ Beta 1 ( ` Asphalt  ` ) ](../../Releases/Beta1-Overview.html)
      * [ Alphas ](../../Releases/Alpha-Overview.html)


Table of Contents


char


Note that itâs possible to set default values for fields within a message
definition. See [ About ROS 2 interfaces  ](../../Concepts/About-ROS-
Interfaces.html) for more ways you can customize interfaces.


[ Rolling ](About-Interfaces.html)


Type name


Hi,


Built with [ Sphinx ](https://www.sphinx-doc.org/) using a [ theme
](https://github.com/readthedocs/sphinx_rtd_theme) provided by [ Read the Docs
](https://readthedocs.org) .


    find_package(rclcpp REQUIRED)

    add_executable(publish_address_book src/publish_address_book.cpp)
    ament_target_dependencies(publish_address_book rclcpp)

    install(TARGETS
        publish_address_book
      DESTINATION lib/${PROJECT_NAME})


auto message = more_interfaces::msg::AddressBook();


####  2.2 (Extra) Set multiple interfaces  ï


[ Python ](https://design.ros2.org/articles/generated_interfaces_python.html)


##  Related content  ï


boolean

byte


![](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/48.png) BBelmar:


For example:


Or using Powershell:


###  Related Topics


long

uint32


* phone_number: of type string


I believe it will be the latter: ` sensor3_d_state.hpp ` (though I’m not 100%
sure of that). Easy enough to test.


or

    #define VAR 1

Input lines of the form ` #cmakedefine01  VAR  ...  ` will expand as `
#cmakedefine01  VAR  ...  0  ` or ` #cmakedefine01  VAR  ...  1  ` , which may
lead to undefined behavior.
New in version 3.10:  The result lines (with the exception of the ` #undef  `
comments) can be indented using spaces and/or tabs between the ` #  `
character and the ` cmakedefine  ` or ` cmakedefine01  ` words. This
whitespace indentation will be preserved in the output lines:

    #  cmakedefine VAR
    #  cmakedefine01 VAR

will be replaced, if ` VAR  ` is defined, with

    #  define VAR
    #  define VAR 1

##  Example  Â¶
Consider a source tree containing a ` foo.h.in  ` file:

    #cmakedefine FOO_ENABLE
    #cmakedefine FOO_STRING "@FOO_STRING@"

An adjacent ` CMakeLists.txt  ` may use ` configure_file  ` to configure the
header:

    option(FOO_ENABLE "Enable Foo" ON)
    if(FOO_ENABLE)
      set(FOO_STRING "foo")
    endif()
    configure_file(foo.h.in foo.h @ONLY)


[ ROS 2 Documentation: Foxy ![Logo](../../_static/foxy-small.png)
](../../index.html)


© Copyright 2024, Open Robotics.


std::string


It’s a ROS thing. And you are right, I don’t see it anywhere explicitly
mentioned in the documentation. I guess an obvious place to put it would be in
[ Interface definition using .msg / .srv / .action files
](http://design.ros2.org/articles/legacy_interface_definition.html) , though I
can see a case for putting it in the documentation on [ ROS 2 Documentation —
ROS 2 Documentation: Rolling documentation ](https://docs.ros.org/en/rolling)
(which is generated from [ GitHub - ros2/ros2_documentation: ROS 2 docs
repository ](https://github.com/ros2/ros2_documentation) ). If you’d be
willing to open a PR explaining it, I’d be happy to review.


You may have noticed that this step was not necessary when the interfaces
being used were from a different package that was built independently. This
CMake code is only required when you want to use interfaces in the same
package as the one in which they are defined.


    * [ Demos ](../Demos.html)
      * [ Using quality-of-service settings for lossy networks ](../Demos/Quality-of-Service.html)
      * [ Managing nodes with managed lifecycles ](../Demos/Managed-Nodes.html)
      * [ Setting up efficient intra-process communication ](../Demos/Intra-Process-Communication.html)
      * [ Recording and playing back data with ` rosbag  ` using the ROS 1 bridge ](../Demos/Rosbag-with-ROS1-Bridge.html)
      * [ Understanding real-time programming ](../Demos/Real-Time-Programming.html)
      * [ Experimenting with a dummy robot ](../Demos/dummy-robot-demo.html)
      * [ Logging ](../Demos/Logging-and-logger-configuration.html)
    * [ Miscellaneous ](../Miscellaneous.html)
      * [ Packaging your ROS 2 application as a snap [community-contributed] ](../Miscellaneous/Packaging-your-ROS-2-application-as-a-snap.html)
      * [ Deploying on IBM Cloud Kubernetes [community-contributed] ](../Miscellaneous/Deploying-ROS-2-on-IBM-Cloud.html)
      * [ Using Eclipse Oxygen with ` rviz2  ` [community-contributed] ](../Miscellaneous/Eclipse-Oxygen-with-ROS-2-and-rviz2.html)
      * [ Building a real-time Linux kernel [community-contributed] ](../Miscellaneous/Building-Realtime-rt_preempt-kernel-for-ROS-2.html)
      * [ Building a package with Eclipse 2021-06 ](../Miscellaneous/Building-ROS2-Package-with-eclipse-2021-06.html)
  * [ How-to Guides ](../../How-To-Guides.html)
    * [ Installation troubleshooting ](../../How-To-Guides/Installation-Troubleshooting.html)
    * [ Developing a ROS 2 package ](../../How-To-Guides/Developing-a-ROS-2-Package.html)
    * [ ament_cmake user documentation ](../../How-To-Guides/Ament-CMake-Documentation.html)
    * [ ament_cmake_python user documentation ](../../How-To-Guides/Ament-CMake-Python-Documentation.html)
    * [ Migrating launch files from ROS 1 to ROS 2 ](../../How-To-Guides/Launch-files-migration-guide.html)
    * [ Using Python, XML, and YAML for ROS 2 Launch Files ](../../How-To-Guides/Launch-file-different-formats.html)
    * [ Using ROS 2 launch to launch composable nodes ](../../How-To-Guides/Launching-composable-nodes.html)
    * [ Migrating YAML parameter files from ROS 1 to ROS 2 ](../../How-To-Guides/Parameters-YAML-files-migration-guide.html)
    * [ Passing ROS arguments to nodes via the command-line ](../../How-To-Guides/Node-arguments.html)
    * [ Synchronous vs. asynchronous service clients ](../../How-To-Guides/Sync-Vs-Async.html)
    * [ DDS tuning information ](../../How-To-Guides/DDS-tuning.html)
    * [ rosbag2: Overriding QoS Policies ](../../How-To-Guides/Overriding-QoS-Policies-For-Recording-And-Playback.html)
    * [ Working with multiple ROS 2 middleware implementations ](../../How-To-Guides/Working-with-multiple-RMW-implementations.html)
    * [ Cross-compilation ](../../How-To-Guides/Cross-compilation.html)
    * [ Releasing a Package ](../../How-To-Guides/Releasing/Releasing-a-Package.html)
      * [ First Time Release ](../../How-To-Guides/Releasing/First-Time-Release.html)
      * [ Subsequent Releases ](../../How-To-Guides/Releasing/Subsequent-Releases.html)
      * [ Release Team / Repository ](../../How-To-Guides/Releasing/Release-Team-Repository.html)
      * [ Release Track ](../../How-To-Guides/Releasing/Release-Track.html)
    * [ Using Python Packages with ROS 2 ](../../How-To-Guides/Using-Python-Packages.html)
    * [ Porting RQt plugins to Windows ](../../How-To-Guides/RQt-Port-Plugin-Windows.html)
    * [ Running ROS 2 nodes in Docker [community-contributed] ](../../How-To-Guides/Run-2-nodes-in-single-or-separate-docker-containers.html)
    * [ Visualizing ROS 2 data with Foxglove Studio ](../../How-To-Guides/Visualizing-ROS-2-Data-With-Foxglove-Studio.html)
    * [ ROS 2 Package Maintainer Guide ](../../How-To-Guides/Package-maintainer-guide.html)
    * [ Building a custom Debian package ](../../How-To-Guides/Building-a-Custom-Debian-Package.html)


####  3.1 The code explained  ï


* names of Message descriptions defined on their own, such as âgeometry_msgs/PoseStampedâ


builtins.str


Table of Contents


char

float32


std::vector


* Related content


In Development


    cd ~/ros2_ws
    colcon build --packages-up-to more_interfaces

    cd ~/ros2_ws
    colcon build --packages-up-to more_interfaces

    cd /ros2_ws
    colcon build --merge-install --packages-up-to more_interfaces


Note


[ gavanderhoorn  ](https://discourse.ros.org/u/gavanderhoorn) May 31, 2022,
7:33am  8


string

All types that are more permissive than their ROS definition enforce the ROS
constraints in range and length by software.


builtins.list*


\r\n  ` newlines. This option may not be used with ` COPYONLY  ` .
##  Transformations  Â¶
[ Variables  ](../manual/cmake-language.7.html#cmake-language-variables)
referenced in the input file content as ` @VAR@  ` , ` ${VAR}  ` , `
$CACHE{VAR}  ` , and [ environment variables  ](../manual/cmake-
language.7.html#cmake-language-environment-variables) referenced as `
$ENV{VAR}  ` , will each be replaced with the current value of the variable,
or the empty string if the variable is not defined. Furthermore, input lines
of the form

    #cmakedefine VAR ...

will be replaced with either

    #define VAR ...

or

    /* #undef VAR */

depending on whether ` VAR  ` is set in CMake to any value not considered a
false constant by the  [ ` if()  ` ](if.html#command:if "if") command. The
"..." content on the line after the variable name, if any, is processed as
above.
Unlike lines of the form ` #cmakedefine  VAR  ...  ` , in lines of the form `
#cmakedefine01  VAR  ` , ` VAR  ` itself will expand to ` VAR  0  ` or ` VAR
1  ` rather than being assigned the value ` ...  ` . Therefore, input lines of
the form

    #cmakedefine01 VAR

will be replaced with either

    #define VAR 0


octet

int16


1 Like


We can of course get much more complicated (if you want to refer to a message
from the same package you must not mention the package name):


long long

uint64


double


[ ROS 2 Documentation: Foxy ![Logo](../_static/foxy-small.png)
](../index.html)


T[N]

unbounded dynamic array


##  Services  ï


* Prerequisites


* 2.1.2 Field names


    rosidl_target_interfaces(publish_address_book
      ${PROJECT_NAME} "rosidl_typesupport_cpp")


auto publish_msg = [this]() -> void {


#  [ Naming conventions for ros2 msgs ](/t/naming-conventions-for-
ros2-msgs/2583)


_Example of message definition using arrays and bounded types:_


**Tutorial level:** Beginner


* 2 Create a msg file


* **bounded arrays** : Whereas the ROS 1 IDL allows unbounded arrays (e.g., ` int32[]  foo  ` ) and fixed-size arrays (e.g., ` int32[5]  bar  ` ), the ROS 2 IDL further allows bounded arrays (e.g., ` int32[<=5]  bat  ` ). There are use cases in which itâs important to be able to place an upper bound on the size of an array without committing to always using that much space (e.g., in a real-time system in which you need to preallocate all memory that will be used during execution).


* string values must be defined in single ` '  ` or double ` "  ` quotes


std::array<T, N>


bool


* msg: ` .msg  ` files are simple text files that describe the fields of a ROS message. They are used to generate source code for messages in different languages.


You should have [ ROS 2 installed  ](../../Installation.html) , a [ workspace
](Creating-A-Workspace/Creating-A-Workspace.html) , and an understanding of [
creating packages  ](Creating-Your-First-ROS2-Package.html) .


[ Next Generation ROS  ](/c/ng-ros/25)


And generate all lists at once like so:


* 2.1.3 Field default value


[ @christophebedard ](/u/christophebedard) Thanks, yes, I realize that now. My
confusion was that, from the tutorial, I thought it just made the file names
lower case (in the tutorial ` Num.msg ` becomes ` num.hpp ` ). So I had
defined a message file like ` Foo3D.msg ` and I tried including it as `
foo3D.hpp ` , which didn’t work. I had to use ` foo3_d.hpp ` .


Also make sure you export the message runtime dependency:


You would also need to include the header of ` Contact.msg  ` in you publisher
node in order to be able to add ` contacts  ` to your ` address_book  ` .


    source install/local_setup.bash
    ros2 run more_interfaces publish_address_book

    . install/local_setup.bash
    ros2 run more_interfaces publish_address_book

    call install/local_setup.bat
    ros2 run more_interfaces publish_address_book


    std::cout << "Publishing Contact\nFirst:" << message.first_name <<
      "  Last:" << message.last_name << std::endl;

    this->address_book_publisher_->publish(message);


builtins.str*


Inside ` more_interfaces/msg  ` , create a new file ` AddressBook.msg  ` , and
paste the following code to create a message meant to carry information about
an individual:


Field types can be:


    # request constants
    int8 FOO=1
    int8 BAR=2
    # request fields
    int8 foobar
    another_pkg/AnotherMessage msg
    ---
    # response constants
    uint32 SECRET=123456
    # response fields
    another_pkg/YetAnotherMessage val
    CustomMessageDefinedInThisPackage value
    uint32 an_integer


__ [ ROS 2 Documentation: Rolling ](../../index.html)


We can of course get much more complicated (if you want to refer to a message
from the same package you must not mention the package name):


This is an action definition where the action client is sending a single `
int32  ` field representing the number of Fibonacci steps to take, and
expecting the action server to produce an array of ` int32  ` containing the
complete steps. Along the way, the action server may also provide an
intermediate array of ` int32  ` containing the steps accomplished up until a
certain point.


Topic  |  |  Replies  |  Views  |  Activity
---|---|---|---|---
[ Relaxing ROS2 topic/service field name restrictions
](https://discourse.ros.org/t/relaxing-ros2-topic-service-field-name-
restrictions/6371)


[ Python ](https://design.ros2.org/articles/generated_interfaces_python.html)


builtins.list


[ togaen  ](https://discourse.ros.org/u/togaen) April 9, 2020, 1:03pm  3


**You're reading the documentation for a development version. For the latest
released version, please have a look at[ Iron
](../../../iron/Concepts/Basic/About-Interfaces.html) . **


builtins.bytes*


You cannot embed another service inside of a service.


unsigned long long

string


Declare the list of messages you want to generate:


builtins.int*


[ DDS type ](https://design.ros2.org/articles/mapping_dds_types.html)

---|---|---|---

static array


[ Previous ](About-Discovery.html "Discovery") [ Next  ](About-Topics.html
"Topics")


Messages are described and defined in ` .msg  ` files in the ` msg/  `
directory of a ROS package. ` .msg  ` files are composed of two parts: fields
and constants.


__ [ ROS 2 Documentation: Foxy ](../../index.html)


     [ Iron (latest) ](../../iron/index.html)
     [ Humble ](../../humble/index.html)
     [ Galactic (EOL) ](../../galactic/Concepts/About-ROS-Interfaces.html)
     [ Foxy (EOL) ](About-ROS-Interfaces.html)
     [ Eloquent (EOL) ](../../eloquent/Concepts/About-ROS-Interfaces.html)
     [ Dashing (EOL) ](../../dashing/Concepts/About-ROS-Interfaces.html)
     [ Crystal (EOL) ](../../crystal/Concepts/About-ROS-Interfaces.html)


Linux  macOS  Windows


So that’s for ` .msg ` & ` .srv ` files.


    auto publish_msg = [this]() -> void {
       auto msg = std::make_shared<more_interfaces::msg::AddressBook>();
       {
         rosidl_tutorials_msgs::msg::Contact contact;
         contact.first_name = "John";
         contact.last_name = "Doe";
         contact.phone_number = "1234567890";
         contact.phone_type = message.PHONE_TYPE_MOBILE;
         msg->address_book.push_back(contact);
       }
       {
         rosidl_tutorials_msgs::msg::Contact contact;
         contact.first_name = "Jane";
         contact.last_name = "Doe";
         contact.phone_number = "4254242424";
         contact.phone_type = message.PHONE_TYPE_HOME;
         msg->address_book.push_back(contact);
       }

       std::cout << "Publishing address book:" << std::endl;
       for (auto contact : msg->address_book) {
         std::cout << "First:" << contact.first_name << "  Last:" << contact.last_name <<
           std::endl;
       }

       address_book_publisher_->publish(*msg);
     };


##  Actions  ï


    int32 X=123
    int32 Y=-123
    string FOO="foo"
    string EXAMPLE='bar'


Note:


Like services, the request fields are before and the response fields are after
the first triple-dash ( ` ---  ` ), respectively. There is also a third set of
fields after the second triple-dash, which is the fields to be sent when
sending feedback.


|  8  |  1376  |  October 16, 2018
[ Why did ROS2 keep .msg interface definitions?
](https://discourse.ros.org/t/why-did-ros2-keep-msg-interface-
definitions/27631)


|  2  |  660  |  June 18, 2021
[ Use ros message in parameter interface ](https://discourse.ros.org/t/use-
ros-message-in-parameter-interface/31269)


2 Likes


In ros2 wiki it is not defined: [ https://github.com/ros2/ros2/wiki/About-ROS-
Interfaces ](https://github.com/ros2/ros2/wiki/About-ROS-Interfaces)


* Field types


As for snake_case headers, that’s just file naming convention. While it
doesn’t explicitly talk about it, the _[ Introduction to msg and srv
interfaces ](https://index.ros.org/doc/ros2/Tutorials/Rosidl-Tutorial/) _
tutorial (although it’s a draft) does use snake_case headers.


Powered by [ Discourse ](https://www.discourse.org) , best viewed with
JavaScript enabled


Then source the workspace and run the publisher:


This message is composed of these fields:


###  2.1 Fields  ï


octet

uint8


* Field names


Isn’t this _pascal case_ ?


    set(msg_files
      "msg/AddressBook.msg"
    )


Defining a default value is done by adding a third element to the field
definition line, i.e:


Will it be allowed to put ‘_’ in the name of a ros2 msg?