Files
simulation/docs/usage.md
2026-02-09 05:51:51 +00:00

155 lines
3.7 KiB
Markdown

# Usage Guide
## Running the Simulation
### Option 1: Autonomous Mode (Recommended)
The simplest way to run - the UAV automatically arms, takes off, and flies:
```bash
source activate_venv.sh
bash scripts/run_autonomous.sh --mission hover
```
**Mission types:**
- `hover` - Take off to 5m, hover 30 seconds, land
- `square` - Fly a 5m square pattern
- `circle` - Fly a circular pattern (5m radius)
**Options:**
```bash
# Software rendering (WSL/no GPU)
bash scripts/run_autonomous.sh --software-render --mission hover
# Custom altitude and duration
python3 src/autonomous_controller.py --altitude 10 --duration 60 --mission hover
```
### Option 2: Manual Mode (MAVProxy)
For interactive control via MAVProxy:
```bash
bash scripts/run_simulation.sh
```
Wait for EKF initialization messages (~15 seconds):
```
EKF3 IMU0 initialised
EKF3 IMU1 initialised
AHRS: EKF3 active
```
Then type commands:
```
mode guided
arm throttle force
takeoff 5
```
### Option 3: ROS 2 Launch
For full ROS 2 integration with MAVROS:
```bash
source /opt/ros/humble/setup.bash
source activate_venv.sh
ros2 launch uav_ugv_simulation full_simulation.launch.py
```
## MAVProxy Commands
| Command | Description |
|---------|-------------|
| `mode guided` | Switch to GUIDED mode |
| `arm throttle force` | Force arm (bypasses checks) |
| `takeoff 5` | Take off to 5 meters |
| `guided 10 5 -10` | Go to position (N, E, Down) |
| `land` | Land at current position |
| `rtl` | Return to launch |
| `disarm` | Disarm motors |
## ROS 2 Topics
### UAV Topics
| Topic | Type | Description |
|-------|------|-------------|
| `/uav/mavros/state` | `mavros_msgs/State` | Armed/mode status |
| `/uav/mavros/local_position/pose` | `PoseStamped` | Current position |
| `/uav/visual_odometry/pose` | `PoseStamped` | VO position estimate |
| `/uav/setpoint_position` | `PoseStamped` | Target position |
| `/uav/controller/command` | `String` | Control commands |
### UGV Topics
| Topic | Type | Description |
|-------|------|-------------|
| `/ugv/odom` | `Odometry` | Current odometry |
| `/ugv/goal_pose` | `PoseStamped` | Target position |
| `/ugv/cmd_vel` | `Twist` | Velocity command |
### Control via ROS 2
```bash
# Send command to UAV
ros2 topic pub /uav/controller/command std_msgs/String "data: 'takeoff'"
# Send waypoint
ros2 topic pub /uav/setpoint_position geometry_msgs/PoseStamped \
"{header: {frame_id: 'odom'}, pose: {position: {x: 10, y: 5, z: 5}}}"
# Send UGV goal
ros2 topic pub /ugv/goal_pose geometry_msgs/PoseStamped \
"{header: {frame_id: 'odom'}, pose: {position: {x: 5, y: 5, z: 0}}}"
```
## Mission Planner
Run coordinated multi-vehicle missions:
```bash
ros2 run uav_ugv_simulation mission_planner
```
Send commands:
```bash
# Load demo mission
ros2 topic pub /mission/command std_msgs/String "data: 'load'"
# Start mission
ros2 topic pub /mission/command std_msgs/String "data: 'start'"
# Pause/Resume
ros2 topic pub /mission/command std_msgs/String "data: 'pause'"
ros2 topic pub /mission/command std_msgs/String "data: 'resume'"
# Abort
ros2 topic pub /mission/command std_msgs/String "data: 'abort'"
```
## Stopping the Simulation
```bash
# Kill all processes
bash scripts/kill_simulation.sh
# Or press Ctrl+C in the terminal running the simulation
```
## Configuration Files
| File | Description |
|------|-------------|
| `config/uav_params.yaml` | UAV navigation/vision parameters |
| `config/ugv_params.yaml` | UGV motion parameters |
| `config/mavros_params.yaml` | MAVROS connection settings |
| `config/geofence_params.yaml` | Geofence boundaries |
| `config/ardupilot_gps_denied.parm` | ArduPilot EKF configuration |
## Next Steps
- [Architecture Overview](architecture.md)
- [GPS-Denied Navigation](gps_denied_navigation.md)
- [Troubleshooting](troubleshooting.md)