This project customizes the PX4 commander module to include a new command called mission_start, enabling fully autonomous drone behavior in GPS Denied Environments: arm → takeoff → hover → monitor → land.
-
This firmware is designed for Gazebo-Classic (ROS1) and Gazebo-Harmonic (ROS2) simulations.
-
Ignore inbuilt PX4 failsafe messages that may appear in the PX4 console during simulation.
-
Clone the repo using:
git clone https://github.com/avianbob/PX4-Autonomous-Mission.git
When you run:
commander mission_startThe drone performs the following:
- Arms the drone
- Switches to AUTO mode
- Takes off to a predefined altitude (default 5m)
- Hovers in place for a set duration (default 40s)
- Logs sensor and flight data every few seconds (default 3s)
- Monitors for battery low or RC signal loss
- Lands and disarms when mission ends or safety triggers occur
- The logic can be found at:
Codes/Commander.cpp
- The logic is to be implemented at:
PX4-Autopilot/src/modules/commander/Commander.cpp
Sets parameters for:
MIS_TAKEOFF_ALT= 5.0 metershover_time= 40.0 secondsprint_interval= 3.0 seconds
Sends arming command and blocks until drone is armed:
send_vehicle_command(VEHICLE_CMD_COMPONENT_ARM_DISARM, ARMING_ACTION_ARM);send_vehicle_command(VEHICLE_CMD_DO_SET_MODE, 1, 2);Mode 2 = AUTO
send_vehicle_command(VEHICLE_CMD_NAV_TAKEOFF);While hovering:
- Logs position, velocity, battery, and angular rate every few seconds
- Records home position
It will trigger landing if any of these happen:
| Condition | Trigger |
|---|---|
Battery below BAT_LOW_THR |
Lands |
| RC Signal Lost | Lands |
| Time Elapsed > Hover Duration | Lands |
Monitors:
vehicle_land_detected_s.landed == trueThen safely disarms:
send_vehicle_command(VEHICLE_CMD_COMPONENT_ARM_DISARM, ARMING_ACTION_DISARM);Every 3 seconds, prints:
- Position:
X,Y,Height - Velocity:
Vertical,Horizontal - Battery:
% Remaining,Current - Angular Velocity:
Roll,Pitch,Yaw