Code reorganization and Drone Logic Update
This commit is contained in:
@@ -1,38 +1,7 @@
|
||||
# ArduPilot GPS-Denied Simulation
|
||||
|
||||
Realistic flight controller simulation with your drone logic.
|
||||
# ArduPilot + Gazebo Simulation
|
||||
|
||||
## Quick Start (2 Terminals)
|
||||
|
||||
**Terminal 1 - Gazebo:**
|
||||
```bash
|
||||
./scripts/run_ardupilot_sim.sh runway
|
||||
# Options: runway, warehouse, zephyr
|
||||
```
|
||||
|
||||
**Terminal 2 - Controller + SITL:**
|
||||
```bash
|
||||
./scripts/run_ardupilot_controller.sh
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
The `run_ardupilot_controller.sh` script starts ArduPilot SITL in the background and connects your controller to it via MAVLink.
|
||||
|
||||
```
|
||||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
||||
│ Gazebo │◄───►│ ArduPilot SITL │◄───►│ run_ardupilot.py│
|
||||
│ (Physics) │JSON │ (Hidden) │MAV │ (Your Logic) │
|
||||
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
||||
│
|
||||
▼
|
||||
drone_controller.py
|
||||
```
|
||||
|
||||
## Manual Mode (Debugging)
|
||||
|
||||
If you need to debug with MAVProxy console (3 Terminals):
|
||||
|
||||
**Terminal 1:**
|
||||
```bash
|
||||
./scripts/run_ardupilot_sim.sh runway
|
||||
@@ -40,50 +9,64 @@ If you need to debug with MAVProxy console (3 Terminals):
|
||||
|
||||
**Terminal 2:**
|
||||
```bash
|
||||
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console
|
||||
./scripts/run_ardupilot_controller.sh
|
||||
```
|
||||
|
||||
**Terminal 3:**
|
||||
## Architecture
|
||||
|
||||
```
|
||||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
||||
│ Gazebo │◄───►│ ArduPilot SITL │◄───►│ run_ardupilot.py│
|
||||
│ (Physics) │JSON │ (Flight Ctrl) │MAV │ (Your Logic) │
|
||||
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
||||
```
|
||||
|
||||
## World Options
|
||||
|
||||
```bash
|
||||
# Debug commands in MAVProxy:
|
||||
./scripts/run_ardupilot_sim.sh runway # Default
|
||||
./scripts/run_ardupilot_sim.sh warehouse # Indoor
|
||||
./scripts/run_ardupilot_sim.sh zephyr # Fixed-wing
|
||||
```
|
||||
|
||||
## GPS-Denied Mode
|
||||
|
||||
The simulation runs in GPS-denied mode by default.
|
||||
|
||||
For manual debugging with MAVProxy:
|
||||
```bash
|
||||
sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --console
|
||||
|
||||
# In MAVProxy:
|
||||
param set ARMING_CHECK 0
|
||||
mode guided
|
||||
mode stabilize
|
||||
arm throttle force
|
||||
```
|
||||
|
||||
## Installation
|
||||
## Controller Options
|
||||
|
||||
```bash
|
||||
./setup/install_ardupilot.sh
|
||||
source ~/.bashrc
|
||||
./scripts/run_ardupilot_controller.sh # Auto takeoff
|
||||
./scripts/run_ardupilot_controller.sh --no-takeoff # Manual
|
||||
./scripts/run_ardupilot_controller.sh -a 10 # 10m altitude
|
||||
```
|
||||
|
||||
## Configuration
|
||||
## Files
|
||||
|
||||
Your `drone_controller.py` receives telemetry and returns control inputs.
|
||||
|
||||
The simulation translates your inputs:
|
||||
- `thrust` → Vertical velocity
|
||||
- `pitch/roll` → Horizontal velocity
|
||||
- `yaw` → Yaw rate
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `scripts/run_ardupilot_sim.sh` | Gazebo + GPU detection |
|
||||
| `scripts/run_ardupilot_controller.sh` | SITL + Controller |
|
||||
| `scripts/run_ardupilot.py` | MAVLink interface |
|
||||
| `src/drone_controller.py` | Your algorithm |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "SITL failed to start"
|
||||
Check if `sim_vehicle.py` is in your PATH:
|
||||
```bash
|
||||
export PATH=$PATH:~/ardupilot/Tools/autotest
|
||||
```
|
||||
|
||||
### Drone drift
|
||||
ArduPilot in GUIDED mode requires good position estimation. Without GPS, it relies on optical flow or visual odometry (not yet implemented in default setup). The drone might drift if relying only on IMU.
|
||||
|
||||
### "No JSON sensor message"
|
||||
Ensure Gazebo (Terminal 1) is running before starting the controller.
|
||||
Start Gazebo (Terminal 1) before the controller.
|
||||
|
||||
## Visualizing Camera
|
||||
### Drone doesn't respond
|
||||
Check mode is GUIDED in MAVProxy.
|
||||
|
||||
```bash
|
||||
python camera_viewer.py --topic /drone/camera
|
||||
```
|
||||
(Requires bridging the topic if using ROS 2 bridge)
|
||||
### Simulation laggy
|
||||
Check GPU: `glxinfo | grep "OpenGL renderer"`
|
||||
|
||||
Reference in New Issue
Block a user