Files
RDC_Simulation/docs/pybullet.md
2026-01-01 01:08:30 +00:00

2.2 KiB

PyBullet Simulation

Running the GPS-denied drone simulation with PyBullet.

No ROS 2 required! Single terminal:

source activate.sh
python standalone_simulation.py --pattern circular --speed 0.3

Options

python standalone_simulation.py --help

Options:
  --pattern, -p   stationary, linear, circular, square
  --speed, -s     Rover speed in m/s (default: 0.5)
  --amplitude, -a Movement amplitude in meters (default: 2.0)

ROS 2 Mode (2 Terminals)

For distributed or remote simulation:

Terminal 1 - Simulator:

source activate.sh
python simulation_host.py

Terminal 2 - Controllers:

source activate.sh
python run_bridge.py --pattern circular --speed 0.3

Remote Setup

Run simulator on one machine, controllers on another:

Machine 1 (with display):

python simulation_host.py  # Listens on 0.0.0.0:5555

Machine 2 (headless):

python run_bridge.py --host 192.168.1.100 --pattern circular

Building Standalone Executable

Create a distributable executable:

source activate.sh

# Build standalone simulation (recommended)
python build_exe.py

# Build simulation_host
python build_exe.py simulation_host

# Build all
python build_exe.py all

Executables are created in dist/.


Simulation Parameters

Parameter Value
Physics Rate 240 Hz
Telemetry Rate 24 Hz
Drone Mass 1.0 kg
UDP Port 5555 (commands), 5556 (telemetry)

GPS-Denied Sensors

Sensor Description
IMU Orientation, angular velocity
Altimeter Barometric altitude, vertical velocity
Velocity Optical flow estimate
Camera 320x240 downward JPEG image
Landing Pad Vision-based relative position

Troubleshooting

"Cannot connect to X server"

PyBullet GUI requires a display:

# Use virtual display
xvfb-run python standalone_simulation.py

# Or use X11 forwarding
ssh -X user@host

Drone flies erratically

Reduce control gains in drone_controller.py:

Kp = 0.3
Kd = 0.2

Camera image not appearing

Install Pillow:

pip install pillow