Code reorganization and Drone Logic Update
This commit is contained in:
@@ -1,98 +1,67 @@
|
||||
# Architecture Overview
|
||||
# Architecture
|
||||
|
||||
## Modes
|
||||
|
||||
### 1. Standalone (1 Terminal)
|
||||
|
||||
```bash
|
||||
python standalone_simulation.py --pattern circular
|
||||
```
|
||||
## System Overview
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────┐
|
||||
│ standalone_simulation.py │
|
||||
│ PyBullet + Controllers + Camera │
|
||||
└────────────────────────────────────────┘
|
||||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
||||
│ Gazebo │◄───►│ ArduPilot SITL │◄───►│ Controller │
|
||||
│ (Physics) │JSON │ (Flight Ctrl) │MAV │ (Your Logic) │
|
||||
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
||||
│ │
|
||||
▼ ▼
|
||||
~/ardupilot_gazebo src/drone_controller.py
|
||||
```
|
||||
|
||||
### 2. Gazebo + ROS 2 (2 Terminals)
|
||||
## Terminal Layout
|
||||
|
||||
**Terminal 1:**
|
||||
```
|
||||
Terminal 1 Terminal 2
|
||||
┌───────────────────┐ ┌───────────────────┐
|
||||
│ Gazebo + Bridge │◄──────►│ run_gazebo.py │
|
||||
└───────────────────┘ ROS └───────────────────┘
|
||||
./scripts/run_ardupilot_sim.sh
|
||||
│
|
||||
▼
|
||||
Gazebo + ArduPilot Plugin
|
||||
```
|
||||
|
||||
### 3. ArduPilot (2 Terminals)
|
||||
|
||||
**Terminal 2:**
|
||||
```
|
||||
Terminal 1 Terminal 2
|
||||
┌───────────────────┐ ┌────────────────────────────┐
|
||||
│ Gazebo + │◄──────►│ run_ardupilot_controller.sh│
|
||||
│ ArduPilot Plugin │ JSON │ ┌──────────────────┐ │
|
||||
└───────────────────┘ │ │ ArduPilot SITL │ │
|
||||
│ └─────────┬────────┘ │
|
||||
│ │ MAVLink │
|
||||
│ ┌─────────▼────────┐ │
|
||||
│ │ run_ardupilot.py │ │
|
||||
│ └──────────────────┘ │
|
||||
└────────────────────────────┘
|
||||
./scripts/run_ardupilot_controller.sh
|
||||
│
|
||||
├── ArduPilot SITL (background)
|
||||
│
|
||||
└── run_ardupilot.py
|
||||
│
|
||||
└── src/drone_controller.py
|
||||
```
|
||||
|
||||
## Data Flow
|
||||
|
||||
### Standalone
|
||||
```
|
||||
Controller → PyBullet → Telemetry → Controller
|
||||
```
|
||||
|
||||
### Gazebo
|
||||
```
|
||||
Controller → /cmd_vel → Gazebo → /odometry → Controller
|
||||
```
|
||||
|
||||
### ArduPilot
|
||||
```
|
||||
Gazebo ◄─── JSON ───► SITL ◄─── MAVLink ───► Controller
|
||||
Gazebo ◄─── JSON/UDP ───► SITL ◄─── MAVLink ───► Controller
|
||||
│ │ │
|
||||
│ Physics │ Flight control │ Your logic
|
||||
│ Sensors │ EKF │ 3-phase mission
|
||||
│ Rendering │ Stabilization │ QR detection
|
||||
▼ ▼ ▼
|
||||
Display Attitude/Position Commands
|
||||
```
|
||||
|
||||
## Key Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `drone_controller.py` | **Your landing algorithm (used in ALL modes)** |
|
||||
| `run_ardupilot.py` | MAVLink interface for ArduPilot |
|
||||
| `run_gazebo.py` | ROS 2 interface for Gazebo |
|
||||
| `standalone_simulation.py` | PyBullet simulation engine |
|
||||
| `config.py` | Shared configuration |
|
||||
| `src/drone_controller.py` | 3-phase mission logic |
|
||||
| `scripts/run_ardupilot.py` | MAVLink interface |
|
||||
| `src/mavlink_bridge.py` | MAVLink utilities |
|
||||
| `src/gazebo_bridge.py` | Gazebo ROS bridge |
|
||||
| `config.py` | Configuration |
|
||||
|
||||
## GPS-Denied Sensors
|
||||
## 3-Phase Mission
|
||||
|
||||
The controller receives this standardized telemetry structure in all modes:
|
||||
|
||||
```python
|
||||
telemetry = {
|
||||
"altimeter": {
|
||||
"altitude": float, # Meters
|
||||
"vertical_velocity": float # m/s (positive = up)
|
||||
},
|
||||
"velocity": { # Body or Local frame
|
||||
"x": float,
|
||||
"y": float,
|
||||
"z": float
|
||||
},
|
||||
"imu": {
|
||||
"orientation": {
|
||||
"roll": float,
|
||||
"pitch": float,
|
||||
"yaw": float
|
||||
}
|
||||
},
|
||||
"landing_pad": { # If visible (None otherwise)
|
||||
"relative_x": float,
|
||||
"relative_y": float,
|
||||
"distance": float
|
||||
}
|
||||
}
|
||||
```
|
||||
┌────────┐ QR Found ┌─────────┐ Timeout ┌──────┐
|
||||
│ SEARCH │───────────────►│ COMMAND │──────────────►│ LAND │
|
||||
└────────┘ └─────────┘ └──────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
Detect QR Send to rover Track & descend
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user