          (length,) = _struct_I.unpack(str[start:end])
          start = end
          end += length
          if python3:
            self.header.frame_id = str[start:end].decode('utf-8', 'rosmsg')
          else:
            self.header.frame_id = str[start:end]
          _x = self
          start = end
          end += 8
          (_x.height, _x.width,) = _get_struct_2I().unpack(str[start:end])
          start = end
          end += 4
          (length,) = _struct_I.unpack(str[start:end])
          start = end
          end += length
          if python3:
            self.encoding = str[start:end].decode('utf-8', 'rosmsg')
          else:
            self.encoding = str[start:end]
          _x = self
          start = end
          end += 5
          (_x.is_bigendian, _x.step,) = _get_struct_BI().unpack(str[start:end])
          start = end
          end += 4
          (length,) = _struct_I.unpack(str[start:end])
          start = end
          end += length
          self.data = str[start:end]
          return self
        except struct.error as e:
          raise genpy.DeserializationError(e)  # most likely buffer underfill

      def serialize_numpy(self, buff, numpy):
        """
        serialize message with numpy array types into buffer
        :param buff: buffer, ``StringIO``
        :param numpy: numpy python module


  * **Development Status**
    * [ 3 - Alpha ](/search/?c=Development+Status+%3A%3A+3+-+Alpha)
  * **Intended Audience**
    * [ Developers ](/search/?c=Intended+Audience+%3A%3A+Developers)
    * [ Science/Research ](/search/?c=Intended+Audience+%3A%3A+Science%2FResearch)
  * **License**
    * [ OSI Approved :: BSD License ](/search/?c=License+%3A%3A+OSI+Approved+%3A%3A+BSD+License)
  * **Operating System**
    * [ OS Independent ](/search/?c=Operating+System+%3A%3A+OS+Independent)
  * **Programming Language**
    * [ Python ](/search/?c=Programming+Language+%3A%3A+Python)
    * [ Python :: 2.7 ](/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+2.7)
    * [ Python :: 3 ](/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3)
    * [ Python :: 3.4 ](/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.4)
    * [ Python :: 3.5 ](/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.5)
    * [ Python :: 3.6 ](/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.6)
    * [ Python :: 3.7 ](/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.7)
    * [ Python :: 3.8 ](/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.8)
  * **Topic**
    * [ Scientific/Engineering ](/search/?c=Topic+%3A%3A+Scientific%2FEngineering)
    * [ Software Development ](/search/?c=Topic+%3A%3A+Software+Development)


Now that you know how to numpy-ize a listener, lets numpy-ize a standard
talker node. This is very similar to what we did above, though you'll have to
be much more careful: _all of your array data must be initialized as numpy
arrays_ . You are responsible for this, _even for fields that you wish to be
initialized with default values_ . You must also be careful that you specify
the correct numpy data type when creating these arrays as rospy will not be
able to catch this mistake.


_These details have been verified by PyPI_


<rosdep name="python-numpy" />


Window 3:


This example presents how the  qPython  can be used along with [ Twisted
](http://twistedmatrix.com/trac/) to build asynchronous client:


Sep 27, 2018


Just for reference, here is the ` rospy_tutorials/Floats ` definition:


######  Maintainers


Execute tests across supported python versions:


  * [ PyPI Blog ](https://blog.pypi.org "External link")
  * [ Infrastructure dashboard ](https://dtdg.co/pypi "External link")
  * [ Statistics ](/stats/)
  * [ Logos & trademarks ](/trademarks/)
  * [ Our sponsors ](/sponsors/)


      <build_depend>python-numpy</build_depend>
      <run_depend>python-numpy</run_depend>

    roscreate-pkg numpy_tutorial rospy rospy_tutorials


[ ![AWS](https://pypi-
camo.freetls.fastly.net/ed7074cadad1a06f56bc520ad9bd3e00d0704c5b/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f707970692d6173736574732f73706f6e736f726c6f676f732f6177732d77686974652d6c6f676f2d7443615473387a432e706e67)
AWS  Cloud computing and Security Sponsor  ](https://aws.amazon.com/) [
![Datadog](https://pypi-
camo.freetls.fastly.net/8855f7c063a3bdb5b0ce8d91bfc50cf851cc5c51/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f707970692d6173736574732f73706f6e736f726c6f676f732f64617461646f672d77686974652d6c6f676f2d6668644c4e666c6f2e706e67)
Datadog  Monitoring  ](https://www.datadoghq.com/) [ ![Fastly](https://pypi-
camo.freetls.fastly.net/df6fe8829cbff2d7f668d98571df1fd011f36192/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f707970692d6173736574732f73706f6e736f726c6f676f732f666173746c792d77686974652d6c6f676f2d65684d3077735f6f2e706e67)
Fastly  CDN  ](https://www.fastly.com/) [ ![Google](https://pypi-
camo.freetls.fastly.net/420cc8cf360bac879e24c923b2f50ba7d1314fb0/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f707970692d6173736574732f73706f6e736f726c6f676f732f676f6f676c652d77686974652d6c6f676f2d616734424e3774332e706e67)
Google  Download Analytics  ](https://careers.google.com/) [
![Microsoft](https://pypi-
camo.freetls.fastly.net/524d1ce72f7772294ca4c1fe05d21dec8fa3f8ea/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f707970692d6173736574732f73706f6e736f726c6f676f732f6d6963726f736f66742d77686974652d6c6f676f2d5a443172685444462e706e67)
Microsoft  PSF Sponsor  ](https://www.python.org/psf/sponsors/#microsoft) [
![Pingdom](https://pypi-
camo.freetls.fastly.net/d01053c02f3a626b73ffcb06b96367fdbbf9e230/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f707970692d6173736574732f73706f6e736f726c6f676f732f70696e67646f6d2d77686974652d6c6f676f2d67355831547546362e706e67)
Pingdom  Monitoring  ](https://www.pingdom.com/) [ ![Sentry](https://pypi-
camo.freetls.fastly.net/67af7117035e2345bacb5a82e9aa8b5b3e70701d/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f707970692d6173736574732f73706f6e736f726c6f676f732f73656e7472792d77686974652d6c6f676f2d4a2d6b64742d706e2e706e67)
Sentry  Error logging  ](https://getsentry.com/for/python) [
![StatusPage](https://pypi-
camo.freetls.fastly.net/b611884ff90435a0575dbab7d9b0d3e60f136466/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f707970692d6173736574732f73706f6e736f726c6f676f732f737461747573706167652d77686974652d6c6f676f2d5467476c6a4a2d502e706e67)
StatusPage  Status page  ](https://statuspage.io)


On Read the Docs


        """
        try:
          _x = self
          buff.write(_get_struct_3I().pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
          _x = self.header.frame_id
          length = len(_x)
          if python3 or type(_x) == unicode:
            _x = _x.encode('utf-8')
            length = len(_x)
          buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
          _x = self
          buff.write(_get_struct_2I().pack(_x.height, _x.width))
          _x = self.encoding
          length = len(_x)
          if python3 or type(_x) == unicode:
            _x = _x.encode('utf-8')
            length = len(_x)
          buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
          _x = self
          buff.write(_get_struct_BI().pack(_x.is_bigendian, _x.step))
          _x = self.data
          length = len(_x)
          # - if encoded as a list instead, serialize as bytes instead of string
          if type(_x) in [list, tuple]:
            buff.write(struct.Struct('<I%sB'%length).pack(length, *_x))
          else:
            buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
        except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
        except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

      def deserialize_numpy(self, str, numpy):
        """
        unpack serialized message in str into this message instance using numpy for array types
        :param str: byte array of serialized message, ``str``
        :param numpy: numpy python module
        """
        if python3:
          codecs.lookup_error("rosmsg").msg_type = self._type
        try:
          if self.header is None:


* [ __ Homepage ](https://github.com/lebedov/msgpack-numpy)


     [ Project Home ](//readthedocs.org/projects/qpython/?fromdocs=qpython)
     [ Builds ](//readthedocs.org/builds/qpython/?fromdocs=qpython)


Note that numpy arrays deserialized by msgpack-numpy are read-only and must be
copied if they are to be modified.


  * [ index ](../../../genindex.html "General Index")
  * [ modules ](../../../py-modindex.html "Python Module Index") |
  * [ MORSE ](../../../morse.html) »  unstable  stable
  * [ Module code ](../../index.html) »


This time the output is slightly different, which shows that you are now
receiving numpy arrays:


© Copyright 2014-2016, DEVnet  Revision ` 7e64a28b ` .


###  [ Hashes ](https://pip.pypa.io/en/stable/topics/secure-installs/#hash-
checking-mode "External link") for msgpack-numpy-0.4.8.tar.gz


Download the file for your platform. If you're not sure which to choose, learn
more about [ installing packages
](https://packaging.python.org/tutorials/installing-packages/ "External link")
.


[ ![Latest Version](https://pypi-
camo.freetls.fastly.net/620db2e41e71c86d29041c76cfc6b67a7267e8e3/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f6d73677061636b2d6e756d70792e737667)
](https://pypi.python.org/pypi/msgpack-numpy) [ ![Build Status](https://pypi-
camo.freetls.fastly.net/52d1bd488e6b74546033a5b447e7d12d3777141f/68747470733a2f2f7472617669732d63692e6f72672f6c656265646f762f6d73677061636b2d6e756d70792e7376673f6272616e63683d6d6173746572)
](https://travis-ci.org/lebedov/msgpack-numpy)


python setup.py install


###  Verified details


Nov 8, 2018


Numpy data serialization using msgpack


##  Contributing to PyPI


May 16, 2019


Window 2:


pip install msgpack-numpy


Here are these two lines in context:


  * [ Distributions ](/Distributions)
  * [ ROS/Installation ](/ROS/Installation)
  * [ ROS/Tutorials ](/ROS/Tutorials)
  * [ RecentChanges ](/RecentChanges)
  * [ numpy ](/rospy_tutorials/Tutorials/numpy)


    # This Python file uses the following encoding: utf-8
    """autogenerated by genpy from sensor_msgs/Image.msg. Do not edit."""
    import codecs
    import sys
    python3 = True if sys.hexversion > 0x03000000 else False
    import genpy
    import struct

    import std_msgs.msg

    class Image(genpy.Message):
      _md5sum = "060021388200f6f0f447d0fcd9c64743"
      _type = "sensor_msgs/Image"
      _has_header = True  # flag to mark the presence of a Header object
      _full_text = """# This message contains an uncompressed image
    # (0, 0) is at top-left corner of image
    #

    Header header        # Header timestamp should be acquisition time of image
                         # Header frame_id should be optical frame of camera
                         # origin of frame should be optical center of camera
                         # +x should point to the right in the image
                         # +y should point down in the image
                         # +z should point into to plane of the image
                         # If the frame_id here and the frame_id of the CameraInfo
                         # message associated with the image conflict
                         # the behavior is undefined

    uint32 height         # image height, that is, number of rows
    uint32 width          # image width, that is, number of columns

    # The legal values for encoding are in file src/image_encodings.cpp
    # If you want to standardize a new string format, join
    # ros-users@lists.sourceforge.net and send an email proposing a new encoding.

    string encoding       # Encoding of pixels -- channel meaning, ordering, size
                          # taken from the list of strings in include/sensor_msgs/image_encodings.h


Feb 24, 2017


roscore


The ROS Wiki is for ROS 1. Are you using ROS 2 ( [ Humble
](http://docs.ros.org/en/humble/) , [ Iron ](http://docs.ros.org/en/iron/) ,
or [ Rolling ](http://docs.ros.org/en/rolling/) )?
[ Check out the ROS 2 Project Documentation ](http://docs.ros.org)
Package specific documentation can be found on [ index.ros.org
](https://index.ros.org)


  * __ **Stars:**
  * __ **Forks:**
  * __ **Open issues:**
  * __ **Open PRs:**


    import struct
    import sys

    from twisted.internet.protocol import Protocol, ClientFactory

    from twisted.internet import reactor
    from qpython.qconnection import MessageType, QAuthenticationException
    from qpython.qreader import QReader
    from qpython.qwriter import QWriter, QWriterException

    class IPCProtocol(Protocol):

        class State(object):
            UNKNOWN = -1
            HANDSHAKE = 0
            CONNECTED = 1

        def connectionMade(self):
            self.state = IPCProtocol.State.UNKNOWN
            self.credentials = self.factory.username + ':' + self.factory.password if self.factory.password else ''

            self.transport.write(self.credentials + '\3\0')

            self._message = None

        def dataReceived(self, data):
            if self.state == IPCProtocol.State.CONNECTED:
                try:
                    if not self._message:
                        self._message = self._reader.read_header(source=data)
                        self._buffer = ''

                    self._buffer += data
                    buffer_len = len(self._buffer) if self._buffer else 0

                    while self._message and self._message.size <= buffer_len:


Downloads


###  Source Distribution


tox


###  Quick search


  * [ Help ](/help/)
  * [ Sponsors ](/sponsors/)
  * [ Log in ](/account/login/)
  * [ Register ](/account/register/)


    # Using a system python
    pip install tox

    # Additionally, using a conda-provided python
    pip install tox tox-conda


With those warnings out of the way, let's look at a numpy-ized talker. Create
a new file, ` numpy_talker.py ` , with the following:


Feb 5, 2017


Hashes for msgpack_numpy-0.4.8-py2.py3-none-any.whl  Algorithm  |  Hash digest
|
---|---|---
SHA256  |  ` 773c19d4dfbae1b3c7b791083e2caf66983bb19b40901646f61d8731554ae3da
` |  Copy
MD5  |  ` 6c2dc5bdd55a65c0a289013a7ee98139 ` |  Copy
BLAKE2b-256  |  `
9b5df25ac7d4fb77cbd53ddc6d05d833c6bf52b12770a44fa9a447eed470ca9a ` |  Copy

Close


msgpack-numpy will try to use the binary (fast) extension in msgpack by
default.
If msgpack was not compiled with Cython (or if the ` MSGPACK_PUREPYTHON `
variable is set), it will fall back to using the slower pure Python msgpack
implementation.


  * [ Installing packages ](https://packaging.python.org/tutorials/installing-packages/ "External link")
  * [ Uploading packages ](https://packaging.python.org/tutorials/packaging-projects/ "External link")
  * [ User guide ](https://packaging.python.org/ "External link")
  * [ Project name retention ](https://www.python.org/dev/peps/pep-0541/ "External link")
  * [ FAQs ](/help/)


##  Asynchronous query  ¶


##  Installation


  * __ Project description
  * __ Project details
  * __ Release history
  * __ Download files


       1 #!/usr/bin/env python
       2 PKG = 'numpy_tutorial'
       3 import roslib; roslib.load_manifest(PKG)
       4
       5 import rospy
       6 from rospy_tutorials.msg import Floats
       7
       8 def callback(data):
       9     print rospy.get_name(), "I heard %s"%str(data.data)
      10
      11 def listener():
      12     rospy.init_node('listener')
      13     rospy.Subscriber("floats", Floats, callback)
      14     rospy.spin()
      15
      16 if __name__ == '__main__':
      17     listener()


Wiki: rospy_tutorials/Tutorials/numpy (last edited 2019-03-15 21:05:10 by  [
TullyFoote ](/TullyFoote "TullyFoote @
70-35-50-58.static.wiline.com\[70.35.50.58\]") )


[ ![Logo](../../../_static/morse-logo.png) ](../../../morse.html)


# Software License Agreement (BSD License)
#
# Copyright (c) 2009, Willow Garage, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above
#    copyright notice, this list of conditions and the following
#    disclaimer in the documentation and/or other materials provided
#    with the distribution.
#  * Neither the name of Willow Garage, Inc. nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Revision $Id$
"""
Support for using numpy with rospy messages.


##  Project details


Following example presents how to execute simple, synchronous query against a
remote q process:


By now, you're probably familiar with creating listener nodes. Lets start off
simple and create a standard listener node that listens to the ` floats ` [
Topic ](/Topics) using the ` rospy_tutorials/Floats ` [ Message type ](/msg) .


chmod +x numpy_talker.py


You should see:


          raise genpy.DeserializationError(e)  # most likely buffer underfill

    _struct_I = genpy.struct_I
    def _get_struct_I():
        global _struct_I
        return _struct_I
    _struct_2I = None
    def _get_struct_2I():
        global _struct_2I
        if _struct_2I is None:
            _struct_2I = struct.Struct("<2I")
        return _struct_2I
    _struct_3I = None
    def _get_struct_3I():
        global _struct_3I
        if _struct_3I is None:
            _struct_3I = struct.Struct("<3I")
        return _struct_3I
    _struct_BI = None
    def _get_struct_BI():
        global _struct_BI
        if _struct_BI is None:
            _struct_BI = struct.Struct("<BI")
        return _struct_BI


###  Navigation


Jul 11, 2018


Just like the listener example, there is a ` from rospy.numpy_msg import
numpy_msg ` to get the ` numpy_msg() ` wrapper. You can also see that this is
used when creating the ` Publisher ` instance:


__ Warning  Some features may not work without JavaScript. Please try enabling
it if you encounter problems.


##  Custom type IPC deserialization  ¶


Now, lets start with this standard listener. Paste the text below into a file
called ` numpy_listener.py ` .


##  Notes


Except where otherwise noted, the ROS wiki is licensed under the
[ Creative Commons Attribution 3.0
](http://creativecommons.org/licenses/by/3.0/)


##  Step 4: Numpy-ize a Talker


For tutorials, see U{http://wiki.ros.org/rospy_tutorials/Tutorials/numpy}
Listener example::
    from rospy.numpy_msg import numpy_msg
    rospy.init_node('mynode')
    rospy.Subscriber("mytopic", numpy_msg(TopicType))
Publisher example::
    from rospy.numpy_msg import numpy_msg
    import numpy

    pub = rospy.Publisher('mytopic', numpy_msg(TopicType), queue_size=10)
    rospy.init_node('mynode')
    a = numpy.array([1.0, 2.1, 3.2, 4.3, 5.4, 6.5], dtype=numpy.float32)
    pub.publish(a)
"""
import numpy
# TODO: we will need to generate a new type structure with
# little-endian specified and then pass that type structure into the
# *_numpy calls.
def _serialize_numpy(self, buff):
    """
    wrapper for factory-generated class that passes numpy module into serialize
    """
    # pass in numpy module reference to prevent import in auto-generated code
    return self.serialize_numpy(buff, numpy)
def _deserialize_numpy(self, str):
    """
    wrapper for factory-generated class that passes numpy module into deserialize
    """
    # pass in numpy module reference to prevent import in auto-generated code
    return self.deserialize_numpy(str, numpy)

_numpy_msg_types = {}
## Use this function to generate message instances using numpy array
## types for numerical arrays.
## @msg_type Message class: call this functioning on the message type that you pass
## into a Publisher or Subscriber call.
## @returns Message class
def numpy_msg(msg_type):
    if msg_type in _numpy_msg_types:
        return _numpy_msg_types[msg_type]
    classdict = { '__slots__': msg_type.__slots__, '_slot_types': msg_type._slot_types,
                  '_md5sum': msg_type._md5sum, '_type': msg_type._type,
                  '_has_header': msg_type._has_header, '_full_text': msg_type._full_text,
                  'serialize': _serialize_numpy, 'deserialize': _deserialize_numpy,
                  'serialize_numpy': msg_type.serialize_numpy,
                                    'deserialize_numpy': msg_type.deserialize_numpy
                  }
    # create the numpy message type
    msg_type_name = "Numpy_%s"%msg_type._type.replace('/', '__')
    numpy_type = type(msg_type_name,(msg_type,),classdict)
    _numpy_msg_types[msg_type] = numpy_type
    return numpy_type


Sep 16, 2020


![](/static/images/white-cube.2351a86c.svg)


                            self.stop()

                except QException as e:
                    print(e)

    if __name__ == '__main__':
        # create connection object
        q = qconnection.QConnection(host = 'localhost', port = 5000)
        # initialize connection
        q.open()

        print(q)
        print('IPC version: %s. Is connected: %s' % (q.protocol_version, q.is_connected()))

        try:
            # definition of asynchronous multiply function
            # queryid - unique identifier of function call - used to identify
            # the result
            # a, b - parameters to the query
            q.sendSync('asynchMult:{[queryid;a;b] res:a*b; (neg .z.w)(`queryid`result!(queryid;res)) }');

            t = ListenerThread(q)
            t.start()

            for x in range(10):
                a = random.randint(1, 100)
                b = random.randint(1, 100)
                print('Asynchronous call with queryid=%s with arguments: %s, %s' % (x, a, b))
                q.sendAsync('asynchMult', x, a, b);

            time.sleep(1)
        finally:
            q.close()


"PyPI", "Python Package Index", and the blocks logos are registered [
trademarks ](/trademarks/) of the [ Python Software Foundation
](https://www.python.org/psf-landing) .


[ ![Avatar for lebedov from gravatar.com](https://pypi-
camo.freetls.fastly.net/01e7af309fa73be94fff5898896dbe6768ac6e2b/68747470733a2f2f7365637572652e67726176617461722e636f6d2f6176617461722f32303863653438666636323533313938366231363032626665303534633934653f73697a653d3530)
lebedov  ](/user/lebedov/)


#  Changelog for package ros_gz_bridge


No version for distro **dashing** . Known supported distros are highlighted in
the buttons above.


  * ` subscription_heartbeat ` \- Period at which the node checks for new subscribers for lazy bridges.
  * ` config_file ` \- YAML file to be loaded as the bridge configuration
  * ` expand_gz_topic_names ` \- Enable or disable ROS namespace applied on GZ topics.


Skip to content
Toggle navigation
[ ](https://github.com/)
[ Sign in
](/login?return_to=https%3A%2F%2Fgithub.com%2Fgazebosim%2Fros_gz%2Ftree%2Fhumble)
  * Product
    * [ Actions  Automate any workflow  ](/features/actions)
    * [ Packages  Host and manage packages  ](/features/packages)
    * [ Security  Find and fix vulnerabilities  ](/features/security)
    * [ Codespaces  Instant dev environments  ](/features/codespaces)
    * [ Copilot  Write better code with AI  ](/features/copilot)
    * [ Code review  Manage code changes  ](/features/code-review)
    * [ Issues  Plan and track work  ](/features/issues)
    * [ Discussions  Collaborate outside of code  ](/features/discussions)
Explore
    * [ All features ](/features)
    * [ Documentation  ](https://docs.github.com)
    * [ GitHub Skills  ](https://skills.github.com/)
    * [ Blog  ](https://github.blog)
  * Solutions
For
    * [ Enterprise ](/enterprise)
    * [ Teams ](/team)
    * [ Startups ](/enterprise/startups)
    * [ Education  ](https://education.github.com)
By Solution
    * [ CI/CD & Automation ](/solutions/ci-cd/)
    * [ DevOps ](/solutions/devops/)
    * [ DevSecOps  ](https://resources.github.com/devops/fundamentals/devsecops/)
Resources
    * [ Learning Pathways  ](https://resources.github.com/learn/pathways/)
    * [ White papers, Ebooks, Webinars  ](https://resources.github.com/)
    * [ Customer Stories ](/customer-stories)
    * [ Partners  ](https://partner.github.com/)
  * Open Source
    * [ GitHub Sponsors  Fund open source developers  ](/sponsors)
    * [ The ReadME Project  GitHub community articles  ](/readme)
Repositories
    * [ Topics ](/topics)
    * [ Trending ](/trending)


     # Set just topic name, applies to both
    - topic_name: "chatter"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"

    # Set just ROS topic name, applies to both
    - ros_topic_name: "chatter_ros"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"

    # Set just GZ topic name, applies to both
    - gz_topic_name: "chatter_ign"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"

    # Set each topic name explicitly
    - ros_topic_name: "chatter_both_ros"
      gz_topic_name: "chatter_both_ign"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"

    # Full set of configurations
    - ros_topic_name: "ros_chatter"
      gz_topic_name: "ign_chatter"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"
      subscriber_queue: 5       # Default 10
      publisher_queue: 6        # Default 10
      lazy: true                # Default "false"
      direction: BIDIRECTIONAL  # Default "BIDIRECTIONAL" - Bridge both directions
                                # "GZ_TO_ROS" - Bridge Ignition topic to ROS
                                # "ROS_TO_GZ" - Bridge ROS topic to Ignition


- ros_topic_name: "scan"
  gz_topic_name: "/scan"
  ros_type_name: "sensor_msgs/msg/LaserScan"
  gz_type_name: "gz.msgs.LaserScan"
  direction: GZ_TO_ROS  # BIDIRECTIONAL or ROS_TO_GZ
Publish key strokes to ROS
Let's send messages to ROS using the Key Publisher an Gazebo plugin.


` ros2 topic pub /chatter std_msgs/msg/String 'data: "Hello"' -1 `


    # Shell C:
    . /opt/ros/humble/setup.bash
    ros2 topic pub /demo/chatter std_msgs/msg/String "data: 'Hi from inside of a namespace'" --once


##  Example 1a: Gazebo Transport talker and ROS 2 listener


Failed to get question list, you can ticket an issue [ here
](https://github.com/ros-infrastructure/rosindex/issues/new)


Dependencies __ |


##  Example 3: Static bridge


In this example, we're going to run an executable that starts a bidirectional
bridge for a specific topic and message type. We'll use the ` static_bridge `
executable that is installed with the bridge.


    # Shell B:
    . ~/bridge_ws/install/setup.bash
    ros2 run ros_gz_bridge parameter_bridge /rgbd_camera/image@sensor_msgs/msg/Image@ignition.msgs.Image


##  Example 4: Service bridge


Let's give it a try, starting with Gazebo -> ROS 2.


_No service files found_


#  Bridge communication between ROS and Gazebo


###  Package Dependencies


**Checkout URI** |  [ https://github.com/gazebosim/ros_gz.git
](https://github.com/gazebosim/ros_gz.git)
---|---
**VCS Type** |  git
**VCS Version** |  humble
**Last Updated**

2024-04-08  |  **Dev Status** |  MAINTAINED
**CI status** |  No Continuous Integration
**Released** |  RELEASED
**Tags** |  _No category tags._
**Contributing** |  [ Help Wanted (  0  ) ](/r/ros_gz/#rolling-contribute-
lists-help-wanted)
[ Good First Issues (  0  ) ](/r/ros_gz/#rolling-contribute-lists-good-first-
issue)
[ Pull Requests to Review (  0  ) ](/r/ros_gz/#rolling-contribute-lists-pull-
requests)

###  Package Description


![Gazebo Transport images and ROS
rqt](https://raw.githubusercontent.com/gazebosim/ros_gz/humble/ros_gz_bridge/images/bridge_image_exchange.png)


####  Maintainers


    # Shell A:
    ign gazebo sensors_demo.sdf


    # Shell A:
    . ~/bridge_ws/install/setup.bash
    ros2 run ros_gz_bridge parameter_bridge /chatter@std_msgs/msg/String@ignition.msgs.StringMsg


* Shivesh Khaitan


##  0.244.14 (2024-04-08)


##  API


Now we start the Gazebo Transport listener.


    # Shell B:
    ign topic -e -t /demo/chatter


**Tags** |  _No category tags._
---|---
**Version** |  0.244.14
**License** |  Apache 2.0
**Build type** |  AMENT_CMAKE
**Use** |  RECOMMENDED

###  Repository Summary


###  Plugins


* [ github-gazebosim-ros_gz ](/p/ros_gz_bridge/github-gazebosim-ros_gz)


And on terminal E, publish a ROS 2 message:


     # Set just topic name, applies to both
    - topic_name: "chatter"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"

    # Set just ROS topic name, applies to both
    - ros_topic_name: "chatter_ros"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"

    # Set just GZ topic name, applies to both
    - gz_topic_name: "chatter_ign"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"

    # Set each topic name explicitly
    - ros_topic_name: "chatter_both_ros"
      gz_topic_name: "chatter_both_ign"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"

    # Full set of configurations
    - ros_topic_name: "ros_chatter"
      gz_topic_name: "ign_chatter"
      ros_type_name: "std_msgs/msg/String"
      gz_type_name: "ignition.msgs.StringMsg"
      subscriber_queue: 5       # Default 10
      publisher_queue: 6        # Default 10
      lazy: true                # Default "false"
      direction: BIDIRECTIONAL  # Default "BIDIRECTIONAL" - Bridge both directions
                                # "GZ_TO_ROS" - Bridge Ignition topic to ROS
                                # "ROS_TO_GZ" - Bridge ROS topic to Ignition


[ ros_gz ](/p/ros_gz/github-gazebosim-ros_gz) ros_gz_bridge  [ ros_gz_image
](/p/ros_gz_image/github-gazebosim-ros_gz) [ ros_gz_interfaces
](/p/ros_gz_interfaces/github-gazebosim-ros_gz) [ ros_gz_point_cloud
](/p/ros_gz_point_cloud/github-gazebosim-ros_gz) [ ros_gz_sim
](/p/ros_gz_sim/github-gazebosim-ros_gz) [ ros_gz_sim_demos
](/p/ros_gz_sim_demos/github-gazebosim-ros_gz) [ ros_ign ](/p/ros_ign/github-
gazebosim-ros_gz) [ ros_ign_bridge ](/p/ros_ign_bridge/github-gazebosim-
ros_gz) [ ros_ign_gazebo ](/p/ros_ign_gazebo/github-gazebosim-ros_gz) [
ros_ign_gazebo_demos ](/p/ros_ign_gazebo_demos/github-gazebosim-ros_gz) [
ros_ign_image ](/p/ros_ign_image/github-gazebosim-ros_gz) [ ros_ign_interfaces
](/p/ros_ign_interfaces/github-gazebosim-ros_gz) [ test_ros_gz_bridge
](/p/test_ros_gz_bridge/github-gazebosim-ros_gz)
---|---

github-gazebosim-ros_gz


` ign gazebo shapes.sdf `


It's possible to make ROS service requests into Gazebo. Let's try unpausing
the simulation.


The following message types can be bridged for topics:


* Louise Poubel


##  Example 6: Using ROS namespace with the Bridge


#  Changelog for package ros_gz_bridge


* ` public  rclcpp::Node  `


###  Messages


_See[ ROS Wiki Tutorials ](http://wiki.ros.org/ros_gz_bridge/Tutorials) for
more details. _


@ is a bidirectional bridge.
[ is a bridge from Gazebo to ROS.
] is a bridge from ROS to Gazebo.
Have a look at these examples explaining how to make communication connections from ROS to Gazebo and vice versa.


It is also possible to use ROS Launch with the ros_gz_bridge and represent the topics in yaml format to be given to the bridge at launch time.


gz sim empty.sdf
Then add the Key Publisher plugin from the dropdown menu on the top right corner.


ROS Resources: [ Documentation ](http://docs.ros.org/) | [ Support
](http://wiki.ros.org/Support) | [ Discussion Forum
](http://discourse.ros.org/) | [ Service Status ](http://status.ros.org/) | [
ros @ Robotics Stack Exchange
](https://robotics.stackexchange.com/questions/tagged/ros)
---

[ ROS Index ](/)


    # Shell C:
    . /opt/ros/humble/setup.bash
    ros2 run rqt_image_view rqt_image_view /rgbd_camera/image


ROS type  |  Gazebo type
---|---
builtin_interfaces/msg/Time  |  ignition::msgs::Time
std_msgs/msg/Bool  |  ignition::msgs::Boolean
std_msgs/msg/ColorRGBA  |  ignition::msgs::Color
std_msgs/msg/Empty  |  ignition::msgs::Empty
std_msgs/msg/Float32  |  ignition::msgs::Float
std_msgs/msg/Float64  |  ignition::msgs::Double
std_msgs/msg/Header  |  ignition::msgs::Header
std_msgs/msg/Int32  |  ignition::msgs::Int32
std_msgs/msg/UInt32  |  ignition::msgs::UInt32
std_msgs/msg/String  |  ignition::msgs::StringMsg
geometry_msgs/msg/Wrench  |  ignition::msgs::Wrench
geometry_msgs/msg/WrenchStamped  |  ignition::msgs::Wrench
geometry_msgs/msg/Quaternion  |  ignition::msgs::Quaternion
geometry_msgs/msg/Vector3  |  ignition::msgs::Vector3d
geometry_msgs/msg/Point  |  ignition::msgs::Vector3d
geometry_msgs/msg/Pose  |  ignition::msgs::Pose
geometry_msgs/msg/PoseArray  |  ignition::msgs::Pose_V
geometry_msgs/msg/PoseWithCovariance  |  ignition::msgs::PoseWithCovariance
geometry_msgs/msg/PoseStamped  |  ignition::msgs::Pose
geometry_msgs/msg/Transform  |  ignition::msgs::Pose
geometry_msgs/msg/TransformStamped  |  ignition::msgs::Pose
geometry_msgs/msg/Twist  |  ignition::msgs::Twist
geometry_msgs/msg/TwistStamped  |  ignition::msgs::Twist
geometry_msgs/msg/TwistWithCovariance  |  ignition::msgs::TwistWithCovariance
geometry_msgs/msg/TwistWithCovarianceStamped  |
ignition::msgs::TwistWithCovariance
nav_msgs/msg/Odometry  |  ignition::msgs::Odometry
nav_msgs/msg/Odometry  |  ignition::msgs::OdometryWithCovariance
rcl_interfaces/msg/ParameterValue  |  ignition::msgs::Any
ros_gz_interfaces/msg/Altimeter  |  ignition::msgs::Altimeter
ros_gz_interfaces/msg/Contact  |  ignition::msgs::Contact
ros_gz_interfaces/msg/Contacts  |  ignition::msgs::Contacts
ros_gz_interfaces/msg/Dataframe  |  ignition::msgs::Dataframe
ros_gz_interfaces/msg/Entity  |  ignition::msgs::Entity
ros_gz_interfaces/msg/Float32Array  |  ignition::msgs::Float_V
ros_gz_interfaces/msg/GuiCamera  |  ignition::msgs::GUICamera
ros_gz_interfaces/msg/JointWrench  |  ignition::msgs::JointWrench
ros_gz_interfaces/msg/Light  |  ignition::msgs::Light


Protected Attributes


  * Overview
  * 0  Assets
  * 29  Dependencies
  * 0  Tutorials
  * 0  Q & A


Let's give it a try, starting with Gazebo -> ROS 2.


    # Shell C:
    ign topic -t /chatter -m ignition.msgs.StringMsg -p 'data:"Hello"'


` ros2 run ros_gz_bridge parameter_bridge
/world/shapes/control@ros_gz_interfaces/srv/ControlWorld `


At this point, you should see the ROS 2 listener echoing the message.


Now we start the Gazebo Transport listener.


ROS 2 Parameters:


    # Shell B:
    ign topic -e -t /demo/chatter


On terminal A, start the service bridge:


  * Added conversion for Detection3D and Detection3DArray ( [ #523 ](https://github.com/gazebosim/ros_gz/issues/523) ) ( [ #526 ](https://github.com/gazebosim/ros_gz/issues/526) ) Co-authored-by: wittenator < [ 9154515+wittenator@users.noreply.github.com ](mailto:9154515+wittenator@users.noreply.github.com) >
  * Add ROS namespaces to GZ topics ( [ #512 ](https://github.com/gazebosim/ros_gz/issues/512) ) Co-authored-by: Alejandro Hern


  * [ About ](/about)
  * Index
    * [ Package List ](/packages/page/1/time/)
    * [ Repository List ](/repos/page/1/time/)
    *     * [ Nodes ](/srvs/)
    * [ Messages ](/msgs/)
    * [ Services ](/srvs/)
    * [ Plugins ](/srvs/)
    *     * [ System Dependencies ](/deps/)
  * [ Contribute ](/contribute)
  * [ Stats ](/stats)


Now we start the ROS talker.


` ros2 topic pub /chatter std_msgs/msg/String 'data: "Hello"' -1 `


CHANGELOG


    # Shell B:
    ign topic -l | grep image
    /rgbd_camera/depth_image
    /rgbd_camera/image


[ ros_gz ](/p/ros_gz/github-gazebosim-ros_gz) ros_gz_bridge  [ ros_gz_image
](/p/ros_gz_image/github-gazebosim-ros_gz) [ ros_gz_interfaces
](/p/ros_gz_interfaces/github-gazebosim-ros_gz) [ ros_gz_point_cloud
](/p/ros_gz_point_cloud/github-gazebosim-ros_gz) [ ros_gz_sim
](/p/ros_gz_sim/github-gazebosim-ros_gz) [ ros_gz_sim_demos
](/p/ros_gz_sim_demos/github-gazebosim-ros_gz) [ ros_ign ](/p/ros_ign/github-
gazebosim-ros_gz) [ ros_ign_bridge ](/p/ros_ign_bridge/github-gazebosim-
ros_gz) [ ros_ign_gazebo ](/p/ros_ign_gazebo/github-gazebosim-ros_gz) [
ros_ign_gazebo_demos ](/p/ros_ign_gazebo_demos/github-gazebosim-ros_gz) [
ros_ign_image ](/p/ros_ign_image/github-gazebosim-ros_gz) [ ros_ign_interfaces
](/p/ros_ign_interfaces/github-gazebosim-ros_gz) [ test_ros_gz_bridge
](/p/test_ros_gz_bridge/github-gazebosim-ros_gz)
---|---

github-gazebosim-ros_gz


    # Shell A:
    . ~/bridge_ws/install/setup.bash
    ros2 run ros_gz_bridge parameter_bridge /chatter@std_msgs/msg/String@ignition.msgs.StringMsg


gz topic -t "/model/vehicle/cmd_vel" -m gz.msgs.Twist -p "linear: {x: 1.0}, angular: {z: -0.1}"
ros2 topic pub /model/vehicle/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 5.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: -0.1}}
And verify the vehicle matching its trajectory in Gazebo and RViz.


` ros2 run ros_gz_bridge static_bridge `


Name  |  Repo  |  Deps  |  [ rmf_demos_gz ](/p/rmf_demos_gz/github-open-rmf-
rmf_demos#iron) |  [ github-open-rmf-rmf_demos ](/r/rmf_demos/github-open-rmf-
rmf_demos) |  [ ](/p/rmf_demos_gz/github-open-rmf-rmf_demos#iron-deps)
---|---|---
[ gz_ros2_control_demos ](/p/gz_ros2_control_demos/github-ros-controls-
gz_ros2_control#iron) |  [ github-ros-controls-gz_ros2_control
](/r/gz_ros2_control/github-ros-controls-gz_ros2_control) |  [
](/p/gz_ros2_control_demos/github-ros-controls-gz_ros2_control#iron-deps)
[ ros_gz ](/p/ros_gz/github-gazebosim-ros_gz#iron) |  [ github-gazebosim-
ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [ ](/p/ros_gz/github-gazebosim-
ros_gz#iron-deps)
[ ros_gz_image ](/p/ros_gz_image/github-gazebosim-ros_gz#iron) |  [ github-
gazebosim-ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [
](/p/ros_gz_image/github-gazebosim-ros_gz#iron-deps)
[ ros_gz_sim_demos ](/p/ros_gz_sim_demos/github-gazebosim-ros_gz#iron) |  [
github-gazebosim-ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [
](/p/ros_gz_sim_demos/github-gazebosim-ros_gz#iron-deps)
[ ros_ign_bridge ](/p/ros_ign_bridge/github-gazebosim-ros_gz#iron) |  [
github-gazebosim-ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [
](/p/ros_ign_bridge/github-gazebosim-ros_gz#iron-deps)
[ test_ros_gz_bridge ](/p/test_ros_gz_bridge/github-gazebosim-ros_gz#iron) |
[ github-gazebosim-ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [
](/p/test_ros_gz_bridge/github-gazebosim-ros_gz#iron-deps)

###  Launch files


No version for distro **hydro** . Known supported distros are highlighted in
the buttons above.


© Copyright 2021, Apache 2.0.


---

[
API Docs ](http://docs.ros.org/en/iron/p/ros_gz_bridge "View API documentation
on docs.ros.org") [
Browse Code ](https://github.com/gazebosim/ros_gz/tree/humble/ros_gz_bridge
"View source code on repository")


_No plugins found._


Component container for the ROS-GZ Bridge.


The configuration file must be a YAML array of maps. An example configuration
for 5 bridges is below, showing the various ways that a bridge may be
specified:


        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::SensorNoise&, ros_gz_interfaces::msg::SensorNoise&) ](function_ros__gz__interfaces_8hpp_1a1455d8760ab1ff21423009b1aef39650.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::StringMsg_V&, ros_gz_interfaces::msg::StringVec&) ](function_ros__gz__interfaces_8hpp_1ac15a356c3c56699baafc0c89eff34ebf.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Param&, ros_gz_interfaces::msg::ParamVec&) ](function_ros__gz__interfaces_8hpp_1acd56ce60489489f35e748a186de2ef7f.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Param_V&, ros_gz_interfaces::msg::ParamVec&) ](function_ros__gz__interfaces_8hpp_1a83296e35e63369f5a03b0c58f8ff52c7.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::TrackVisual&, ros_gz_interfaces::msg::TrackVisual&) ](function_ros__gz__interfaces_8hpp_1a0f96b314e3cd16d4ae9c604cc72436cb.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::VideoRecord&, ros_gz_interfaces::msg::VideoRecord&) ](function_ros__gz__interfaces_8hpp_1a5bc9f6a2e93fb3dbe12e39bb10133284.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::WorldControl&, ros_gz_interfaces::msg::WorldControl&) ](function_ros__gz__interfaces_8hpp_1a37149533b18f80e0f9916ef111ac89a7.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::WorldReset&, ros_gz_interfaces::msg::WorldReset&) ](function_ros__gz__interfaces_8hpp_1a21e568e649f644f745528b17f455084a.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Float_V&, ros_gz_interfaces::msg::Float32Array&) ](function_ros__gz__interfaces_8hpp_1ad3cccc5f20a44dd9bb54d62aa28a9ffa.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Clock&, rosgraph_msgs::msg::Clock&) ](function_rosgraph__msgs_8hpp_1a646602508ca1f10528cfa9896ce2c313.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Joy&, sensor_msgs::msg::Joy&) ](function_sensor__msgs_8hpp_1aca24f688f9f376f2b2cee17eed1445fd.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::FluidPressure&, sensor_msgs::msg::FluidPressure&) ](function_sensor__msgs_8hpp_1acf46168eab763711c2f966ee68e3b28e.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Image&, sensor_msgs::msg::Image&) ](function_sensor__msgs_8hpp_1ac1bb1dff4821829a97f816707d881a06.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::CameraInfo&, sensor_msgs::msg::CameraInfo&) ](function_sensor__msgs_8hpp_1a7ffd99b7dd34eb406038c2bdca0acf4c.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::IMU&, sensor_msgs::msg::Imu&) ](function_sensor__msgs_8hpp_1ae47a633c4007c68210b8aae098cb11bd.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Model&, sensor_msgs::msg::JointState&) ](function_sensor__msgs_8hpp_1aa034728ee82da71cf16df2af0e93b648.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::LaserScan&, sensor_msgs::msg::LaserScan&) ](function_sensor__msgs_8hpp_1a49efd0e7587026e8d721334c9d64fe95.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Magnetometer&, sensor_msgs::msg::MagneticField&) ](function_sensor__msgs_8hpp_1ab7d0c633feef63177c8dcf66ed056b67.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::NavSat&, sensor_msgs::msg::NavSatFix&) ](function_sensor__msgs_8hpp_1a63ba5bfc33e4d648d9ca3c474b58d0ed.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::PointCloudPacked&, sensor_msgs::msg::PointCloud2&) ](function_sensor__msgs_8hpp_1a5aa7fe55e4f62819d847135d36aeadc0.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::BatteryState&, sensor_msgs::msg::BatteryState&) ](function_sensor__msgs_8hpp_1a02fac2b96b5bc99782798ad0e462e12b.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Boolean&, std_msgs::msg::Bool&) ](function_std__msgs_8hpp_1a0ea77739113d67b840858b4aed2c1568.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Color&, std_msgs::msg::ColorRGBA&) ](function_std__msgs_8hpp_1afd91788a8635cd1f79e954f71c1acc81.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Empty&, std_msgs::msg::Empty&) ](function_std__msgs_8hpp_1af2b42120ff80998fd9fab0397f84fc4a.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::UInt32&, std_msgs::msg::UInt32&) ](function_std__msgs_8hpp_1a91416a18cdbec7a4566e806cb3c981d3.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Float&, std_msgs::msg::Float32&) ](function_std__msgs_8hpp_1ae578f0f95aed969a0945309f46403b1a.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Double&, std_msgs::msg::Float64&) ](function_std__msgs_8hpp_1a9e5c39b508c43bc2bb391f9cac82d0cb.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Header&, std_msgs::msg::Header&) ](function_std__msgs_8hpp_1a37333361146656f3a465597f0611384f.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Int32&, std_msgs::msg::Int32&) ](function_std__msgs_8hpp_1ac594a0ee0c20b5c2a9a4ecad76acab49.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::StringMsg&, std_msgs::msg::String&) ](function_std__msgs_8hpp_1a61d1d24ff68a20842f532855814df8f4.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Pose_V&, tf2_msgs::msg::TFMessage&) ](function_tf2__msgs_8hpp_1ab30fc972d5a5fb2cf0f002f0b0e1d7bd.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::JointTrajectoryPoint&, trajectory_msgs::msg::JointTrajectoryPoint&) ](function_trajectory__msgs_8hpp_1abd71f7a74996c12d3dec6919e78b8e13.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::JointTrajectory&, trajectory_msgs::msg::JointTrajectory&) ](function_trajectory__msgs_8hpp_1ace7940f46c2554456ad36cbdd91be7cf.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::AnnotatedAxisAligned2DBox&, vision_msgs::msg::Detection2D&) ](function_vision__msgs_8hpp_1a9b399bcceccdf5c105e25e04e1564ec7.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::AnnotatedAxisAligned2DBox_V&, vision_msgs::msg::Detection2DArray&) ](function_vision__msgs_8hpp_1a77e10c6f8ed2e6c1afb76a59da51ae24.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::AnnotatedOriented3DBox&, vision_msgs::msg::Detection3D&) ](function_vision__msgs_8hpp_1a15f7378e58a45c461c491ec758e04e30.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::AnnotatedOriented3DBox_V&, vision_msgs::msg::Detection3DArray&) ](function_vision__msgs_8hpp_1a2d3556617aaeed0d71f65eeff2465dee.html)
        * [ Template Function ros_gz_bridge::convert_gz_to_ros(const GZ_T&, ROS_T&) ](function_convert__decl_8hpp_1a79659ef265605c411ee3931796f28382.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const actuator_msgs::msg::Actuators&, gz::msgs::Actuators&) ](function_actuator__msgs_8hpp_1aad53adb1610b0024647b9dda0bd793cb.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const builtin_interfaces::msg::Time&, gz::msgs::Time&) ](function_builtin__interfaces_8hpp_1aa206eb9e91272b64fd4a62fae6fab6a9.html)


ROS 2 Parameters:


_See[ ROS Wiki Tutorials ](http://wiki.ros.org/ros_gz_bridge/Tutorials) for
more details. _


In this example, we're going to generate Gazebo Transport images using Gazebo
Sim, that will be converted into ROS images, and visualized with `
rqt_image_viewer ` .


The example's code can be found under ` ros_gz_bridge/src/static_bridge.cpp `
. In the code, it's possible to see how the bridge is hardcoded to bridge
string messages published on the ` /chatter ` topic.


In another terminal launch an Gazebo Sim world, for example the empty.sdf world:


#  Integration between ROS and Gazebo
##  Packages
This repository holds packages that provide integration between [ ROS
](http://www.ros.org/) and [ Gazebo ](https://gazebosim.org) :
  * [ ros_gz ](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz) : Metapackage which provides all the other packages.
  * [ ros_gz_image ](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_image) : Unidirectional transport bridge for images from [ Gazebo Transport ](https://gazebosim.org/libs/transport) to ROS using [ image_transport ](http://wiki.ros.org/image_transport) .
  * [ ros_gz_bridge ](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_bridge) : Bidirectional transport bridge between [ Gazebo Transport ](https://gazebosim.org/libs/transport) and ROS.
  * [ ros_gz_sim ](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_sim) : Convenient launch files and executables for using [ Gazebo Sim ](https://gazebosim.org/libs/gazebo) with ROS.
  * [ ros_gz_sim_demos ](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_sim_demos) : Demos using the ROS-Gazebo integration.
  * [ ros_gz_point_cloud ](https://github.com/gazebosim/ros_gz/tree/ros2/ros_gz_point_cloud) : Plugins for publishing point clouds to ROS from [ Gazebo Sim ](https://gazebosim.org/libs/gazebo) simulations.
##  Install
This branch supports ROS Humble. See above for other ROS versions.
###  Binaries
Humble binaries are available for Fortress. They are hosted at [
https://packages.ros.org ](https://packages.ros.org) .
  1. Add [ https://packages.ros.org ](https://packages.ros.org)

         sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
     curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
     sudo apt-get update

  2. Install ` ros_gz `

         sudo apt install ros-humble-ros-gz

###  From source
####  ROS
Be sure you've installed [ ROS Humble
](https://docs.ros.org/en/humble/Installation.html) (at least ROS-Base). More
ROS dependencies will be installed below.
####  Gazebo
Install either [ Edifice, Fortress, or Garden ](https://gazebosim.org/docs) .
Set the ` GZ_VERSION ` environment variable to the Gazebo version you'd like
to compile against. For example:

    export GZ_VERSION=edifice # IMPORTANT: Replace with correct version

> You only need to set this variable when compiling, not when running.
####  Compile ros_gz
The following steps are for Linux and OSX.
  1. Create a colcon workspace:

        # Setup the workspace


Start the parameter bridge which will watch the specified topics.


ros_gz_interfaces/msg/SensorNoise  |  ignition::msgs::SensorNoise
ros_gz_interfaces/msg/StringVec  |  ignition::msgs::StringMsg_V
ros_gz_interfaces/msg/TrackVisual  |  ignition::msgs::TrackVisual
ros_gz_interfaces/msg/VideoRecord  |  ignition::msgs::VideoRecord
ros_gz_interfaces/msg/WorldControl  |  ignition::msgs::WorldControl
rosgraph_msgs/msg/Clock  |  ignition::msgs::Clock
sensor_msgs/msg/BatteryState  |  ignition::msgs::BatteryState
sensor_msgs/msg/CameraInfo  |  ignition::msgs::CameraInfo
sensor_msgs/msg/FluidPressure  |  ignition::msgs::FluidPressure
sensor_msgs/msg/Imu  |  ignition::msgs::IMU
sensor_msgs/msg/Image  |  ignition::msgs::Image
sensor_msgs/msg/JointState  |  ignition::msgs::Model
sensor_msgs/msg/Joy  |  ignition::msgs::Joy
sensor_msgs/msg/LaserScan  |  ignition::msgs::LaserScan
sensor_msgs/msg/MagneticField  |  ignition::msgs::Magnetometer
sensor_msgs/msg/NavSatFix  |  ignition::msgs::NavSat
sensor_msgs/msg/PointCloud2  |  ignition::msgs::PointCloudPacked
tf2_msgs/msg/TFMessage  |  ignition::msgs::Pose_V
trajectory_msgs/msg/JointTrajectory  |  ignition::msgs::JointTrajectory
vision_msgs/msg/Detection3D  |  ignition::msgs::AnnotatedOriented3DBox
vision_msgs/msg/Detection3DArray  |  ignition::msgs::AnnotatedOriented3DBox_V

And the following for services:


Failed to get question list, you can ticket an issue [ here
](https://github.com/ros-infrastructure/rosindex/issues/new)


####  Additional Links


        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::Quaternion&, gz::msgs::Quaternion&) ](function_geometry__msgs_8hpp_1a3e40d6f365ed9898140db9df4fbd2d8f.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::Vector3&, gz::msgs::Vector3d&) ](function_geometry__msgs_8hpp_1ac2e5b034392611b1c5b81858e2b8e592.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::Point&, gz::msgs::Vector3d&) ](function_geometry__msgs_8hpp_1a38627186677c7ea030a08ab3262cb110.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::Pose&, gz::msgs::Pose&) ](function_geometry__msgs_8hpp_1a469328996890fe59eda54c9367a5ff6d.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::PoseArray&, gz::msgs::Pose_V&) ](function_geometry__msgs_8hpp_1ae95f8912394310a7443473d226f2cb6d.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::PoseWithCovariance&, gz::msgs::PoseWithCovariance&) ](function_geometry__msgs_8hpp_1a376b7c498501e314943288798bf6e2b1.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::PoseStamped&, gz::msgs::Pose&) ](function_geometry__msgs_8hpp_1a47fac246c5d07f737de342d26466a8fa.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::Transform&, gz::msgs::Pose&) ](function_geometry__msgs_8hpp_1ab99019265916ddecf8cf356078ae56eb.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::TransformStamped&, gz::msgs::Pose&) ](function_geometry__msgs_8hpp_1acf8884526b7424b468e56329f8ea1de6.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::Twist&, gz::msgs::Twist&) ](function_geometry__msgs_8hpp_1acd0f422232e454f95e27dcbbc42c1d43.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::TwistStamped&, gz::msgs::Twist&) ](function_geometry__msgs_8hpp_1a3861bad517173929e1969252cbd5f548.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::TwistWithCovariance&, gz::msgs::TwistWithCovariance&) ](function_geometry__msgs_8hpp_1a10e4de653eb0f6b053fd9787a86a90d0.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::TwistWithCovarianceStamped&, gz::msgs::TwistWithCovariance&) ](function_geometry__msgs_8hpp_1ac772b24c986dd67543ca2879dc9fbd51.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::Wrench&, gz::msgs::Wrench&) ](function_geometry__msgs_8hpp_1af79c552db4fb670bf13305bda418b821.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const geometry_msgs::msg::WrenchStamped&, gz::msgs::Wrench&) ](function_geometry__msgs_8hpp_1af3ad1f7e7ab748148d893ad52e58e21c.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const nav_msgs::msg::Odometry&, gz::msgs::Odometry&) ](function_nav__msgs_8hpp_1aa70a1c87be5af446384e2677df7be457.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const nav_msgs::msg::Odometry&, gz::msgs::OdometryWithCovariance&) ](function_nav__msgs_8hpp_1ac35a07b340c79a07b6c665798528138f.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const rcl_interfaces::msg::ParameterValue&, gz::msgs::Any&) ](function_rcl__interfaces_8hpp_1a4033fbac984c7315d9c1cc988b083b48.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::JointWrench&, gz::msgs::JointWrench&) ](function_ros__gz__interfaces_8hpp_1a345509379758dc71462bc86c50a08411.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::Altimeter&, gz::msgs::Altimeter&) ](function_ros__gz__interfaces_8hpp_1aace8c358934ecaaf801f4f36a8679aa0.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::Entity&, gz::msgs::Entity&) ](function_ros__gz__interfaces_8hpp_1a9e3146898f488e76028615bf1e0d219a.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::Contact&, gz::msgs::Contact&) ](function_ros__gz__interfaces_8hpp_1abec84c39945440b7a1ec1896c0fa96b3.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::Contacts&, gz::msgs::Contacts&) ](function_ros__gz__interfaces_8hpp_1a46c5466e4ecfc7ca19974974561c6a91.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::GuiCamera&, gz::msgs::GUICamera&) ](function_ros__gz__interfaces_8hpp_1a4afa302df866a24d6083edad7a02e00c.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::Light&, gz::msgs::Light&) ](function_ros__gz__interfaces_8hpp_1a1e09401dce4a824ba2d3bf5d4d9aef38.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::SensorNoise&, gz::msgs::SensorNoise&) ](function_ros__gz__interfaces_8hpp_1a7a436c22ef4a67e8b1f9bdd121a1bdc8.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::StringVec&, gz::msgs::StringMsg_V&) ](function_ros__gz__interfaces_8hpp_1a1a31b8bfcfddffaf49a33c98b2026b2c.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::ParamVec&, gz::msgs::Param&) ](function_ros__gz__interfaces_8hpp_1ae2e16545208bc4946e84e1e826f04a3c.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::ParamVec&, gz::msgs::Param_V&) ](function_ros__gz__interfaces_8hpp_1a8742837590e03877f02be29b9abc8e75.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::TrackVisual&, gz::msgs::TrackVisual&) ](function_ros__gz__interfaces_8hpp_1a02e058ff8cea786a75e6945baeca9091.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::VideoRecord&, gz::msgs::VideoRecord&) ](function_ros__gz__interfaces_8hpp_1ad094010d4509cf1b134d233c6e5f9648.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::WorldControl&, gz::msgs::WorldControl&) ](function_ros__gz__interfaces_8hpp_1a9d5471938f0476876f48c8cd08061986.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::WorldReset&, gz::msgs::WorldReset&) ](function_ros__gz__interfaces_8hpp_1a4ea736961df7bacf26f6bc13d000cbc9.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const ros_gz_interfaces::msg::Float32Array&, gz::msgs::Float_V&) ](function_ros__gz__interfaces_8hpp_1a7281948b39d32ae26dfa857971f45a65.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const rosgraph_msgs::msg::Clock&, gz::msgs::Clock&) ](function_rosgraph__msgs_8hpp_1af0fca163e9b84541378031817252614b.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::Joy&, gz::msgs::Joy&) ](function_sensor__msgs_8hpp_1add5c1ab23d6e64260c0eefd159c650e3.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::FluidPressure&, gz::msgs::FluidPressure&) ](function_sensor__msgs_8hpp_1a663a67317685b7e375f9d190d6b5d120.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::Image&, gz::msgs::Image&) ](function_sensor__msgs_8hpp_1a8c688fbd13c8b92c26cd673527c506e8.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::CameraInfo&, gz::msgs::CameraInfo&) ](function_sensor__msgs_8hpp_1a01092fae1b26cfd7aa8ece1a02c97c0a.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::Imu&, gz::msgs::IMU&) ](function_sensor__msgs_8hpp_1a59b477934db5a765c6e18937d1387419.html)


####  Authors


Protected Functions


_Not currently indexed._


ros2 run ros_gz_bridge parameter_bridge --ros-args -p config_file:=$WORKSPACE/ros_gz/ros_gz_bridge/test/config/full.yaml


##  Example 1a: Gazebo Transport talker and ROS 2 listener


    # Shell B:
    ign topic -e -t /chatter


Now it's your turn! Try to send data from ROS to Gazebo. You can also try different data types and different directions of communication.


    # Shell B:
    . /opt/ros/humble/setup.bash
    ros2 topic echo /chatter


**config** â **[in]** Parameters to control creation of a new bridge


    # Shell A:
    . ~/bridge_ws/install/setup.bash
    ros2 run ros_gz_bridge parameter_bridge /chatter@std_msgs/msg/String@ignition.msgs.StringMsg


_No plugins found._


Now we start the ROS talker.


[ Previous ](structros__gz__bridge_1_1BridgeConfig.html "Struct BridgeConfig")
[ Next  ](enum_bridge__config_8hpp_1abab542e6fa8d45d6d5e1b26f5ac2f593.html
"Enum BridgeDirection")


std  ::  shared_ptr  < gz  ::  transport  ::  Node  > gz_node_  ï


The configuration file must be a YAML array of maps. An example configuration
for 5 bridges is below, showing the various ways that a bridge may be
specified:


Visualize in RViz
Take a step further and try out demos from ros_gz_sim_demos.


ros2 service call /world/<world_name>/control ros_gz_interfaces/srv/ControlWorld "{world_control: {pause: false}}"


std  ::  vector  < std  ::  shared_ptr  < ros_gz_bridge  ::  BridgeHandle  > >
handles_  ï


On terminal B, start Gazebo, it will be paused by default:


    # Shell C:
    . /opt/ros/humble/setup.bash
    ros2 topic pub /chatter std_msgs/msg/String "data: 'Hi'" --once


explicit  RosGzBridge  (  const  rclcpp  ::  NodeOptions  & options  =  rclcpp
::  NodeOptions  (  )  )  ï


PACKAGECONFIG options  |

##  Sources


![](/assets/package.png) |


First we start Gazebo Sim (don't forget to hit play, or Gazebo Sim won't
generate any images).


_See[ ROS Wiki Tutorials ](http://wiki.ros.org/ros_gz_bridge/Tutorials) for
more details. _


Now we start the Gazebo Transport talker.


  * ` subscription_heartbeat ` \- Period at which the node checks for new subscribers for lazy bridges.
  * ` config_file ` \- YAML file to be loaded as the bridge configuration
  * ` expand_gz_topic_names ` \- Enable or disable ROS namespace applied on GZ topics.


* **gz_req_type_name** â **[in]** Gazebo service response type


ros2 run ros_gz_bridge parameter_bridge /keyboard/keypress@std_msgs/msg/Int32@gz.msgs.Int32
We started a bridge on /keyboard/keypress topic with message of type Int32. For ROS it is std_msgs/msg/Int32 and for Gazebo it is gz.msgs.Int32


**options** â **[in]** options control creation of the ROS 2 node


To run the bridge node with the above configuration:


    # Shell A:
    . ~/bridge_ws/install/setup.bash
    ros2 run ros_gz_bridge parameter_bridge /chatter@std_msgs/msg/String@ignition.msgs.StringMsg


__ [ ros_gz_bridge ](../index.html)


[ .github ](/gazebosim/ros_gz/tree/humble/.github ".github")
|
###
[ .github ](/gazebosim/ros_gz/tree/humble/.github ".github")
|
|

###
[ ros_gz ](/gazebosim/ros_gz/tree/humble/ros_gz "ros_gz")
|
###
[ ros_gz ](/gazebosim/ros_gz/tree/humble/ros_gz "ros_gz")
|
|

###
[ ros_gz_bridge ](/gazebosim/ros_gz/tree/humble/ros_gz_bridge "ros_gz_bridge")
|
###
[ ros_gz_bridge ](/gazebosim/ros_gz/tree/humble/ros_gz_bridge "ros_gz_bridge")
|
|

###
[ ros_gz_image ](/gazebosim/ros_gz/tree/humble/ros_gz_image "ros_gz_image")
|
###
[ ros_gz_image ](/gazebosim/ros_gz/tree/humble/ros_gz_image "ros_gz_image")
|
|

###
[ ros_gz_interfaces ](/gazebosim/ros_gz/tree/humble/ros_gz_interfaces
"ros_gz_interfaces")
|
###
[ ros_gz_interfaces ](/gazebosim/ros_gz/tree/humble/ros_gz_interfaces
"ros_gz_interfaces")
|
|


Deps  |  |  Name  |  [ ](/p/ament_cmake#humble-deps) |  [ 1
](/packages/ament_cmake) |  [ ament_cmake ](/p/ament_cmake#humble)
---|---|---
[ ](/p/ament_cmake_gtest#humble-deps) |  [ 1 ](/packages/ament_cmake_gtest) |
[ ament_cmake_gtest ](/p/ament_cmake_gtest#humble)
[ ](/p/ament_lint_auto#humble-deps) |  [ 1 ](/packages/ament_lint_auto) |  [
ament_lint_auto ](/p/ament_lint_auto#humble)
[ ](/p/ament_lint_common#humble-deps) |  [ 1 ](/packages/ament_lint_common) |
[ ament_lint_common ](/p/ament_lint_common#humble)
[ ](/p/launch_testing_ament_cmake#humble-deps) |  [ 1
](/packages/launch_testing_ament_cmake) |  [ launch_testing_ament_cmake
](/p/launch_testing_ament_cmake#humble)
[ ](/p/launch_ros#humble-deps) |  [ 2 ](/packages/launch_ros) |  [ launch_ros
](/p/launch_ros#humble)
[ ](/p/launch_testing#humble-deps) |  [ 1 ](/packages/launch_testing) |  [
launch_testing ](/p/launch_testing#humble)
[ ](/p/actuator_msgs#humble-deps) |  [ 1 ](/packages/actuator_msgs) |  [
actuator_msgs ](/p/actuator_msgs#humble)
[ ](/p/geometry_msgs#humble-deps) |  [ 2 ](/packages/geometry_msgs) |  [
geometry_msgs ](/p/geometry_msgs#humble)
[ ](/p/nav_msgs#humble-deps) |  [ 2 ](/packages/nav_msgs) |  [ nav_msgs
](/p/nav_msgs#humble)
[ ](/p/rclcpp#humble-deps) |  [ 1 ](/packages/rclcpp) |  [ rclcpp
](/p/rclcpp#humble)
[ ](/p/rclcpp_components#humble-deps) |  [ 1 ](/packages/rclcpp_components) |
[ rclcpp_components ](/p/rclcpp_components#humble)
[ ](/p/ros_gz_interfaces#humble-deps) |  [ 1 ](/packages/ros_gz_interfaces) |
[ ros_gz_interfaces ](/p/ros_gz_interfaces#humble)
[ ](/p/rosgraph_msgs#humble-deps) |  [ 3 ](/packages/rosgraph_msgs) |  [
rosgraph_msgs ](/p/rosgraph_msgs#humble)
[ ](/p/sensor_msgs#humble-deps) |  [ 2 ](/packages/sensor_msgs) |  [
sensor_msgs ](/p/sensor_msgs#humble)
[ ](/p/std_msgs#humble-deps) |  [ 2 ](/packages/std_msgs) |  [ std_msgs
](/p/std_msgs#humble)
[ ](/p/tf2_msgs#humble-deps) |  [ 3 ](/packages/tf2_msgs) |  [ tf2_msgs
](/p/tf2_msgs#humble)
[ ](/p/trajectory_msgs#humble-deps) |  [ 2 ](/packages/trajectory_msgs) |  [
trajectory_msgs ](/p/trajectory_msgs#humble)
[ ](/p/yaml_cpp_vendor#humble-deps) |  [ 1 ](/packages/yaml_cpp_vendor) |  [
yaml_cpp_vendor ](/p/yaml_cpp_vendor#humble)


No version for distro **foxy** . Known supported distros are highlighted in
the buttons above.


##  0.244.14 (2024-04-08)


CHANGELOG


Name  |  Repo  |  Deps  |  [ leo_gz_bringup ](/p/leo_gz_bringup/github-
LeoRover-leo_simulator-ros2#humble) |  [ github-LeoRover-leo_simulator-ros2
](/r/leo_simulator/github-LeoRover-leo_simulator-ros2) |  [
](/p/leo_gz_bringup/github-LeoRover-leo_simulator-ros2#humble-deps)
---|---|---
[ rmf_demos_gz ](/p/rmf_demos_gz/github-open-rmf-rmf_demos#humble) |  [
github-open-rmf-rmf_demos ](/r/rmf_demos/github-open-rmf-rmf_demos) |  [
](/p/rmf_demos_gz/github-open-rmf-rmf_demos#humble-deps)
[ ros_gz ](/p/ros_gz/github-gazebosim-ros_gz#humble) |  [ github-gazebosim-
ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [ ](/p/ros_gz/github-gazebosim-
ros_gz#humble-deps)
[ ros_gz_image ](/p/ros_gz_image/github-gazebosim-ros_gz#humble) |  [ github-
gazebosim-ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [
](/p/ros_gz_image/github-gazebosim-ros_gz#humble-deps)
[ ros_gz_sim_demos ](/p/ros_gz_sim_demos/github-gazebosim-ros_gz#humble) |  [
github-gazebosim-ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [
](/p/ros_gz_sim_demos/github-gazebosim-ros_gz#humble-deps)
[ ros_ign_bridge ](/p/ros_ign_bridge/github-gazebosim-ros_gz#humble) |  [
github-gazebosim-ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [
](/p/ros_ign_bridge/github-gazebosim-ros_gz#humble-deps)
[ test_ros_gz_bridge ](/p/test_ros_gz_bridge/github-gazebosim-ros_gz#humble) |
[ github-gazebosim-ros_gz ](/r/ros_gz/github-gazebosim-ros_gz) |  [
](/p/test_ros_gz_bridge/github-gazebosim-ros_gz#humble-deps)
[ as2_gazebo_assets ](/p/as2_gazebo_assets/github-
aerostack2-aerostack2#humble) |  [ github-aerostack2-aerostack2
](/r/aerostack2/github-aerostack2-aerostack2) |  [
](/p/as2_gazebo_assets/github-aerostack2-aerostack2#humble-deps)

###  Launch files


Now we start the ROS GUI:


` ros2 topic echo /chatter std_msgs/msg/String `


    # Shell C:
    ign topic -t /chatter -m ignition.msgs.StringMsg -p 'data:"Hello"'


And terminal C, publish an Gazebo message:


At this point, you should see the ROS 2 listener echoing the message.


[ ros_gz_bridge ](../index.html)


` ign topic -t /chatter -m ignition.msgs.StringMsg -p 'data:"Hello"' `


####  Additional Links


On the Gazebo window, press on the keyboard keys and you should find data on the listener terminal.


` ign topic -e -t /chatter `


  * Added conversion for Detection3D and Detection3DArray ( [ #523 ](https://github.com/gazebosim/ros_gz/issues/523) ) ( [ #526 ](https://github.com/gazebosim/ros_gz/issues/526) ) Co-authored-by: wittenator < [ 9154515+wittenator@users.noreply.github.com ](mailto:9154515+wittenator@users.noreply.github.com) >
  * Add ROS namespaces to GZ topics ( [ #512 ](https://github.com/gazebosim/ros_gz/issues/512) ) Co-authored-by: Alejandro Hern


The example's code can be found under ` ros_gz_bridge/src/static_bridge.cpp `
. In the code, it's possible to see how the bridge is hardcoded to bridge
string messages published on the ` /chatter ` topic.


  * [ master ](/layerindex/branch/master/layers/)
  * [ meta-ros2-humble ](/layerindex/branch/master/layer/meta-ros2-humble/)
  * ros-gz-bridge


[ API Docs ](http://docs.ros.org/en/rolling/p/ros_gz_bridge "View API
documentation on docs.ros.org") [ Browse Code
](https://github.com/gazebosim/ros_gz/tree/humble/ros_gz_bridge "View source
code on repository")


By default, the Bridge will not apply ROS namespace on the Gazebo topics. To
enable this feature, use parameter ` expand_gz_topic_names ` . Let's test our
topic with namespace:


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) .


**Tags** |  _No category tags._
---|---
**Version** |  0.244.14
**License** |  Apache 2.0
**Build type** |  AMENT_CMAKE
**Use** |  RECOMMENDED

###  Repository Summary


No questions yet, you can ask one [ here
](https://robotics.stackexchange.com/questions/tagged/ros_gz_bridge+humble) .


For more details on implementation of this demo see ROS 2 Interoperability.


ros_gz_interfaces/msg/SensorNoise  |  ignition::msgs::SensorNoise
ros_gz_interfaces/msg/StringVec  |  ignition::msgs::StringMsg_V
ros_gz_interfaces/msg/TrackVisual  |  ignition::msgs::TrackVisual
ros_gz_interfaces/msg/VideoRecord  |  ignition::msgs::VideoRecord
ros_gz_interfaces/msg/WorldControl  |  ignition::msgs::WorldControl
rosgraph_msgs/msg/Clock  |  ignition::msgs::Clock
sensor_msgs/msg/BatteryState  |  ignition::msgs::BatteryState
sensor_msgs/msg/CameraInfo  |  ignition::msgs::CameraInfo
sensor_msgs/msg/FluidPressure  |  ignition::msgs::FluidPressure
sensor_msgs/msg/Imu  |  ignition::msgs::IMU
sensor_msgs/msg/Image  |  ignition::msgs::Image
sensor_msgs/msg/JointState  |  ignition::msgs::Model
sensor_msgs/msg/Joy  |  ignition::msgs::Joy
sensor_msgs/msg/LaserScan  |  ignition::msgs::LaserScan
sensor_msgs/msg/MagneticField  |  ignition::msgs::Magnetometer
sensor_msgs/msg/NavSatFix  |  ignition::msgs::NavSat
sensor_msgs/msg/PointCloud2  |  ignition::msgs::PointCloudPacked
tf2_msgs/msg/TFMessage  |  ignition::msgs::Pose_V
trajectory_msgs/msg/JointTrajectory  |  ignition::msgs::JointTrajectory
vision_msgs/msg/Detection3D  |  ignition::msgs::AnnotatedOriented3DBox
vision_msgs/msg/Detection3DArray  |  ignition::msgs::AnnotatedOriented3DBox_V

And the following for services:


You should see the Gazebo listener echoing the message.


  * ` subscription_heartbeat ` \- Period at which the node checks for new subscribers for lazy bridges.
  * ` config_file ` \- YAML file to be loaded as the bridge configuration
  * ` expand_gz_topic_names ` \- Enable or disable ROS namespace applied on GZ topics.


It's possible to make ROS service requests into Gazebo. Let's try unpausing
the simulation.


Now we start the ROS listener.


![](/assets/package.png) |


[ ros-infrastructure/rosindex  ](https://github.com/ros-
infrastructure/rosindex "Find rosindex in Github") | _generated on 2024-04-09_


    # Shell C:
    . /opt/ros/humble/setup.bash
    ros2 run rqt_image_view rqt_image_view /rgbd_camera/image


* [ github-gazebosim-ros_gz ](/p/ros_gz_bridge/github-gazebosim-ros_gz)


##  Example 2: Run the bridge and exchange images


First we will start a bridge between ROS and Gazebo specifying the topic at which the Key Publisher plugin sends messages and also the type of the messages as follows:


Branch  |  Recipe
---|---
master  |  ros-gz-bridge 0.244.12-1 (this recipe)
nanbield (Yocto Project 4.3)  |  [ ros-gz-bridge 0.244.12-1
](/layerindex/recipe/390836/)
mickledore (Yocto Project 4.2)  |  [ ros-gz-bridge
](/layerindex/recipe/392191/)
langdale (Yocto Project 4.1)  |  [ ros-gz-bridge ](/layerindex/recipe/393546/)
kirkstone (Yocto Project 4.0)  |  [ ros-gz-bridge 0.244.13-1
](/layerindex/recipe/394901/)

* * *


_No message files found._


**Checkout URI** |  [ https://github.com/gazebosim/ros_gz.git
](https://github.com/gazebosim/ros_gz.git)
---|---
**VCS Type** |  git
**VCS Version** |  humble
**Last Updated**

2024-04-08  |  **Dev Status** |  MAINTAINED
**CI status** |  No Continuous Integration
**Released** |  RELEASED
**Tags** |  _No category tags._
**Contributing** |  [ Help Wanted (  0  ) ](/r/ros_gz/#humble-contribute-
lists-help-wanted)
[ Good First Issues (  0  ) ](/r/ros_gz/#humble-contribute-lists-good-first-
issue)
[ Pull Requests to Review (  0  ) ](/r/ros_gz/#humble-contribute-lists-pull-
requests)

###  Package Description


Let's see the topic where camera images are published.


Now we start the Gazebo Transport listener.


Example uses of the bridge can be found in ros_gz_sim_demos, including demo launch files with bridging of all major actuation and sensor types.


###  [ ros_gz_bridge ](/p/ros_gz_bridge) package from [ ros_gz
](/r/ros_gz/github-gazebosim-ros_gz) repo


` ign topic -t /chatter -m ignition.msgs.StringMsg -p 'data:"Hello"' `


No version for distro **jade** . Known supported distros are highlighted in
the buttons above.


First we start Gazebo Sim (don't forget to hit play, or Gazebo Sim won't
generate any images).


_No launch files found_


The screenshot shows all the shell windows and their expected content (it was
taken using ROS 2 Galactic and Gazebo Fortress):


###
[ README.md ](/gazebosim/ros_gz/blob/humble/README.md "README.md")
|
###
[ README.md ](/gazebosim/ros_gz/blob/humble/README.md "README.md")
|
|

###
[ README_RENAME.md ](/gazebosim/ros_gz/blob/humble/README_RENAME.md
"README_RENAME.md")
|
###
[ README_RENAME.md ](/gazebosim/ros_gz/blob/humble/README_RENAME.md
"README_RENAME.md")
|
|

###
[ RELEASING.md ](/gazebosim/ros_gz/blob/humble/RELEASING.md "RELEASING.md")
|
###
[ RELEASING.md ](/gazebosim/ros_gz/blob/humble/RELEASING.md "RELEASING.md")
|
|

View all files

##  Repository files navigation
  * README
  * License
[ ![Build
Status](https://github.com/gazebosim/ros_gz/actions/workflows/ros2-ci.yml/badge.svg?branch=ros2)
](https://github.com/gazebosim/ros_gz/actions/workflows/ros2-ci.yml)
ROS 2 version  |  Gazebo version  |  Branch  |  Binaries hosted at
---|---|---|---
Foxy  |  Citadel  |  [ foxy ](https://github.com/gazebosim/ros_gz/tree/foxy) |
[ https://packages.ros.org ](https://packages.ros.org)
Foxy  |  Edifice  |  [ foxy ](https://github.com/gazebosim/ros_gz/tree/foxy) |


On terminal B, start Gazebo, it will be paused by default:


Pointer to Gazebo node used to create publishers/subscribers.


**Tags** |  _No category tags._
---|---
**Version** |  0.244.14
**License** |  Apache 2.0
**Build type** |  AMENT_CMAKE
**Use** |  RECOMMENDED

###  Repository Summary


Now let's try the other way around, ROS 2 -> Gazebo.


It's possible to make ROS service requests into Gazebo. Let's try unpausing
the simulation.


You should see the Gazebo listener echoing the message.


  * Added conversion for Detection3D and Detection3DArray ( [ #523 ](https://github.com/gazebosim/ros_gz/issues/523) ) ( [ #526 ](https://github.com/gazebosim/ros_gz/issues/526) ) Co-authored-by: wittenator < [ 9154515+wittenator@users.noreply.github.com ](mailto:9154515+wittenator@users.noreply.github.com) >
  * Add ROS namespaces to GZ topics ( [ #512 ](https://github.com/gazebosim/ros_gz/issues/512) ) Co-authored-by: Alejandro Hern


And on terminal E, publish a ROS 2 message:


No version for distro **ardent** . Known supported distros are highlighted in
the buttons above.


    # Shell A:
    . ~/bridge_ws/install/setup.bash
    ros2 run ros_gz_bridge parameter_bridge chatter@std_msgs/msg/String@ignition.msgs.StringMsg \
      --ros-args -p expand_gz_topic_names:=true -r __ns:=/demo


On terminal C, make a ROS request to unpause simulation:


Start the parameter bridge which will watch the specified topics.


  * [ C++ API ](index.html)
    * [ Class Hierarchy ](index.html#class-hierarchy)
    * [ File Hierarchy ](index.html#file-hierarchy)
    * [ Full C++ API ](index.html#full-c-api)
      * [ Namespaces ](index.html#namespaces)
        * [ Namespace rclcpp ](namespace_rclcpp.html)
        * [ Namespace ros_gz_bridge ](namespace_ros_gz_bridge.html)
      * [ Classes and Structs ](index.html#classes-and-structs)
        * [ Struct BridgeConfig ](structros__gz__bridge_1_1BridgeConfig.html)
        * Class RosGzBridge
      * [ Enums ](index.html#enums)
        * [ Enum BridgeDirection ](enum_bridge__config_8hpp_1abab542e6fa8d45d6d5e1b26f5ac2f593.html)
      * [ Functions ](index.html#functions)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Actuators&, actuator_msgs::msg::Actuators&) ](function_actuator__msgs_8hpp_1a48301d94efafa3449e20ca22afad74d7.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Time&, builtin_interfaces::msg::Time&) ](function_builtin__interfaces_8hpp_1a8ad7cadc6f05cdbcb87f11c89c99c850.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Quaternion&, geometry_msgs::msg::Quaternion&) ](function_geometry__msgs_8hpp_1a573b590fe1f2df194bae7b96e1064acc.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Vector3d&, geometry_msgs::msg::Vector3&) ](function_geometry__msgs_8hpp_1a566ebb53c225d409340bd6d24b712ada.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Vector3d&, geometry_msgs::msg::Point&) ](function_geometry__msgs_8hpp_1ad11bd8e276c89590512721dbc381f398.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Pose&, geometry_msgs::msg::Pose&) ](function_geometry__msgs_8hpp_1abfb907f18367d15effa28726411f8e23.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Pose_V&, geometry_msgs::msg::PoseArray&) ](function_geometry__msgs_8hpp_1aa841b3577a5d8b4924215c3c4f92960a.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::PoseWithCovariance&, geometry_msgs::msg::PoseWithCovariance&) ](function_geometry__msgs_8hpp_1a8b12fd75b9d0877b9f8c0312486ed7ba.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Pose&, geometry_msgs::msg::PoseStamped&) ](function_geometry__msgs_8hpp_1ad12dbbe73bcd4aaff8deb650364f8763.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Pose&, geometry_msgs::msg::Transform&) ](function_geometry__msgs_8hpp_1ac10c69486bd94c50454d69c0aa7a012e.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Pose&, geometry_msgs::msg::TransformStamped&) ](function_geometry__msgs_8hpp_1ad0e887b5727a21d7e6b40a823e478aca.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Twist&, geometry_msgs::msg::Twist&) ](function_geometry__msgs_8hpp_1ac959c538e2848448b787bbda601f45b3.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Twist&, geometry_msgs::msg::TwistStamped&) ](function_geometry__msgs_8hpp_1a3c6e670d4d2354e384e8960b6d6b99a0.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::TwistWithCovariance&, geometry_msgs::msg::TwistWithCovariance&) ](function_geometry__msgs_8hpp_1af64cbc9a52d2d16011d6a7c7bd86202f.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::TwistWithCovariance&, geometry_msgs::msg::TwistWithCovarianceStamped&) ](function_geometry__msgs_8hpp_1ab7cf4187f1805d1b3c5ba24ad5868ddf.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Wrench&, geometry_msgs::msg::Wrench&) ](function_geometry__msgs_8hpp_1abef1ba032ebe4ae5e7e5dcb3aade392c.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Wrench&, geometry_msgs::msg::WrenchStamped&) ](function_geometry__msgs_8hpp_1a0c506b5398d73b1017d8c3f9c945fd85.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Odometry&, nav_msgs::msg::Odometry&) ](function_nav__msgs_8hpp_1a80afdda48776ced7d087a9b5eb0afd92.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::OdometryWithCovariance&, nav_msgs::msg::Odometry&) ](function_nav__msgs_8hpp_1a9d1190c639a858d256ef04183fdeb5e4.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Any&, rcl_interfaces::msg::ParameterValue&) ](function_rcl__interfaces_8hpp_1a932414925f78e5abc445d2c8cada98f6.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::JointWrench&, ros_gz_interfaces::msg::JointWrench&) ](function_ros__gz__interfaces_8hpp_1a51cd0e7b8d33227fc61b614fe87e2f7d.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Altimeter&, ros_gz_interfaces::msg::Altimeter&) ](function_ros__gz__interfaces_8hpp_1a873200fc64de3c457b8b39c9d396fff6.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Entity&, ros_gz_interfaces::msg::Entity&) ](function_ros__gz__interfaces_8hpp_1a375212bd7cac99f25a9f26535621f940.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Contact&, ros_gz_interfaces::msg::Contact&) ](function_ros__gz__interfaces_8hpp_1a20fdc4f995ea1b0b84d3753003d9582a.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Contacts&, ros_gz_interfaces::msg::Contacts&) ](function_ros__gz__interfaces_8hpp_1a3a7f99a3b9ba037cf2445e5f5f8b5e2c.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::GUICamera&, ros_gz_interfaces::msg::GuiCamera&) ](function_ros__gz__interfaces_8hpp_1a1b2ca16f79b44f76d05b5e48f68b1599.html)
        * [ Specialized Template Function ros_gz_bridge::convert_gz_to_ros(const gz::msgs::Light&, ros_gz_interfaces::msg::Light&) ](function_ros__gz__interfaces_8hpp_1a95de7a66a958c2f120f74a207ff83a25.html)


Now we start the ROS talker.


On terminal A, start the bridge:


#  ros-gz-bridge 0.244.12-1


Deps  |  |  Name  |  [ ](/p/ament_cmake#iron-deps) |  [ 1
](/packages/ament_cmake) |  [ ament_cmake ](/p/ament_cmake#iron)
---|---|---
[ ](/p/ament_cmake_gtest#iron-deps) |  [ 1 ](/packages/ament_cmake_gtest) |  [
ament_cmake_gtest ](/p/ament_cmake_gtest#iron)
[ ](/p/ament_lint_auto#iron-deps) |  [ 1 ](/packages/ament_lint_auto) |  [
ament_lint_auto ](/p/ament_lint_auto#iron)
[ ](/p/ament_lint_common#iron-deps) |  [ 1 ](/packages/ament_lint_common) |  [
ament_lint_common ](/p/ament_lint_common#iron)
[ ](/p/launch_testing_ament_cmake#iron-deps) |  [ 1
](/packages/launch_testing_ament_cmake) |  [ launch_testing_ament_cmake
](/p/launch_testing_ament_cmake#iron)
[ ](/p/launch_ros#iron-deps) |  [ 2 ](/packages/launch_ros) |  [ launch_ros
](/p/launch_ros#iron)
[ ](/p/launch_testing#iron-deps) |  [ 1 ](/packages/launch_testing) |  [
launch_testing ](/p/launch_testing#iron)
[ ](/p/actuator_msgs#iron-deps) |  [ 1 ](/packages/actuator_msgs) |  [
actuator_msgs ](/p/actuator_msgs#iron)
[ ](/p/geometry_msgs#iron-deps) |  [ 2 ](/packages/geometry_msgs) |  [
geometry_msgs ](/p/geometry_msgs#iron)
[ ](/p/nav_msgs#iron-deps) |  [ 2 ](/packages/nav_msgs) |  [ nav_msgs
](/p/nav_msgs#iron)
[ ](/p/rclcpp#iron-deps) |  [ 1 ](/packages/rclcpp) |  [ rclcpp
](/p/rclcpp#iron)
[ ](/p/rclcpp_components#iron-deps) |  [ 1 ](/packages/rclcpp_components) |  [
rclcpp_components ](/p/rclcpp_components#iron)
[ ](/p/ros_gz_interfaces#iron-deps) |  [ 1 ](/packages/ros_gz_interfaces) |  [
ros_gz_interfaces ](/p/ros_gz_interfaces#iron)
[ ](/p/rosgraph_msgs#iron-deps) |  [ 3 ](/packages/rosgraph_msgs) |  [
rosgraph_msgs ](/p/rosgraph_msgs#iron)
[ ](/p/sensor_msgs#iron-deps) |  [ 2 ](/packages/sensor_msgs) |  [ sensor_msgs
](/p/sensor_msgs#iron)
[ ](/p/std_msgs#iron-deps) |  [ 2 ](/packages/std_msgs) |  [ std_msgs
](/p/std_msgs#iron)
[ ](/p/tf2_msgs#iron-deps) |  [ 3 ](/packages/tf2_msgs) |  [ tf2_msgs
](/p/tf2_msgs#iron)
[ ](/p/trajectory_msgs#iron-deps) |  [ 2 ](/packages/trajectory_msgs) |  [
trajectory_msgs ](/p/trajectory_msgs#iron)
[ ](/p/yaml_cpp_vendor#iron-deps) |  [ 1 ](/packages/yaml_cpp_vendor) |  [
yaml_cpp_vendor ](/p/yaml_cpp_vendor#iron)


Bridge communication between ROS and Gazebo Transport


In another terminal, send either ROS or Gazebo commands for the vehicle to move in circles:


` ros2 run ros_gz_bridge static_bridge `


###  Wiki Tutorials


##  Example 3: Static bridge


* Louise Poubel


---

[
API Docs ](http://docs.ros.org/en/rolling/p/ros_gz_bridge "View API
documentation on docs.ros.org") [
Browse Code ](https://github.com/gazebosim/ros_gz/tree/humble/ros_gz_bridge
"View source code on repository")


std  ::  vector  < rclcpp  ::  ServiceBase  ::  SharedPtr  > services_  ï


###  Messages


[ ros_gz ](/p/ros_gz/github-gazebosim-ros_gz) ros_gz_bridge  [ ros_gz_image
](/p/ros_gz_image/github-gazebosim-ros_gz) [ ros_gz_interfaces
](/p/ros_gz_interfaces/github-gazebosim-ros_gz) [ ros_gz_point_cloud
](/p/ros_gz_point_cloud/github-gazebosim-ros_gz) [ ros_gz_sim
](/p/ros_gz_sim/github-gazebosim-ros_gz) [ ros_gz_sim_demos
](/p/ros_gz_sim_demos/github-gazebosim-ros_gz) [ ros_ign ](/p/ros_ign/github-
gazebosim-ros_gz) [ ros_ign_bridge ](/p/ros_ign_bridge/github-gazebosim-
ros_gz) [ ros_ign_gazebo ](/p/ros_ign_gazebo/github-gazebosim-ros_gz) [
ros_ign_gazebo_demos ](/p/ros_ign_gazebo_demos/github-gazebosim-ros_gz) [
ros_ign_image ](/p/ros_ign_image/github-gazebosim-ros_gz) [ ros_ign_interfaces
](/p/ros_ign_interfaces/github-gazebosim-ros_gz) [ test_ros_gz_bridge
](/p/test_ros_gz_bridge/github-gazebosim-ros_gz)
---|---

github-gazebosim-ros_gz


In this example, we're going to run an executable that starts a bidirectional
bridge for a specific topic and message type. We'll use the ` static_bridge `
executable that is installed with the bridge.


    # Shell B:
    . /opt/ros/humble/setup.bash
    ros2 topic echo /chatter


###  [ ros_gz_bridge ](/p/ros_gz_bridge) package from [ ros_gz
](/r/ros_gz/github-gazebosim-ros_gz) repo


##  API


void  add_service_bridge  (  const  std  ::  string  & ros_type_name  ,  const
std  ::  string  & gz_req_type_name  ,  const  std  ::  string  &
gz_rep_type_name  ,  const  std  ::  string  & service_name  )  ï


List of bridge handles.


Parameters  :


[ git://github.com/ros2-gbp/ros_ign-release
](https://github.com/ros2-gbp/ros_ign-release)
---

##  Patches


For example:


  * [ ](../index.html)
  * [ C++ API ](index.html)
  * Class RosGzBridge
  * [ View page source ](../_sources/generated/classros__gz__bridge_1_1RosGzBridge.rst.txt)


##  Other branches


* Defined in [ File ros_gz_bridge.hpp  ](file__tmp_ws_src_ros_gz_ros_gz_bridge_include_ros_gz_bridge_ros_gz_bridge.hpp.html#file-tmp-ws-src-ros-gz-ros-gz-bridge-include-ros-gz-bridge-ros-gz-bridge-hpp)


####  Package Summary


* **gz_req_type_name** â **[in]** Gazebo service request type


_No service files found_


void  spin  (  )  ï


[ API Docs ](http://docs.ros.org/en/humble/p/ros_gz_bridge "View API
documentation on docs.ros.org") [ Browse Code
](https://github.com/gazebosim/ros_gz/tree/humble/ros_gz_bridge "View source
code on repository")


        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::JointState&, gz::msgs::Model&) ](function_sensor__msgs_8hpp_1a027fbe248218503dfb8b6ead28efddd8.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::LaserScan&, gz::msgs::LaserScan&) ](function_sensor__msgs_8hpp_1a9fbb1588ca40cbe1ecd3a0be7cc3f072.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::MagneticField&, gz::msgs::Magnetometer&) ](function_sensor__msgs_8hpp_1a7b5fb978106eb965a8900b2a65110cb8.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::NavSatFix&, gz::msgs::NavSat&) ](function_sensor__msgs_8hpp_1adaf30497b4dabfce10b42379845d2880.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::PointCloud2&, gz::msgs::PointCloudPacked&) ](function_sensor__msgs_8hpp_1a1838d56fa44172a454827be2686bd37f.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const sensor_msgs::msg::BatteryState&, gz::msgs::BatteryState&) ](function_sensor__msgs_8hpp_1a71427090968c70fa4124ba457147bb46.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::Bool&, gz::msgs::Boolean&) ](function_std__msgs_8hpp_1a80c90872022cda80be1d80ea0c1ecf5f.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::ColorRGBA&, gz::msgs::Color&) ](function_std__msgs_8hpp_1a2d96abc34ec3f0a75643f35c11dc0283.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::Empty&, gz::msgs::Empty&) ](function_std__msgs_8hpp_1aa6f196151bb1b1fd97e007dcb912d9cb.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::UInt32&, gz::msgs::UInt32&) ](function_std__msgs_8hpp_1ab329b3d02b1db28a24cb6e73efaac47e.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::Float32&, gz::msgs::Float&) ](function_std__msgs_8hpp_1a71f45f4b6f7050dd6eb81dcc90fe921a.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::Float64&, gz::msgs::Double&) ](function_std__msgs_8hpp_1a9ed1d1a25ec5b495bf2c4cda869b1086.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::Header&, gz::msgs::Header&) ](function_std__msgs_8hpp_1a193435f50be3bbf47ef424597d027557.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::Int32&, gz::msgs::Int32&) ](function_std__msgs_8hpp_1a456ad9210abcb2c836b5f0860bc1eea3.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const std_msgs::msg::String&, gz::msgs::StringMsg&) ](function_std__msgs_8hpp_1a0bc16cbb3b6d5fa4815be0d2be0fa9ec.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const tf2_msgs::msg::TFMessage&, gz::msgs::Pose_V&) ](function_tf2__msgs_8hpp_1a40089cb8eb6ad166ab1816dab52570c8.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const trajectory_msgs::msg::JointTrajectoryPoint&, gz::msgs::JointTrajectoryPoint&) ](function_trajectory__msgs_8hpp_1ac93e254730f21b4a0d6b63c79715e855.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const trajectory_msgs::msg::JointTrajectory&, gz::msgs::JointTrajectory&) ](function_trajectory__msgs_8hpp_1ae0e5304f51193d2e31aceb8e226d0001.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const vision_msgs::msg::Detection2D&, gz::msgs::AnnotatedAxisAligned2DBox&) ](function_vision__msgs_8hpp_1aa32f20ffb0c7be422e53340c16e7c9dc.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const vision_msgs::msg::Detection2DArray&, gz::msgs::AnnotatedAxisAligned2DBox_V&) ](function_vision__msgs_8hpp_1ac83a9a70d54196b633992f28e5769634.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const vision_msgs::msg::Detection3D&, gz::msgs::AnnotatedOriented3DBox&) ](function_vision__msgs_8hpp_1ab774e050eb2af8b36ab5c806d73fa690.html)
        * [ Specialized Template Function ros_gz_bridge::convert_ros_to_gz(const vision_msgs::msg::Detection3DArray&, gz::msgs::AnnotatedOriented3DBox_V&) ](function_vision__msgs_8hpp_1a734304539b37236ff0ff2a3ea111b34f.html)
        * [ Template Function ros_gz_bridge::convert_ros_to_gz(const ROS_T&, GZ_T&) ](function_convert__decl_8hpp_1a98acbfd7b25187c786429edc919799b7.html)
        * [ Function ros_gz_bridge::readFromYamlFile ](function_bridge__config_8hpp_1a3eaecbc7da7c2a4696787acdec1e0fdf.html)
        * [ Function ros_gz_bridge::readFromYamlString ](function_bridge__config_8hpp_1a551836da7e13373b15861b0453c77026.html)
      * [ Variables ](index.html#variables)
        * [ Variable ros_gz_bridge::kDefaultDirection ](variable_bridge__config_8hpp_1a5c96f9113ce782f6ddc781f1fc39865f.html)
        * [ Variable ros_gz_bridge::kDefaultLazy ](variable_bridge__config_8hpp_1ab4a1af23c48af03ab61740ef5de052fc.html)
        * [ Variable ros_gz_bridge::kDefaultPublisherQueue ](variable_bridge__config_8hpp_1ac6652574ba8f4471d47ccca3f279b462.html)
        * [ Variable ros_gz_bridge::kDefaultSubscriberQueue ](variable_bridge__config_8hpp_1a82e339d7124a5115d7b0c29f77982b09.html)
      * [ Directories ](index.html#directories)
        * [ Directory src ](dir__tmp_ws_src.html)
        * [ Directory ros_gz ](dir__tmp_ws_src_ros_gz.html)
        * [ Directory ros_gz_bridge ](dir__tmp_ws_src_ros_gz_ros_gz_bridge.html)
        * [ Directory include ](dir__tmp_ws_src_ros_gz_ros_gz_bridge_include.html)
        * [ Directory ros_gz_bridge ](dir__tmp_ws_src_ros_gz_ros_gz_bridge_include_ros_gz_bridge.html)
        * [ Directory convert ](dir__tmp_ws_src_ros_gz_ros_gz_bridge_include_ros_gz_bridge_convert.html)
      * [ Files ](index.html#files)
        * [ File actuator_msgs.hpp ](file__tmp_ws_src_ros_gz_ros_gz_bridge_include_ros_gz_bridge_convert_actuator_msgs.hpp.html)
        * [ File bridge_config.hpp ](file__tmp_ws_src_ros_gz_ros_gz_bridge_include_ros_gz_bridge_bridge_config.hpp.html)


##  Example 5: Configuring the Bridge via YAML


class  RosGzBridge  :  public  rclcpp  ::  Node  ï


    # Shell C:
    . /opt/ros/humble/setup.bash
    ros2 topic pub /chatter std_msgs/msg/String "data: 'Hi'" --once


void  add_bridge  (  const  [ BridgeConfig
](structros__gz__bridge_1_1BridgeConfig.html#_CPPv4N13ros_gz_bridge12BridgeConfigE
"ros_gz_bridge::BridgeConfig") & config  )  ï


Name  |  [ pkg-config ](/d/pkg-config)
---
[ gz-msgs9 ](/d/gz-msgs9)
[ gz-transport12 ](/d/gz-transport12)
[ ignition-msgs8 ](/d/ignition-msgs8)
[ ignition-transport11 ](/d/ignition-transport11)
[ ignition-msgs7 ](/d/ignition-msgs7)
[ ignition-transport10 ](/d/ignition-transport10)

###  Dependant Packages


#  Class RosGzBridge  ï


###  Recent questions tagged ` ros_gz_bridge ` at **[ Robotics Stack Exchange
](https://robotics.stackexchange.com/) **


On terminal D, start an Igntion listener:


##  Example 1b: ROS 2 talker and Gazebo Transport listener


Now we start the Gazebo Transport talker.


  * Overview
  * 0  Assets
  * 29  Dependencies
  * 0  Tutorials
  * 0  Q & A


On terminal A, start the bridge:


###  Source Tutorials


And terminal C, publish an Gazebo message:


Then we start the parameter bridge with the previous topic.


##  Example 6: Using ROS namespace with the Bridge


Let's see the topic where camera images are published.


Now let's try the other way around, ROS 2 -> Gazebo.


Start the parameter bridge which will watch the specified topics.


Now we start the ROS GUI:


[ OpenEmbedded Layer Index ](/layerindex/)


##  Example 3: Static bridge


Let's give it a try, starting with Gazebo -> ROS 2.


By default, the Bridge will not apply ROS namespace on the Gazebo topics. To
enable this feature, use parameter ` expand_gz_topic_names ` . Let's test our
topic with namespace:


    # Shell A:
    . ~/bridge_ws/install/setup.bash
    ros2 run ros_gz_bridge parameter_bridge /chatter@std_msgs/msg/String@ignition.msgs.StringMsg


###  Plugins


###  Services


By changing ` chatter ` to ` /chatter ` or ` ~/chatter ` you can obtain
different results.


The configuration file must be a YAML array of maps. An example configuration
for 5 bridges is below, showing the various ways that a bridge may be
specified:


_No message files found._


##  Class Documentation  ï


Add a new ROS-IGN bridge to the node.


    # Shell B:
    ign topic -e -t /chatter


    # Shell C:
    . /opt/ros/humble/setup.bash
    ros2 topic pub /demo/chatter std_msgs/msg/String "data: 'Hi from inside of a namespace'" --once


**Checkout URI** |  [ https://github.com/gazebosim/ros_gz.git
](https://github.com/gazebosim/ros_gz.git)
---|---
**VCS Type** |  git
**VCS Version** |  humble
**Last Updated**

2024-04-08  |  **Dev Status** |  MAINTAINED
**CI status** |  No Continuous Integration
**Released** |  RELEASED
**Tags** |  _No category tags._
**Contributing** |  [ Help Wanted (  0  ) ](/r/ros_gz/#iron-contribute-lists-
help-wanted)
[ Good First Issues (  0  ) ](/r/ros_gz/#iron-contribute-lists-good-first-
issue)
[ Pull Requests to Review (  0  ) ](/r/ros_gz/#iron-contribute-lists-pull-
requests)

###  Package Description