npx skills add smithery/mjunaidca --skill ros2-gazebo-bridge
mjunaidca/robolearn · Archived
ros2-gazebo-bridge
Configure ros_gz_bridge to connect Gazebo topics with ROS 2 for closed-loop control
Installation
npx skills add mjunaidca/robolearn --skill ros2-gazebo-bridge
Stronger alternatives
This repository is archived — consider an actively maintained alternative.
Configure camera, LIDAR, IMU, and contact sensors on simulated robots in Gazebo
1 installsComprehensive best practices, design patterns, and common pitfalls for ROS2 (Robot Operating Sy…
354 installsPatterns for developing robotics applications with ROS2 (Robot Operating System 2). Covers node…
261 installsBest practices for Docker-based ROS2 development including multi-stage Dockerfiles, docker-comp…
118 installsAlso in this package
Other skills from mjunaidca/robolearn.
npx skills add mjunaidca/robolearn
More details
Agent compatibility
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Also listed on
Alternate registries and mirrors of this skill.
Repository health
main
Skill metadata
Parsed from SKILL.md frontmatter.
Package contents
Files included with this skill beyond the listing page.
-
skill md
SKILL.md7,149 B -
docs
SUMMARY.md109 B
History
- First seen on skills.sh
- First recorded snapshot · 1 installs
SKILL.md
ROS 2 Gazebo Bridge Skill
Persona
Think like a robotics systems integrator who connects simulation to control systems. You understand message type mappings, topic naming conventions, and launch file orchestration. You create reliable bridges that enable seamless ROS 2 control of simulated robots.
Pre-Flight Questions
Before configuring any bridge, ask yourself:
1. Data Flow Direction
- Q: Which direction does data flow?
- ROSTOGZ: Commands from ROS 2 to simulation (cmdvel) - GZTO_ROS: Sensor data from simulation to ROS 2 (images, scans) - BIDIRECTIONAL: Both directions (rare, use sparingly)
2. Message Type Compatibility
- Q: Do ROS 2 and Gazebo message types match?
- Impact: Incompatible types cause silent failures - Always verify mapping exists in rosgzbridge
3. Topic Naming
- Q: Are topic names consistent across systems?
- Convention: Use same name for both sides when possible - Namespace: Use robot namespace for multi-robot
Principles
Principle 1: Bridge Syntax
Command-line format:
/TOPIC@ROS_MSG@GZ_MSG
Direction modifiers:
/TOPIC@ROS_MSG@GZ_MSG # Bidirectional (default)
/TOPIC@ROS_MSG[gz.msgs.X # GZ to ROS only
/TOPIC@ROS_MSG]gz.msgs.X # ROS to GZ only
Principle 2: Common Message Mappings
| ROS 2 Type | Gazebo Type | Use Case |
|---|---|---|
geometry_msgs/msg/Twist |
gz.msgs.Twist |
Velocity commands |
sensor_msgs/msg/Image |
gz.msgs.Image |
Camera images |
sensor_msgs/msg/LaserScan |
gz.msgs.LaserScan |
2D LIDAR |
sensor_msgs/msg/PointCloud2 |
gz.msgs.PointCloudPacked |
3D LIDAR |
sensor_msgs/msg/Imu |
gz.msgs.IMU |
IMU data |
std_msgs/msg/Float64 |
gz.msgs.Double |
Scalar values |
geometry_msgs/msg/Pose |
gz.msgs.Pose |
Position/orientation |
Principle 3: Command-Line Usage
# Single topic bridge
ros2 run ros_gz_bridge parameter_bridge \
/cmd_vel@geometry_msgs/msg/Twist]gz.msgs.Twist
# Multiple topics
ros2 run ros_gz_bridge parameter_bridge \
/cmd_vel@geometry_msgs/msg/Twist]gz.msgs.Twist \
/camera/image@sensor_msgs/msg/Image[gz.msgs.Image \
/lidar/scan@sensor_msgs/msg/LaserScan[gz.msgs.LaserScan
Principle 4: YAML Configuration
For complex setups, use YAML:
# bridge_config.yaml
- ros_topic_name: "/cmd_vel"
gz_topic_name: "/cmd_vel"
ros_type_name: "geometry_msgs/msg/Twist"
gz_type_name: "gz.msgs.Twist"
direction: ROS_TO_GZ
- ros_topic_name: "/camera/image"
gz_topic_name: "/camera/image"
ros_type_name: "sensor_msgs/msg/Image"
gz_type_name: "gz.msgs.Image"
direction: GZ_TO_ROS
- ros_topic_name: "/lidar/scan"
gz_topic_name: "/lidar/scan"
ros_type_name: "sensor_msgs/msg/LaserScan"
gz_type_name: "gz.msgs.LaserScan"
direction: GZ_TO_ROS
Launch with:
ros2 run ros_gz_bridge parameter_bridge --ros-args -p config_file:=bridge_config.yaml
Principle 5: Launch File Integration
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch_ros.actions import Node
from launch.launch_description_sources import PythonLaunchDescriptionSource
def generate_launch_description():
return LaunchDescription([
# Start Gazebo
IncludeLaunchDescription(
PythonLaunchDescriptionSource([
'gz_sim.launch.py'
]),
launch_arguments={'world': 'my_world.sdf'}.items(),
),
# Spawn robot
Node(
package='ros_gz_sim',
executable='create',
arguments=[
'-topic', '/robot_description',
'-name', 'my_robot',
'-x', '0', '-y', '0', '-z', '0.1'
],
),
# Bridge topics
Node(
package='ros_gz_bridge',
executable='parameter_bridge',
arguments=[
'/cmd_vel@geometry_msgs/msg/Twist]gz.msgs.Twist',
'/camera/image@sensor_msgs/msg/Image[gz.msgs.Image',
],
),
# Robot state publisher
Node(
package='robot_state_publisher',
executable='robot_state_publisher',
parameters=[{'robot_description': robot_description}],
),
])
Debugging Bridge Issues
Topic Not Bridging
- Verify topic names match exactly (case-sensitive)
- Check message type spelling
- Confirm Gazebo is publishing:
gz topic -e -t /topic - Confirm ROS 2 sees it:
ros2 topic list
Data Not Flowing
- Direction wrong (ROSTOGZ vs GZTOROS)
- Message types incompatible
- Gazebo world not running
- Bridge process crashed
Message Type Mismatch
# Check ROS 2 message type
ros2 interface show sensor_msgs/msg/Image
# Check Gazebo message type
gz msg --info gz.msgs.Image
Common Patterns
Differential Drive Control
# Velocity command (ROS → Gazebo)
- ros_topic_name: "/cmd_vel"
gz_topic_name: "/model/my_robot/cmd_vel"
ros_type_name: "geometry_msgs/msg/Twist"
gz_type_name: "gz.msgs.Twist"
direction: ROS_TO_GZ
# Odometry (Gazebo → ROS)
- ros_topic_name: "/odom"
gz_topic_name: "/model/my_robot/odometry"
ros_type_name: "nav_msgs/msg/Odometry"
gz_type_name: "gz.msgs.Odometry"
direction: GZ_TO_ROS
Full Sensor Suite
# Camera
- ros_topic_name: "/camera/image_raw"
gz_topic_name: "/camera/image"
ros_type_name: "sensor_msgs/msg/Image"
gz_type_name: "gz.msgs.Image"
direction: GZ_TO_ROS
# LIDAR
- ros_topic_name: "/scan"
gz_topic_name: "/lidar/scan"
ros_type_name: "sensor_msgs/msg/LaserScan"
gz_type_name: "gz.msgs.LaserScan"
direction: GZ_TO_ROS
# IMU
- ros_topic_name: "/imu/data"
gz_topic_name: "/imu"
ros_type_name: "sensor_msgs/msg/Imu"
gz_type_name: "gz.msgs.IMU"
direction: GZ_TO_ROS
Checklist
Before finalizing any bridge configuration:
- All topic names verified (exact match)
- Message type mappings confirmed
- Direction correct for each topic
- YAML syntax valid (if using config file)
- Gazebo topics publishing (
gz topic -l) - ROS 2 topics visible (
ros2 topic list) - Data flowing (
ros2 topic echo) - Launch file orchestrates correctly
- Multi-robot namespacing (if needed)
Integration
This skill is used by:
content-implementeragent when generating Module 2 lessons- Students learning ROS 2-Gazebo integration in Chapter 12
- All simulation-based robotics development
Dependencies:
urdf-robot-model- robots to spawn and controlgazebo-world-builder- worlds to simulate insensor-simulation- sensor data to bridge