Files
simulation/docs/usage.md
2026-02-09 04:52:32 +00:00

137 lines
3.0 KiB
Markdown

# Usage Guide
How to run and control the simulation.
## Starting the Simulation
```bash
cd ~/simulation
source activate_venv.sh
bash scripts/run_simulation.sh
```
This launches:
1. Gazebo with the drone model
2. ArduPilot SITL (flight controller)
3. MAVProxy console (for commands)
## Simulation Options
```bash
# Default (iris_runway world)
bash scripts/run_simulation.sh
# Specific world
bash scripts/run_simulation.sh --world iris_runway
# Rover instead of copter
bash scripts/run_simulation.sh --vehicle Rover
# Software rendering (for WSL or no GPU)
bash scripts/run_simulation.sh --software-render
# Show available options
bash scripts/run_simulation.sh --help
```
## Controlling the UAV
### MAVProxy Console
The simulation opens a MAVProxy console. Commands:
```
mode guided # Switch to GUIDED mode (required for commands)
arm throttle # Arm motors
takeoff 5 # Takeoff to 5 meters altitude
# Fly to position (North, East, Down in meters)
guided 10 0 -5 # 10m north, 0m east, 5m altitude
guided 10 10 -5 # 10m north, 10m east, 5m altitude
guided 0 0 -5 # Return to origin at 5m altitude
rtl # Return to launch
land # Land at current position
disarm # Disarm motors (after landing)
```
### ROS 2 Interface
If MAVROS is running, control via ROS 2:
```bash
# Arm
ros2 service call /mavros/cmd/arming mavros_msgs/srv/CommandBool "{value: true}"
# Set GUIDED mode
ros2 service call /mavros/set_mode mavros_msgs/srv/SetMode "{custom_mode: 'GUIDED'}"
# Takeoff
ros2 service call /mavros/cmd/takeoff mavros_msgs/srv/CommandTOL "{altitude: 5}"
# Fly to position (local frame, meters)
ros2 topic pub /mavros/setpoint_position/local geometry_msgs/PoseStamped \
"{header: {frame_id: 'map'}, pose: {position: {x: 10, y: 5, z: 5}}}"
# Land
ros2 service call /mavros/cmd/land mavros_msgs/srv/CommandTOL "{}"
```
### Monitoring
```bash
# List topics
ros2 topic list
# View position
ros2 topic echo /mavros/local_position/pose
# View velocity
ros2 topic echo /mavros/local_position/velocity_local
# View IMU
ros2 topic echo /mavros/imu/data
```
## Flight Modes
| Mode | Description |
|------|-------------|
| STABILIZE | Manual control with attitude stabilization |
| ALT_HOLD | Maintain altitude, manual position |
| LOITER | Hold position and altitude |
| GUIDED | Accept position commands |
| AUTO | Follow pre-planned mission |
| RTL | Return to launch point |
| LAND | Controlled descent and landing |
## Stopping the Simulation
Press `Ctrl+C` in the terminal running the simulation.
Or run:
```bash
bash scripts/kill_simulation.sh
```
## Camera Topics
The UAV has two cameras:
```bash
# Forward camera (visual odometry)
ros2 topic echo /uav/camera/forward/image_raw
# Downward camera (optical flow)
ros2 topic echo /uav/camera/downward/image_raw
```
## GPS-Denied Navigation
All position commands use local coordinates (meters from takeoff point):
- X: North
- Y: East
- Z: Up (or Down for NED frame)
GPS is only used for geofencing boundaries, not for navigation.