This document describes the comprehensive fix implemented for the flight mode handling system across all three components of the MAVSDK Drone Show project: drone-side, backend server, and frontend dashboard.
The original implementation had several critical issues:
base_mode instead of custom_mode for flight modessrc/)src/drone_config.pybase_mode: MAVLink base mode flags (armed/disarmed, etc.)custom_mode: PX4-specific flight mode valuesis_armed: Derived armed statusis_ready_to_arm: Pre-arm checks resultsrc/local_mavlink_controller.pymsg.base_mode and msg.custom_modeMAV_MODE_FLAG_SAFETY_ARMEDsrc/drone_communicator.pyflight_mode (custom_mode) instead of flight_mode_rawbase_mode, is_armed, is_ready_to_arm fieldsgcs-server/)gcs-server/telemetry.pyapp/dashboard/drone-dashboard/src/)constants/px4FlightModes.js)DroneDetail.js: Professional arming status displayDroneWidget.js: QGroundControl-style status indicatorsflightModeUtils.js: Standardized utility functionsDroneWidget.css: Visual indicators (green/red borders, status badges)DroneDetail.css: Professional status badge styling#28a745)#dc3545)#007bff)#6c757d)| Custom Mode | Flight Mode | Description |
|---|---|---|
| 65536 | Manual | Direct pilot control |
| 131072 | Altitude | Altitude hold mode |
| 196608 | Position | GPS position hold |
| 327680 | Acro | Acrobatic mode |
| 393216 | Offboard | External control |
| 458752 | Stabilized | Attitude stabilization |
| 262147 | Hold | Loiter/Hold position |
| 262149 | Return | Return to Launch |
| 262150 | Land | Auto landing |
The system now implements proper pre-arm checks based on PX4 standards:
{
// Old (deprecated)
"flight_mode_raw": 458752,
// New (proper implementation)
"flight_mode": 458752, // PX4 custom_mode
"base_mode": 81, // MAVLink base_mode flags
"system_status": 3, // MAV_STATE value
"is_armed": false, // Actual armed status
"is_ready_to_arm": true // Pre-arm checks result
}
import { getFlightModeTitle, getSystemStatusTitle, isSafeMode } from '../utilities/flightModeUtils';
// Get human-readable flight mode name
const modeName = getFlightModeTitle(drone.Flight_Mode);
// Check if drone is ready to arm (from pre-arm checks)
const canArm = drone.Is_Ready_To_Arm;
// Check if drone is currently armed
const isArmed = drone.Is_Armed;
.drone-widget.ready-to-arm {
border-color: #28a745; /* Green border */
}
.drone-widget.not-ready-to-arm {
border-color: #dc3545; /* Red border */
}
.status-indicator.ready {
background-color: #28a745; /* Green badge */
}
The following files are now deprecated and should be replaced:
constants/flightModes.js → constants/px4FlightModes.jsconstants/mavModeEnum.js → constants/px4FlightModes.jsFlight_Mode now contains PX4 custom_mode values (not base_mode)This implementation follows:
Author: Claude Code Assistant
Date: 2025-09-04
Version: 1.0
Compliance: MAVLink/PX4/QGroundControl Standards