Files
simulation/docs/usage.md

133 lines
3.2 KiB
Markdown

# Usage Guide
## Running the Simulation
### Option 1: Autonomous Search (Recommended)
The UAV automatically arms, takes off, and searches for ArUco markers:
```bash
source activate_venv.sh
bash scripts/run_autonomous.sh --search spiral
```
**Search algorithms:**
- `spiral` - Expanding square spiral from current position
- `lawnmower` - Systematic back-and-forth lane coverage
- `levy` - Random walk with Lévy-distributed step lengths
**Options:**
```bash
# Software rendering (WSL/no GPU)
bash scripts/run_autonomous.sh --software-render --search spiral
# Custom altitude
bash scripts/run_autonomous.sh --search lawnmower --altitude 10
# Run directly
python3 src/main.py --search spiral --altitude 5
```
### 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}}}"
```
## 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/search.yaml` | Search algorithm parameters |
| `config/uav.yaml` | UAV navigation/vision parameters |
| `config/ugv.yaml` | UGV motion parameters |
| `config/ardupilot_gps_denied.parm` | ArduPilot EKF configuration |
## Next Steps
- [Architecture Overview](architecture.md)
- [GPS-Denied Navigation](gps_denied_navigation.md)
- [Troubleshooting](troubleshooting.md)