--- name: gazebo-simulation description: Expert skill for Gazebo Classic and Ignition/Gazebo Sim world creation and plugin development. Create SDF worlds with terrain, lighting, physics configuration, sensor models, and custom plugins. allowed-tools: Bash(*) Read Write Edit Glob Grep WebFetch metadata: author: babysitter-sdk version: "1.0.0" category: simulation backlog-id: SK-002 --- # gazebo-simulation You are **gazebo-simulation** - a specialized skill for Gazebo simulation environment creation, configuration, and plugin development. ## Overview This skill enables AI-powered Gazebo simulation including: - Creating SDF world files with terrain, lighting, and physics - Configuring physics engine parameters (ODE, Bullet, DART) - Implementing Gazebo plugins (model, world, sensor, visual) - Generating sensor models (camera, LiDAR, IMU, GPS, depth) - Setting up contact sensors and force-torque sensors - Configuring dynamic actors and animated models - Implementing custom physics materials and friction - Creating procedural world generation - Optimizing simulation performance (LOD, collision simplification) - Setting up multi-robot simulation instances ## Prerequisites - Gazebo Sim (Harmonic, Ionic) or Gazebo Classic (11) - ROS2 with gazebo_ros_pkgs - SDF specification knowledge - C++ development tools for custom plugins ## Capabilities ### 1. World File Creation Generate SDF world files: ```xml 0.001 1.0 1000 quick 50 1.3 0.0 0.2 100.0 0.001 true 0 0 10 0 0 0 0.8 0.8 0.8 1 0.2 0.2 0.2 1 -0.5 0.1 -0.9 5 5 3 0 0 0 0.5 0.5 0.5 1 0.1 0.1 0.1 1 20 0.05 0.001 true 0 0 1 100 100 100 50 0 0 1 100 100 0.8 0.8 0.8 1 0.8 0.8 0.8 1 model://my_robot robot1 0 0 0.1 0 0 0 ogre2 ``` ### 2. Physics Engine Configuration Configure different physics engines: ```xml 0.001 1.0 quick 50 0.001 1.0 sequential_impulse 50 1.3 0.001 1.0 fcl pgs ``` ### 3. Sensor Configuration Add various sensors to robots: ```xml true 30 1.3962634 640 480 R8G8B8 0.1 100 gaussian 0 0.007 true 15 1.047 640 480 R_FLOAT32 0.1 10 true 10 640 1 -3.14159 3.14159 16 1 -0.26 0.26 0.3 100 0.01 gaussian 0 0.01 true 200 0.0 0.0002 0.0 0.0002 0.0 0.0002 0.0 0.017 true 5 0 0.5 0 1.0 ``` ### 4. ROS2-Gazebo Bridge Configure ROS2 bridge for topics: ```xml /robot ``` ### 5. Terrain and Environment Create terrain and environment models: ```xml true file://terrain/heightmap.png 100 100 10 0 0 0 file://terrain/heightmap.png 100 100 10 0 0 0 file://terrain/grass.png file://terrain/grass_normal.png 10 true 5 3 0.5 0 0 0 1 1 1 1 1 1 0.5 0.5 0.5 1 ``` ### 6. Custom Plugin Development Create custom Gazebo plugins: ```cpp // WorldPlugin example #include #include namespace my_plugins { class MyWorldPlugin : public gz::sim::System, public gz::sim::ISystemConfigure, public gz::sim::ISystemPreUpdate { public: void Configure(const gz::sim::Entity &_entity, const std::shared_ptr &_sdf, gz::sim::EntityComponentManager &_ecm, gz::sim::EventManager &_eventMgr) override { // Configuration on load gzmsg << "MyWorldPlugin configured" << std::endl; } void PreUpdate(const gz::sim::UpdateInfo &_info, gz::sim::EntityComponentManager &_ecm) override { // Called before each simulation step if (_info.paused) return; // Custom logic here } }; } GZ_ADD_PLUGIN(my_plugins::MyWorldPlugin, gz::sim::System, my_plugins::MyWorldPlugin::ISystemConfigure, my_plugins::MyWorldPlugin::ISystemPreUpdate) ``` ### 7. Launch File Integration Launch Gazebo with ROS2: ```python from launch import LaunchDescription from launch.actions import IncludeLaunchDescription, DeclareLaunchArgument from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration, PathJoinSubstitution from launch_ros.actions import Node from launch_ros.substitutions import FindPackageShare def generate_launch_description(): pkg_share = FindPackageShare('my_robot_gazebo') # World file world_file = PathJoinSubstitution([pkg_share, 'worlds', 'robot_world.sdf']) # Gazebo launch gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource([ FindPackageShare('ros_gz_sim'), '/launch/gz_sim.launch.py' ]), launch_arguments={ 'gz_args': ['-r ', world_file], 'on_exit_shutdown': 'true' }.items() ) # Spawn robot spawn_robot = Node( package='ros_gz_sim', executable='create', arguments=[ '-name', 'my_robot', '-topic', '/robot_description', '-x', '0', '-y', '0', '-z', '0.1' ], output='screen' ) # ROS-GZ Bridge bridge = Node( package='ros_gz_bridge', executable='parameter_bridge', arguments=[ '/cmd_vel@geometry_msgs/msg/Twist@gz.msgs.Twist', '/odom@nav_msgs/msg/Odometry@gz.msgs.Odometry', '/scan@sensor_msgs/msg/LaserScan@gz.msgs.LaserScan' ], output='screen' ) return LaunchDescription([ gazebo, spawn_robot, bridge ]) ``` ## MCP Server Integration This skill can leverage the following MCP servers for enhanced capabilities: | Server | Description | Installation | |--------|-------------|--------------| | Gazebo MCP Server | ROS2 MCP for Gazebo | [lobehub.com](https://lobehub.com/mcp/yourusername-gazebo-mcp) | | ros-mcp-server | ROS/ROS2 bridge | [GitHub](https://github.com/robotmcp/ros-mcp-server) | ## Best Practices 1. **Use appropriate physics** - Choose physics engine based on requirements 2. **Sensor noise** - Add realistic noise models to sensors 3. **Collision simplification** - Use simplified collision geometry 4. **Real-time factor** - Adjust for simulation vs real-time requirements 5. **Resource management** - Disable unused sensors to improve performance 6. **Modular worlds** - Use includes for reusable world components ## Process Integration This skill integrates with the following processes: - `gazebo-simulation-setup.js` - Primary simulation setup - `digital-twin-development.js` - Digital twin creation - `synthetic-data-pipeline.js` - Training data generation - `simulation-performance-optimization.js` - Performance tuning - `hil-testing.js` - Hardware-in-the-loop testing ## Output Format When executing operations, provide structured output: ```json { "operation": "create-world", "worldName": "robot_world", "status": "success", "configuration": { "physicsEngine": "ode", "realTimeFactor": 1.0, "sensors": ["camera", "lidar", "imu"] }, "artifacts": [ "worlds/robot_world.sdf", "launch/simulation.launch.py" ], "launchCommand": "ros2 launch my_robot_gazebo simulation.launch.py" } ``` ## Constraints - Verify Gazebo version compatibility (Classic vs Sim) - Check SDF version for feature availability - Test sensor update rates for performance impact - Validate physics parameters for stability - Ensure ROS-GZ bridge topic compatibility