Skip to main content
🤝

이 가이드는 인류와 AI가 함께 만드는 지식입니다.

이 콘텐츠는 Human + AI Partnership 철학 아래 모든 사람이 로봇·AI를 배울 수 있도록 무료로 제공됩니다. 당신의 질문과 기여가 다음 학생의 미래를 바꿉니다.

ROS 2 Gazebo Simulation Guide 2026

Simulation is where robots are built before hardware exists. This guide covers modern Gazebo (gz-sim Harmonic) with ROS 2: authoring worlds, simulating sensors, tuning physics, bridging topics, and closing the sim-to-real gap.

1. Installing Gazebo Harmonic + ROS 2

Modern Gazebo (formerly "Ignition") pairs with ROS 2 via ros_gz:

# Gazebo Harmonic (gz-sim 8) with ROS 2 Humble/Jazzy
sudo apt-get install -y   ros-humble-ros-gz   ros-humble-ros-gz-sim   ros-humble-ros-gz-bridge   ros-humble-ros-gz-image

# Launch an empty world
gz sim empty.sdf

# Verify the ROS <-> gz bridge tooling
ros2 pkg list | grep ros_gz

2. Authoring an SDF World

Worlds are SDF. Define physics, lighting, and models:

<?xml version="1.0" ?>
<sdf version="1.10">
  <world name="warehouse">
    <physics name="1ms" type="ignored">
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1.0</real_time_factor>
    </physics>

    <plugin filename="gz-sim-physics-system"
            name="gz::sim::systems::Physics"/>
    <plugin filename="gz-sim-sensors-system"
            name="gz::sim::systems::Sensors">
      <render_engine>ogre2</render_engine>
    </plugin>

    <light type="directional" name="sun">
      <direction>-0.5 0.1 -0.9</direction>
    </light>

    <include>
      <uri>model://warehouse_shelves</uri>
    </include>
  </world>
</sdf>

3. Simulating Sensors

Attach a 3D LiDAR and a depth camera to the robot in SDF:

<sensor name="lidar" type="gpu_lidar">
  <update_rate>10</update_rate>
  <topic>scan</topic>
  <lidar>
    <scan>
      <horizontal><samples>360</samples>
        <min_angle>-3.14</min_angle><max_angle>3.14</max_angle>
      </horizontal>
      <vertical><samples>16</samples>
        <min_angle>-0.26</min_angle><max_angle>0.26</max_angle>
      </vertical>
    </scan>
    <range><min>0.1</min><max>30.0</max></range>
  </lidar>
</sensor>

<sensor name="depth" type="depth_camera">
  <update_rate>30</update_rate>
  <topic>camera/depth</topic>
  <camera><image><width>640</width><height>480</height></image></camera>
</sensor>

4. Bridging gz Topics to ROS 2

ros_gz_bridge maps Gazebo transport topics to ROS 2 message types:

# Bridge specific topics (gz_type <-> ros_type)
ros2 run ros_gz_bridge parameter_bridge   /scan@sensor_msgs/msg/LaserScan[gz.msgs.LaserScan   /camera/depth@sensor_msgs/msg/Image[gz.msgs.Image   /cmd_vel@geometry_msgs/msg/Twist]gz.msgs.Twist   /model/robot/odometry@nav_msgs/msg/Odometry[gz.msgs.Odometry

# '[' = gz -> ros, ']' = ros -> gz, '@' separates names from types.
# For many topics, use a YAML bridge config instead.

5. Spawning Robots at Runtime

from launch import LaunchDescription
from launch_ros.actions import Node
from ros_gz_sim.actions import GzServer

def generate_launch_description():
    return LaunchDescription([
        GzServer(world_sdf_file='warehouse.sdf'),
        Node(package='ros_gz_sim', executable='create',
             arguments=['-name', 'robot',
                        '-file', 'robot.sdf',
                        '-x', '0', '-y', '0', '-z', '0.2'],
             output='screen'),
    ])

6. Physics Tuning for Fidelity

7. Sim-to-Real: Domain Randomization

Randomize sim parameters so a policy trained in sim survives reality:

import random

def randomize_episode(world):
    world.set_friction(random.uniform(0.6, 1.2))
    world.set_gravity_z(random.uniform(-9.7, -9.9))
    world.set_light_intensity(random.uniform(0.5, 1.5))
    world.add_sensor_noise('lidar', stddev=random.uniform(0.0, 0.03))
    world.set_actuator_latency(random.uniform(0.0, 0.02))
    # Training across this distribution makes the policy robust to
    # the unknown true parameters of the real robot.

8. Headless Sim for CI & RL

# Headless server (no GUI) for cloud training / CI pipelines
gz sim -s -r --headless-rendering warehouse.sdf

# Run many parallel instances with distinct partitions
GZ_PARTITION=env0 gz sim -s -r world.sdf &
GZ_PARTITION=env1 gz sim -s -r world.sdf &
# Each is isolated — collect experience in parallel for RL.

9. Validating Against Reality

10. When to Use Gazebo vs Isaac Sim

Key Takeaways

Modern Gazebo (gz-sim Harmonic) is the open-source backbone of ROS 2 simulation: author SDF worlds, simulate LiDAR and depth sensors, and bridge to ROS 2 with ros_gz_bridge. Tune physics — especially friction and inertia — to shrink the sim-to-real gap, and use domain randomization plus headless parallel sim for robust RL. Validate against real rosbag logs before trusting sim, and reach for Isaac Sim or MuJoCo when you need photorealism or fast contact dynamics.