BASCORRO
Software

Simulation

Webots dan Gazebo untuk testing dan development

Simulation

Simulasi memungkinkan testing dan development tanpa robot fisik. BASCORRO menggunakan Webots sebagai simulator utama dan Gazebo sebagai alternatif.


Why Simulation?

KeuntunganPenjelasan
Safe TestingTidak ada risiko kerusakan hardware
Fast IterationBisa reset environment dalam hitungan detik
Parallel TestingJalankan multiple instances
Controlled ConditionsLighting, physics, dll bisa dikontrol
Cost EffectiveTidak perlu hardware untuk setiap developer

Webots (Primary)

Overview

Webots adalah simulator robot open-source dengan physics engine yang akurat.

┌─────────────────────────────────────────────┐
│                  Webots                     │
├─────────────────────────────────────────────┤
│  ┌─────────┐  ┌─────────┐  ┌─────────────┐ │
│  │ Physics │  │ Sensors │  │ Rendering   │ │
│  │ Engine  │  │  Sim    │  │   (OpenGL)  │ │
│  └────┬────┘  └────┬────┘  └──────┬──────┘ │
│       │            │              │        │
│       └────────────┴──────────────┘        │
│                    │                       │
│              ROS 2 Bridge                  │
│                    │                       │
└────────────────────┼───────────────────────┘

              ROS 2 Topics/Services

Installation

# Ubuntu 22.04
sudo apt install webots

# Atau download dari:
# https://cyberbotics.com/download

Package: op3_webots_ros2

ros_ws/src/ROBOTIS-OP3-Simulations/op3_webots_ros2/
├── launch/
│   └── robot_launch.py      # Main launch file
├── worlds/
│   └── op3_env.wbt         # Soccer field world
├── protos/
│   └── OP3.proto           # Robot model
└── controllers/
    └── op3_controller/     # Webots controller

Launch Simulation

# Source workspace
source /opt/ros/humble/setup.bash
source install/setup.bash

# Launch Webots with OP3
ros2 launch op3_webots_ros2 robot_launch.py world:=worlds/op3_env.wbt

World File (op3_env.wbt)

Soccer Field Setup

┌────────────────────────────────────────────────┐
│                   World                        │
│  ┌──────────────────────────────────────────┐  │
│  │            Soccer Field                  │  │
│  │  ┌────┐                        ┌────┐    │  │
│  │  │Goal│      ┌──────────┐      │Goal│    │  │
│  │  │ A  │      │  Center  │      │ B  │    │  │
│  │  └────┘      │  Circle  │      └────┘    │  │
│  │              └──────────┘                │  │
│  │         Field Lines (white)              │  │
│  │                                          │  │
│  │             🤖 OP3 Robot                 │  │
│  │             ⚽ Ball                       │  │
│  └──────────────────────────────────────────┘  │
│                                                │
│  Lighting: Directional Sun                     │
│  Ground: Artificial Turf (30mm)               │
│                                                │
└────────────────────────────────────────────────┘

KidSize Field Dimensions

ElementSize
Field9m x 6m
Goal2.6m x 1m
Penalty Area3m x 1m
Center Circle1.5m diameter
BallFIFA Size 1 (orange)

Webots + ROS 2 Integration

Published Topics

TopicTypeDescription
/camera/image_rawsensor_msgs/ImageCamera feed
/imu/datasensor_msgs/ImuIMU sensor
/joint_statessensor_msgs/JointStateJoint positions

Subscribed Topics

TopicTypeDescription
/cmd_velgeometry_msgs/TwistVelocity command
/joint_commandstrajectory_msgs/JointTrajectoryJoint control

Services

# Reset simulation
ros2 service call /supervisor/reset_simulation std_srvs/srv/Empty

Gazebo (Alternative)

Package: op3_gazebo_ros2

# Launch Gazebo simulation
ros2 launch op3_gazebo_ros2 op3_gazebo.launch.py

Webots adalah simulator utama untuk BASCORRO karena lebih ringan dan memiliki support yang baik untuk humanoid robots.


Development Workflow

┌─────────────────────────────────────────────────┐
│           Development Workflow                  │
├─────────────────────────────────────────────────┤
│                                                 │
│  1. Write Code                                  │
│       │                                         │
│       ▼                                         │
│  2. Test in Simulation (Webots)                │
│       │                                         │
│   ┌───┴───┐                                    │
│   │ Pass? │                                    │
│   └───┬───┘                                    │
│       │                                         │
│   No ─┤─ Yes                                   │
│       │    │                                   │
│       ▼    ▼                                   │
│   Fix Bug  3. Test on Real Robot               │
│       │         │                              │
│       └─────────┘                              │
│                                                │
└─────────────────────────────────────────────────┘

Running Vision in Simulation

# Terminal 1: Launch Webots
ros2 launch op3_webots_ros2 robot_launch.py

# Terminal 2: Launch Vision
ros2 launch soccer_vision soccer_vision.launch.py publish_debug_image:=true

# Terminal 3: View camera
ros2 run rqt_image_view rqt_image_view

Tips & Tricks

Speed Up Simulation

# In world file, set:
WorldInfo {
  basicTimeStep 8  # Lower = faster, less accurate
}

Headless Mode

# Run without GUI (for CI/CD)
webots --no-rendering --mode=fast world.wbt

Record Video

# From Webots menu:
# Tools → Export Movie

Multiple Robots

# In world file, add multiple OP3 protos
OP3 {
  name "robot1"
  translation 0 0 0
}
OP3 {
  name "robot2"
  translation 1 0 0
}

Common Issues

Webots Tidak Mau Buka

# Check OpenGL
glxinfo | grep "OpenGL version"

# Install dependencies
sudo apt install libgl1-mesa-glx

ROS 2 Topics Tidak Muncul

# Check if bridge is running
ros2 node list | grep webots

# Restart simulation
ros2 service call /supervisor/reset_simulation std_srvs/srv/Empty

Physics Tidak Akurat

  1. Reduce basicTimeStep
  2. Check collision shapes
  3. Verify mass/inertia values

Custom World Creation

1. Open Webots

webots

2. Create New World

File → New Project Directory

3. Add Elements

  • Add Arena (Rectangle Arena node)
  • Add OP3 Robot (import PROTO)
  • Add Ball (Sphere with physics)
  • Configure lighting

4. Save World

Save as .wbt file in op3_webots_ros2/worlds/


Resources

On this page