Gazebo | Ignition | Community
Ask Your Question

How do you use contact sensor to make a bridge from Gazebo to ROS2 ?

asked 2023-04-11 08:07:30 -0500

Mildred34 gravatar image

updated 2023-04-11 08:44:57 -0500


  • OS Version: Ubuntu 22.04 precisely using WSL2 through windows 10
  • Source or binary build? Source build, branch: ROS2 latest commit from Aditya Panda 22/03 with gazebo garden / Tried also the humble branch with gazebo fortress
  • ROS version: humble


  • Expected behavior: Doing a bridge from gz::msgs::Contact to ros_gz_interfaces/msg/Contact using or ignition::msgs::Contact to ros_gz_interfaces/msg/Contact depending of the gazebo version tested
  • Actual behavior: Last errors were: The bridge was launched but couldn't echocause of:

    ros2 topic echo \topic_name I received the error: The message type 'ros_gz_interfaces/msg/Contacts' is invalid

Mostly, the errors were:

[WARN] [1681217678.043852626] [ros_gz_bridge]: Failed to create a bridge for topic [/chatter] with ROS2 type [ros_gz_interfaces/msg/Contact] to topic [/chatter] with Gazebo Transport type [ignition.msgs.Contact]

Where the bridge didn't even start.

Steps to reproduce

  1. Install Gazebo Garden / Fortress
  2. Install ROS2 Humble
  3. Launch for instance (here with gazebo garden), commands change if fortress being used: gz sim shapes.sdf It will open Gazebo with simple sdf model. Actually, I'm using my own sdf, if you have your own it'll be better to ensure that in your sdf, you have the right plug-ins initialized. For instance, for the contact plug-in, i'm interested:

<!-- Contact plug-in --> <plugin filename="ignition-gazebo-contact-system" name="ignition::gazebo::systems::Contact"> </plugin> in fortress*


<!-- Contact plug-in --> <plugin filename="gz-sim-contact-system" name="gz::sim::systems::Contact"> </plugin> in garden

Written within the world scope. And:

<sensor name='object_contact_sensor' type='contact'> <contact> <collision>coude_collision</collision> </contact> </sensor>

Written within the link scope of the model I want the contacts. With coude_collision, the collision name of the link.

  1. Launch the bridge: ros2 run ros_gz_bridge parameter_bridge /chatter@ros_gz_interfaces/msg/Contacts[gz.msgs.Contacts Still using garden
  2. Launch an echo : ros2 topic echo --once /chatter

I can echo with gazebo like: gz topic -e -t topic_name But not with ROS2


Would give your more in depth output.

edit retag flag offensive close merge delete


Launching a bridge from a terminal is now working. I forgot, to source the ros_gz_interfaces after compiling it in the terminal I used for ros2 topic echo...

I added the source command inside my bashrc file ; will not forget it again x)

Mildred34 gravatar imageMildred34 ( 2023-04-12 03:32:10 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2023-04-11 15:37:51 -0500

azeey gravatar image

Looks like you haven't properly built ros_gz_interfaces, which is part of ros_gz. Have you followed these instructions for building ros_gz for Garden and ROS 2 Humble?

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2023-04-11 08:07:30 -0500

Seen: 227 times

Last updated: Apr 11