74 lines
1.7 KiB
Markdown
74 lines
1.7 KiB
Markdown
# DroneController Guide
|
|
|
|
Implement your GPS-denied landing algorithm.
|
|
|
|
## Quick Start
|
|
|
|
1. Edit `drone_controller.py`
|
|
2. Find `calculate_landing_maneuver()`
|
|
3. Implement your algorithm
|
|
4. Test with any simulation mode
|
|
|
|
## Function to Implement
|
|
|
|
```python
|
|
def calculate_landing_maneuver(self, telemetry, rover_telemetry):
|
|
# Your logic here
|
|
return (thrust, pitch, roll, yaw)
|
|
```
|
|
|
|
## Sensors (GPS-Denied)
|
|
|
|
```python
|
|
# Altitude
|
|
altitude = telemetry['altimeter']['altitude']
|
|
vertical_vel = telemetry['altimeter']['vertical_velocity']
|
|
|
|
# Velocity
|
|
vel_x = telemetry['velocity']['x']
|
|
vel_y = telemetry['velocity']['y']
|
|
|
|
# Landing Pad (may be None!)
|
|
landing_pad = telemetry.get('landing_pad')
|
|
if landing_pad:
|
|
relative_x = landing_pad['relative_x']
|
|
relative_y = landing_pad['relative_y']
|
|
```
|
|
|
|
## Control Output
|
|
|
|
| Value | Range | Effect |
|
|
|-------|-------|--------|
|
|
| thrust | ±1.0 | Up/down (positive = up) |
|
|
| pitch | ±0.5 | Forward/back |
|
|
| roll | ±0.5 | Left/right |
|
|
| yaw | ±0.5 | Rotation |
|
|
|
|
Note: In ArduPilot mode, these are scaled to velocities:
|
|
- Thrust → Z velocity
|
|
- Pitch/Roll → X/Y velocity
|
|
|
|
## Example Algorithm (PD Control)
|
|
|
|
```python
|
|
def calculate_landing_maneuver(self, telemetry, rover_telemetry):
|
|
alt = telemetry.get('altimeter', {})
|
|
altitude = alt.get('altitude', 5.0)
|
|
vert_vel = alt.get('vertical_velocity', 0.0)
|
|
|
|
# Altitude PD control
|
|
thrust = 0.5 * (target_alt - altitude) - 0.3 * vert_vel
|
|
|
|
# Horizontal control
|
|
pad = telemetry.get('landing_pad')
|
|
if pad:
|
|
pitch = 0.3 * pad['relative_x']
|
|
roll = 0.3 * pad['relative_y']
|
|
else:
|
|
# Hover
|
|
pitch = 0
|
|
roll = 0
|
|
|
|
return (thrust, pitch, roll, 0.0)
|
|
```
|