Docs and Controllers Update

This commit is contained in:
2026-01-02 07:53:44 +00:00
parent 72f85c37a5
commit 61c47f82fc
8 changed files with 289 additions and 208 deletions

View File

@@ -15,11 +15,12 @@ Single-process simulation - no ROS 2 or networking required:
│ │ PyBullet Physics + Camera │ │
│ │ Built-in Landing Controller │ │
│ │ Rover Movement Patterns │ │
│ │ Configuration from config.py │ │
│ └──────────────────────────────────┘ │
└────────────────────────────────────────┘
```
### 2. PyBullet + ROS 2 Mode (2 Terminals)
### 2. PyBullet + ROS 2 Mode (Two Terminals)
```
Terminal 1 Terminal 2
@@ -33,45 +34,65 @@ Terminal 1 Terminal 2
└──────────────────────────┘
```
### 3. Gazebo + ROS 2 Mode (2 Terminals, Linux Only)
Data flow:
- RoverController publishes position → Bridge sends to Simulator
- Simulator moves rover visually AND sends back telemetry
- DroneController receives telemetry, publishes commands
- Bridge forwards commands to Simulator
### 3. Gazebo + ROS 2 Mode (Two Terminals, Linux/WSL2)
```
Terminal 1 Terminal 2
┌──────────────────┐ ┌──────────────────────────┐
Gazebo │◄─ROS───►│ run_gazebo.py │
(gz sim ...) │ │ ┌────────────────────┐ │
│ │ GazeboBridge │ │
│ │ DroneController │ │
│ │ RoverController │ │
────────────────── │ └────────────────────┘ │
└──────────────────────────┘
Terminal 1 Terminal 2
┌───────────────────────────┐ ┌──────────────────────────┐
ros2 launch ... .launch.py│ │ run_gazebo.py │
┌─────────────────────┐ │ │ ┌────────────────────┐ │
│ Gazebo (ign gazebo) │ │ GazeboBridge │ │
│ - Drone (vel ctrl) │ │◄────►│ │ DroneController │ │
- Rover (vel ctrl) │ │ ROS │ │ RoverController │ │
│ ├───────────────────── │ └────────────────────┘ │
│ │ ros_gz_bridge └──────────────────────────┘
│ └─────────────────────┘ │
└───────────────────────────┘
```
Data flow:
- RoverController publishes to `/rover/cmd_vel` → Gazebo moves rover
- Gazebo publishes odometry → GazeboBridge converts to telemetry
- DroneController receives telemetry, publishes to `/cmd_vel`
- GazeboBridge forwards to `/drone/cmd_vel` → Gazebo moves drone
## Components
| File | Description |
|------|-------------|
| `config.py` | Central configuration (positions, physics, gains) |
| `standalone_simulation.py` | All-in-one simulation |
| `simulation_host.py` | PyBullet physics server (UDP) |
| `run_bridge.py` | PyBullet bridge + controllers |
| `run_gazebo.py` | Gazebo bridge + controllers |
| `drone_controller.py` | Landing algorithm |
| `drone_controller.py` | **Your landing algorithm** |
| `rover_controller.py` | Moving landing pad |
| `ros_bridge.py` | ROS-UDP bridge (used by run_bridge.py) |
| `gazebo_bridge.py` | Gazebo-ROS bridge (used by run_gazebo.py) |
| `gazebo/launch/drone_landing.launch.py` | ROS 2 launch file for Gazebo |
| `gazebo/worlds/drone_landing.sdf` | Gazebo world with drone + rover |
## ROS Topics
## ROS 2 Topics
| Topic | Type | Description |
|-------|------|-------------|
| `/cmd_vel` | `Twist` | Drone velocity commands |
| `/drone/telemetry` | `String` | GPS-denied sensor data |
| `/rover/telemetry` | `String` | Rover position (internal) |
| `/cmd_vel` | `Twist` | Drone commands from DroneController |
| `/drone/cmd_vel` | `Twist` | Drone commands to Gazebo |
| `/drone/telemetry` | `String` | GPS-denied sensor data (JSON) |
| `/rover/cmd_vel` | `Twist` | Rover velocity to simulator |
| `/rover/telemetry` | `String` | Rover position (JSON) |
## Network Configuration
All components default to `0.0.0.0` for network accessibility.
### Remote Setup
### Remote Setup (PyBullet mode)
**Machine 1 (with display):**
```bash
@@ -87,8 +108,8 @@ python run_bridge.py --host 192.168.1.100
| Port | Direction | Content |
|------|-----------|---------|
| 5555 | Bridge → Simulator | Commands |
| 5556 | Simulator → Bridge | Telemetry |
| 5555 | Bridge → Simulator | Commands (JSON) |
| 5556 | Simulator → Bridge | Telemetry (JSON) |
## GPS-Denied Sensors
@@ -96,11 +117,23 @@ All modes provide the same sensor data:
| Sensor | Data |
|--------|------|
| IMU | Orientation, angular velocity |
| Altimeter | Altitude, vertical velocity |
| Velocity | Estimated from optical flow |
| Camera | 320x240 downward JPEG |
| Landing Pad | Relative position (when visible) |
| **IMU** | Orientation (roll, pitch, yaw), angular velocity |
| **Altimeter** | Altitude above ground, vertical velocity |
| **Velocity** | Estimated velocity (x, y, z) |
| **Camera** | 320x240 downward JPEG (base64) |
| **Landing Pad** | Relative position (x, y, distance) when visible |
## Configuration (config.py)
| Section | Parameters |
|---------|------------|
| `DRONE` | mass, size, color, start_position, thrust/torque scales |
| `ROVER` | size, color, start_position, default_pattern, default_speed |
| `CAMERA` | width, height, fov, jpeg_quality |
| `PHYSICS` | gravity, timestep, telemetry_rate |
| `CONTROLLER` | Kp_z, Kd_z, Kp_xy, Kd_xy, rate |
| `LANDING` | success_distance, success_velocity, height_threshold |
| `NETWORK` | host, command_port, telemetry_port |
## Platform Support