How mo-elshamy/ros2_gazebo_sim_tutorial works
Project Type and Purpose
• This is a ROS 2 robotics simulation package that integrates a TurtleBot3 Waffle model (with LiDAR and camera sensors) into Gazebo Sim (Ignition) and visualizes sensor data in RViz 2.
• It lives under a single ROS 2 package named robot_description and relies on ros_gz_sim, ros_gz_bridge, and SDFormat.
Main Components
a. Gazebo Sim (Ignition)
• The simulation engine that loads SDF world files (robot_description/worlds/*.sdf) and the robot model (robot_description/models/*).
• Hosts the sensor plugins (LiDAR, camera).
b. ROS 2 Middleware
• Core ROS 2 nodes and DDS communications.
• ros_gz_sim node: spins up Gazebo as a ROS 2 node.
• ros_gz_bridge node: translates Gazebo topics into ROS 2 topics.
c. robot_description Package
• URDF/SDF files and meshes under models/
• Launch file (launch/robot.launch.py) that brings up Gazebo, bridges, and optionally RViz.
• Parameter YAML for bridge topics (params/ros_bridge.yaml).
• RViz config (rviz/rviz.rviz).
d. teleop_twist_keyboard Node
• A ROS 2 executable that publishes /cmd_vel Twist messages.
e. RViz 2
• A separate visualization node subscribing to sensor topics and TF frames.
Relationships & Data Flow
• teleop node → publishes /cmd_vel → ros_gz_bridge → Gazebo plugin subscribes → moves robot.
• Gazebo LiDAR plugin → publishes /scan (in Ignition) → ros_gz_bridge → ROS 2 /scan topic → RViz subscribes.
• Gazebo camera plugin → publishes /camera/image → ros_gz_bridge → ROS 2 topic → RViz.
• Static TF and joint states also bridged for RViz.
Architectural Patterns & Principles
• Publish–Subscribe (ROS 2 topics) decouples components.
• Separation of concerns: simulation engine vs. middleware vs. visualization.
• Launch-driven orchestration: single robot.launch.py brings up all nodes with the correct parameters.
• Clear, distinct labels for components and topics.
• Simulation engine (Gazebo/SDFormat)
• Bridge/middleware nodes
• User-space nodes (teleop, RViz)