Controller Update

This commit is contained in:
2026-02-09 05:51:51 +00:00
parent cd9ae9a4f6
commit 1a616472f0
16 changed files with 1545 additions and 669 deletions

View File

@@ -1,136 +1,154 @@
# Usage Guide
How to run and control the simulation.
## Running the Simulation
## Starting the Simulation
### Option 1: Autonomous Mode (Recommended)
The simplest way to run - the UAV automatically arms, takes off, and flies:
```bash
cd ~/simulation
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
```
This launches:
1. Gazebo with the drone model
2. ArduPilot SITL (flight controller)
3. MAVProxy console (for commands)
Wait for EKF initialization messages (~15 seconds):
```
EKF3 IMU0 initialised
EKF3 IMU1 initialised
AHRS: EKF3 active
```
## Simulation Options
Then type commands:
```
mode guided
arm throttle force
takeoff 5
```
### Option 3: ROS 2 Launch
For full ROS 2 integration with MAVROS:
```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
source /opt/ros/humble/setup.bash
source activate_venv.sh
ros2 launch uav_ugv_simulation full_simulation.launch.py
```
## Controlling the UAV
## MAVProxy Commands
### MAVProxy Console
| 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 |
The simulation opens a MAVProxy console. Commands:
## ROS 2 Topics
```
mode guided # Switch to GUIDED mode (required for commands)
arm throttle # Arm motors
takeoff 5 # Takeoff to 5 meters altitude
### UAV Topics
# 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
| 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 |
rtl # Return to launch
land # Land at current position
disarm # Disarm motors (after landing)
```
### UGV Topics
### ROS 2 Interface
| Topic | Type | Description |
|-------|------|-------------|
| `/ugv/odom` | `Odometry` | Current odometry |
| `/ugv/goal_pose` | `PoseStamped` | Target position |
| `/ugv/cmd_vel` | `Twist` | Velocity command |
If MAVROS is running, control via ROS 2:
### Control via ROS 2
```bash
# Arm
ros2 service call /mavros/cmd/arming mavros_msgs/srv/CommandBool "{value: true}"
# Send command to UAV
ros2 topic pub /uav/controller/command std_msgs/String "data: 'takeoff'"
# Set GUIDED mode
ros2 service call /mavros/set_mode mavros_msgs/srv/SetMode "{custom_mode: 'GUIDED'}"
# Send waypoint
ros2 topic pub /uav/setpoint_position geometry_msgs/PoseStamped \
"{header: {frame_id: 'odom'}, pose: {position: {x: 10, y: 5, z: 5}}}"
# 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 "{}"
# Send UGV goal
ros2 topic pub /ugv/goal_pose geometry_msgs/PoseStamped \
"{header: {frame_id: 'odom'}, pose: {position: {x: 5, y: 5, z: 0}}}"
```
### Monitoring
## Mission Planner
Run coordinated multi-vehicle missions:
```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
ros2 run uav_ugv_simulation mission_planner
```
## Flight Modes
Send commands:
```bash
# Load demo mission
ros2 topic pub /mission/command std_msgs/String "data: 'load'"
| 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 |
# 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
Press `Ctrl+C` in the terminal running the simulation.
Or run:
```bash
# Kill all processes
bash scripts/kill_simulation.sh
# Or press Ctrl+C in the terminal running the simulation
```
## Camera Topics
## Configuration Files
The UAV has two cameras:
| 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 |
```bash
# Forward camera (visual odometry)
ros2 topic echo /uav/camera/forward/image_raw
## Next Steps
# 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.
- [Architecture Overview](architecture.md)
- [GPS-Denied Navigation](gps_denied_navigation.md)
- [Troubleshooting](troubleshooting.md)