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,236 +1,253 @@
# Troubleshooting
# Troubleshooting Guide
Common issues and solutions.
## Common Issues
## Installation Issues
### Arming Failed
### ROS 2 packages not found
**Symptoms:**
- "PreArm: Gyros inconsistent"
- "PreArm: Need Position Estimate"
- "Arm: Throttle too high"
```
E: Unable to locate package ros-humble-ros-base
```
Check Ubuntu version matches ROS distro:
- Ubuntu 22.04 → ROS 2 Humble
- Ubuntu 24.04 → ROS 2 Jazzy
Re-run setup:
**Solution:**
```bash
bash setup.sh
```
# Wait for EKF initialization (15+ seconds)
# Look for these messages:
# EKF3 IMU0 initialised
# EKF3 IMU1 initialised
# AHRS: EKF3 active
### Gazebo cmake error (gz-cmake3 not found)
```
Could not find a package configuration file provided by "gz-cmake3"
```
Install Gazebo development packages:
```bash
sudo apt install libgz-cmake3-dev libgz-sim8-dev libgz-plugin2-dev
```
### ArduPilot build fails
```bash
cd ~/ardupilot
./waf clean
./waf configure --board sitl
./waf copter
```
### ardupilot_gazebo build fails
Ensure Gazebo dev packages are installed:
```bash
sudo apt install gz-harmonic libgz-cmake3-dev libgz-sim8-dev \
libgz-plugin2-dev libgz-common5-dev libgz-physics7-dev \
libgz-sensors8-dev rapidjson-dev
```
Rebuild:
```bash
cd ~/ardupilot_gazebo
rm -rf build
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
```
## Runtime Issues
### Gazebo won't start
Check Gazebo installation:
```bash
gz sim --version
```
Check plugin path:
```bash
echo $GZ_SIM_SYSTEM_PLUGIN_PATH
ls ~/ardupilot_gazebo/build/libArduPilotPlugin.so
```
### Black screen in Gazebo (WSL)
Use software rendering:
```bash
export LIBGL_ALWAYS_SOFTWARE=1
bash scripts/run_simulation.sh
```
Or use the flag:
```bash
bash scripts/run_simulation.sh --software-render
```
### Gazebo crashes with OpenGL error
```bash
export MESA_GL_VERSION_OVERRIDE=3.3
export MESA_GLSL_VERSION_OVERRIDE=330
export LIBGL_ALWAYS_SOFTWARE=1
```
### sim_vehicle.py not found
```bash
export PATH=$PATH:$HOME/ardupilot/Tools/autotest
```
Or source the activation script:
```bash
source activate_venv.sh
```
### MAVProxy not found
```bash
pip3 install --user mavproxy pymavlink
export PATH=$PATH:$HOME/.local/bin
```
### Drone doesn't respond to commands
1. Check ArduPilot is running:
```bash
ps aux | grep arducopter
```
2. Check connection:
```
# In MAVProxy console
status
```
3. Ensure GUIDED mode:
```
# Then force arm:
mode guided
arm throttle force
takeoff 5
```
4. Arm the drone:
```
arm throttle
### Gazebo Won't Start
**Symptoms:**
- "libGL error"
- Black screen
- Segmentation fault
**Solution (WSL/No GPU):**
```bash
# Use software rendering
bash scripts/run_autonomous.sh --software-render
# Or set manually:
export LIBGL_ALWAYS_SOFTWARE=1
export GALLIUM_DRIVER=llvmpipe
```
### Drone immediately disarms
### ArduPilot SITL Won't Connect
Usually means pre-arm checks failing:
```
# In MAVProxy console
arm check
**Symptoms:**
- "Waiting for heartbeat"
- Connection timeout
- "No MAVLink heartbeat"
**Solution:**
```bash
# Kill existing processes
bash scripts/kill_simulation.sh
# Check if port is in use
lsof -i :5760
# Restart simulation
bash scripts/run_autonomous.sh --mission hover
```
Common fixes:
```
# Disable GPS check for GPS-denied operation
param set ARMING_CHECK 0
### MAVROS Connection Failed
**Symptoms:**
- "FCU connection lost"
- MAVROS not publishing topics
**Solution:**
```bash
# Verify SITL is running
pgrep -a arducopter
# Check connection URL
# Should be tcp://127.0.0.1:5760
# Restart MAVROS
ros2 run mavros mavros_node --ros-args -p fcu_url:=tcp://127.0.0.1:5760
```
### Drone drifts or flips on takeoff
### Drone Drifts / Unstable
Check EKF is using vision/external nav:
**Symptoms:**
- Position drift after takeoff
- Oscillations
- Won't hold position
**Causes:**
1. Visual odometry not providing updates
2. EKF not using external nav
3. Poor camera data
**Solution:**
```bash
# Verify VO is publishing
ros2 topic hz /uav/visual_odometry/pose
# Check EKF source
# In MAVProxy:
param show EK3_SRC1_POSXY # Should be 6
# Verify camera is working
ros2 topic hz /uav/camera/forward/image_raw
```
# In MAVProxy console
param show EK3_SRC*
### Module Not Found
**Symptoms:**
- "ModuleNotFoundError: No module named 'pymavlink'"
- "ImportError: No module named 'cv2'"
**Solution:**
```bash
# Activate virtual environment
source activate_venv.sh
# Reinstall dependencies
pip install -r requirements.txt
```
## WSL-Specific Issues
### DISPLAY not set
### Display Not Available
For WSLg (Windows 11):
**Symptoms:**
- "cannot open display"
- GUI won't show
**Solution:**
```bash
# Install VcXsrv on Windows, then:
export DISPLAY=:0
# Or use WSLg (Windows 11)
# Should work automatically
```
For VcXsrv (Windows 10):
```bash
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
```
### Graphics Performance
### VcXsrv connection refused
1. Ensure XLaunch is running
2. Disable access control in XLaunch
3. Check Windows Firewall allows VcXsrv
### Slow graphics performance
**Symptoms:**
- Very slow rendering
- Low FPS in Gazebo
**Solution:**
```bash
# Use software rendering
bash scripts/run_simulation.sh --software-render
# Or set environment
export LIBGL_ALWAYS_SOFTWARE=1
export GALLIUM_DRIVER=llvmpipe
# Or reduce visual quality
# In Gazebo, disable shadows and effects
```
## Logs and Debugging
## Debugging Commands
### Gazebo verbose output
### Check Running Processes
```bash
gz sim -v4 ~/ardupilot_gazebo/worlds/iris_runway.sdf
# All simulation processes
pgrep -a "gz|ardupilot|mavros|ros2"
# ArduPilot SITL
pgrep -a arducopter
# Gazebo
pgrep -a "gz sim"
```
### ArduPilot logs
Logs are saved in:
```
~/ardupilot/logs/
```
### Check ROS topics
### View Logs
```bash
source activate_venv.sh
# ArduPilot logs
ls ~/.ardupilot/logs/
# ROS 2 logs
ros2 run rqt_console rqt_console
```
### Check Topics
```bash
# List all topics
ros2 topic list
ros2 topic echo /mavros/state
# Check topic rate
ros2 topic hz /uav/mavros/state
# View topic data
ros2 topic echo /uav/mavros/local_position/pose
```
## Reset Everything
### Check Services
```bash
# Stop all processes
# List services
ros2 service list
# Call arming service
ros2 service call /uav/mavros/cmd/arming mavros_msgs/srv/CommandBool "{value: true}"
```
## Reset Procedures
### Soft Reset
```bash
# Kill all processes
bash scripts/kill_simulation.sh
# Clean rebuild of ArduPilot
cd ~/ardupilot
./waf clean
./waf copter
# Wait 5 seconds
sleep 5
# Clean rebuild of plugin
cd ~/ardupilot_gazebo
rm -rf build
mkdir build && cd build
cmake ..
make -j$(nproc)
# Restart
bash scripts/run_autonomous.sh --mission hover
```
## Full Reinstall
### Full Reset
```bash
bash scripts/uninstall.sh
# Kill everything
bash scripts/kill_simulation.sh
pkill -9 -f python
pkill -9 -f ros2
# Clear ArduPilot eeprom
rm -rf ~/.ardupilot/eeprom.bin
# Restart
bash scripts/run_autonomous.sh --mission hover
```
### Reinstall
```bash
# Uninstall
bash scripts/uninstall.sh --all
# Reinstall
bash setup.sh
```
## Getting Help
1. Check the logs in the terminal
2. Verify all processes are running
3. Check ROS 2 topics are publishing
4. Ensure EKF is initialized before arming
5. Use `--software-render` on WSL/no GPU
## Related Documentation
- [Setup Guide](setup_guide.md)
- [Usage Guide](usage.md)
- [WSL Setup](wsl_setup_guide.md)