Repository navigation
Development
Assets/_Project/Scripts/ runtime code, namespace DroneSim
Bridge/ PX4 connection, MAVLink encoder
Vehicle/ Rotor, Wing, ControlSurface, VehicleActuators, ManualControl (keyboard)
Sensors/ IMU, cameras, ground truth, sensor delay
World/ GeoOrigin (home + GPS), magnetic field table, Wind
Core/ settings, ROS topic names, ROS clock, publisher base, reset
UserCamera/ chase and free camera
Utils/ noise
Assets/Editor/DroneSim/ SceneBuilder
Assets/Tests/EditMode/ unit tests
tools/ px4_flight_test.py
missions/ QGC mission for the quadplane
SimSettings, ROSSettings, GeoOrigin and Wind are components on the Managers object.
- Edit the numbers in
Assets/Editor/DroneSim/SceneBuilder.cs - In Unity: Drone Sim > Build Flight Scenes
- Commit the builder and the scenes
[todo: image of the Drone Sim menu]
Inspector changes get wiped on the next rebuild, put them in the builder.
From PX4's 1040_gazebo-classic_standard_vtol airframe. Same table in code as
StandardVtolChannels.
| Channel | Actuator | Range | Notes |
|---|---|---|---|
| 0 | Lift rotor front-right | 0..1 | CCW |
| 1 | Lift rotor rear-left | 0..1 | CCW |
| 2 | Lift rotor front-left | 0..1 | CW |
| 3 | Lift rotor rear-right | 0..1 | CW |
| 4 | Pusher | 0..1 | |
| 5 | Left aileron | -1..1 | positive rolls left |
| 6 | Right aileron | -1..1 | positive rolls right |
| 7 | Elevator | -1..1 | positive pitches nose up |
No rudder. X500 uses 0-3 in the same order. When we get our own airframe, update
StandardVtolChannels, the builder and this table together.
Game view focused.
| Key | Does |
|---|---|
| R | Reset to start pose |
| M | Toggle keyboard flying (no PX4) |
| Shift / Ctrl | Lift rotors up / down |
| W / S | Pitch |
| A / D | Roll |
| Q / E | Yaw |
| Up / Down | Pusher |
| Space | Cut motors |
| Right drag | Orbit camera |
| Scroll | Zoom |
Edit mode unit tests for MAVLink bytes (checked against pymavlink), frame conversions, geo math, magnetic field and actuators.
-
Unity: Window > General > Test Runner > EditMode > Run All
-
Terminal, with the editor closed:
/Applications/Unity/Hub/Editor/6000.6.0f1/Unity.app/Contents/MacOS/Unity -batchmode -nographics \ -projectPath . -runTests -testPlatform EditMode -testResults results.xml -logFile test.log
End to end: tools/px4_flight_test.py with PX4 connected.
From Unity through the ROS TCP endpoint:
| Topic | Type | Rate |
|---|---|---|
/clock |
rosgraph_msgs/Clock | 10 Hz |
/sim/imu/data |
sensor_msgs/Imu | 10 Hz |
/sim/forward_cam/image_raw/compressed |
sensor_msgs/CompressedImage | 10 Hz |
/sim/forward_cam/camera_info |
sensor_msgs/CameraInfo | 10 Hz |
/sim/down_cam/image_raw/compressed |
sensor_msgs/CompressedImage | 10 Hz |
/sim/down_cam/camera_info |
sensor_msgs/CameraInfo | 10 Hz |
/sim/ground_truth/pose |
geometry_msgs/PoseStamped (ENU) | 50 Hz |
/sim/ground_truth/twist |
geometry_msgs/TwistStamped (body FLU) | 50 Hz |
/sim/ground_truth/gps |
sensor_msgs/NavSatFix | 50 Hz |
-
/simulation/reset(std_msgs/Bool): resets the vehicle ontrue - Topic and frame names:
ROSSettings - Rates: on each publisher. ROS on/off and JPEG settings:
SimSettings -
/fmu/...topics come from PX4 through the agent, not from Unity
- Wind:
WindonManagers(mean vector, gust size, gust period) - Randomize on reset:
SimulationResetManager(mass, thrust, wind), off by default - Sensor noise: IMU on
ImuModel, GPS/baro/mag/airspeed onPx4HilBridge
Published from docs/ in the repository. Edit the pages there through a pull request; edits made on the wiki are overwritten by the next publish.