* fix(commander): allow VTOL to register fixed-wing setpoint type from MC form
isSetpointTypeValid() rejected SetpointType::FixedwingLateralLongitudinal
whenever vehicle_type != VEHICLE_TYPE_FIXED_WING. Since a VTOL always
boots (and stays, until it actually transitions) in ROTARY_WING form,
this made it impossible for an external mode to register this setpoint
type up front in order to command the vehicle's own first transition to
fixed-wing - registration is a one-time, synchronous step performed at
mode construction, before the vehicle has ever flown.
Thread the vehicle's is_vtol flag down to isSetpointTypeValid() and
accept FixedwingLateralLongitudinal when is_vtol is true, regardless of
the vehicle's current dynamic form. A VTOL is capable of fixed-wing
control even while currently multicopter, precisely because it is about
to transition.
* Update src/modules/commander/ModeUtil/setpoint_types.cpp
Co-authored-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
* Update src/modules/commander/ModeUtil/setpoint_types.hpp
Co-authored-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
---------
Co-authored-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
Move the arm-time home capture to before ARMING_STATE_ARMED so it runs before the ESCs are enabled and prop wash perturbs the baro, and gate it on landed && (!_mission_in_progress || seq_current == 0). The previous !_mission_in_progress gate skipped the capture entirely when arming straight into a mission, leaving home referenced to a stale (cold-baro, fewer-sats) on-ground fix. seq_current distinguishes a genuine mission start from a mid-mission re-arm (land/disarm/continue), which must not move home.
Part of #27730.
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
* fix(commander): NACK DO_FIGUREEIGHT/NAV_VTOL_TAKEOFF without double-ACKing others
handle_command() decided whether the post-switch answer_command() call
was needed by checking cmd_result != UNSUPPORTED, on the assumption that
UNSUPPORTED only ever came from the shared default: case (which already
self-acks). DO_FIGUREEIGHT and NAV_VTOL_TAKEOFF also legitimately resolve
to UNSUPPORTED from within their own case (module not compiled, or wrong
vehicle type), so the guard mistook them for already-handled and silently
dropped the ACK - the vehicle command timed out on the GCS instead of
being NACKed.
A prior fix for this addressed it with a separate `already_answered` flag,
but only set it in the two places that already matched the old proxy
(default: and the ignore-list), so ~8 other cases that answer_command()
themselves inline (PREFLIGHT_CALIBRATION, PREFLIGHT_REBOOT_SHUTDOWN,
PREFLIGHT_STORAGE, FIXED_MAG_CAL_YAW, DO_SET_STANDARD_MODE,
RUN_PREARM_CHECKS, DO_SET_ACTUATOR, DO_SET_SAFETY_SWITCH_STATE) would now
fall through to the shared call too and get ACKed a second time, with the
wrong (UNSUPPORTED) result.
Replace the flag with a structural rule instead: every case that sends
its own ACK returns immediately rather than breaking, so the single
answer_command(cmd, cmd_result) after the switch is unconditional and
only ever reached by cases that rely on it.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
* fix(commander): move GUIDED_CHANGE_HEADING into navigator-acked ignore list
Its case body was empty, relying on cmd_result staying UNSUPPORTED to
skip the old conditional answer_command() call. Now that the shared
answer_command() runs unconditionally, this fell through into a bogus
UNSUPPORTED NACK on top of navigator's own ACK/DENIED for the command.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
* Apply suggestion from @hamishwillee
---------
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Switches from using VehicleControlMode to a specific setpoint type message
with reply.
Reasons:
- in case a VehicleControlMode was dropped (e.g. when the mode switched
setpoint type), no confirmation was returned, and resulting in wrong
controller flags.
- cleaner interface separation: external modes do not need to configure
(or know) which controller to run for a certain setpoint
- allows for external modes to check for compatibility: e.g. a mode using
fixed-wing setpoint types can now be rejected on a multicopter.
- allows for further extensions, like a setpoint timeout
This makes it a bit more effort to add a new setpoint type. Specifically,
setpoint_types.cpp needs to be extended when adding a new setpoint message.
PX4 internal modes also make use of the setpoint types. The information
flow is:
nav_state -> setpoint type -> vehicle control mode flags
It also adds a timeout to the setpoint config, but is not implemented
yet.
This changes the interface for external modes and thus the compatibility
version is increased.
* feat(manual_control): trigger RC override on stick velocity
COM_RC_STICK_OV is now a velocity threshold (1/s) instead of a deflection percentage.
Default 3.0, range [1.0, 10.0]. A stick held statically cannot trigger override.
* docs(manual_control): update COM_RC_STICK_OV description for velocity-based override
* feat(manual_control): gate RC override with sign-consistency check
* fix(ManualControl): lower threshold and filter constant for RC override, add tests for MovingDiff
* refactor(commander): merge RC override params into COM_RC_OVR_SPEED
Replace the COM_RC_OVERRIDE bitmask + COM_RC_STICK_OV threshold with a
single float COM_RC_OVR_SPEED (stick override velocity, 0 = disabled).
Override now applies uniformly in auto and offboard modes.
- ManualControl: rename param, treat 0 as disabled (FLT_EPSILON guard)
- Commander: drop the per-mode bitmask gate and the RcOverrideBits enum
- param_translation: migrate COM_RC_OVERRIDE on import (enabled -> 1.0,
disabled -> 0.0) and drop the unit-incompatible COM_RC_STICK_OV value
- docs: collapse the two params into one across the mode pages
* fix(manual_override): Move configuration to manual_control module
with MAN_OVERRIDE_SPD parameter and a negative value disabling the feature. All other logic stays in Commander.
* docs(releases): add release note for RC override rework (MAN_OVERRIDE_SPD)
---------
Co-authored-by: Matthias Grob <maetugr@gmail.com>
* feat(Commander): add COM_FLTMODE_BOOT parameter for configurable flight mode on boot
This adds COM_FLTMODE_BOOT, an enum parameter (Altitude/Position/Hold/Stabilized, default Hold) that controls the nav_state set on boot, before any user mode command is received.
The navStateFromParam() translation function (previously a ManualControl method) has been moved to mode_util::navStateFromFlightModeParam() in ModeUtil/conversions.hpp so COM_FLTMODE_BOOT can follow the same enumeration as COM_FLTMODE* params.
* chore(commander): use nav_state for mode mapping
* feat(commander): extend list of modes available
* chore: fix style
* refactor(commander): simplify COM_FLTMODE_BOOT boot mode initialization
Apply the configured boot flight mode directly in the Commander
constructor.
Also removes the stick-presence-based mode logic (everHadModeChange
check in manualControlCheck), and changes the default to Position (NAVIGATION_STATE_POSCTL).
* chore: remove accidental whitespace
* chore: set default COM_FLTMODE_BOOT to Hold (nav_state 4)
* feat: add Takeoff state to COM_FLTMODE_BOOT
DO_REPOSITION with the CHANGE_MODE flag clear (param2=0) is valid per the
MAVLink spec -- "reposition without forcing a mode change" -- but Commander
acked UNSUPPORTED for it while the navigator still applied the setpoint
whenever armed, so an armed vehicle in Hold moved despite the UNSUPPORTED ack.
Commander now acks by mode: CHANGE_MODE set switches to Hold (or stays in
Course) and acks ACCEPTED/TEMPORARILY_REJECTED; param2=0 in Hold acks ACCEPTED;
otherwise DENIED. It never returns UNSUPPORTED.
The navigator now only applies the reposition setpoint when armed and either
CHANGE_MODE was requested or it is already in Hold, so it no longer leaves a
stale setpoint that a later switch into Hold could execute -- realizing the
intent of the 2023 change (bec0d83), which only ever touched the ack.
QGC and MAVSDK always set CHANGE_MODE, so their behavior is unchanged.
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Implements a new GUIDED_COURSE navigator mode that maintains a constant
ground-track bearing, altitude, and airspeed without manual stick input.
The mode is activated via MAVLink and accepts real-time in-flight updates:
- MAV_CMD_GUIDED_CHANGE_HEADING (HEADING_TYPE_COURSE_OVER_GROUND): set course
- MAV_CMD_DO_CHANGE_ALTITUDE: adjust target altitude
- MAV_CMD_DO_CHANGE_SPEED: adjust target airspeed
On activation the vehicle captures its current velocity vector as the
initial course bearing. A valid horizontal velocity estimate (GPS or
dead-reckoning) is required; course commands are rejected if unavailable.
The current preflight check works by sending individual actuator
commands over mavlink. This can only be done sequentially, so the
surfaces do not move in a coordinated way, instilling little confidence.
To alleviate, this adds a control surface preflight check which causes
the allocator to command torque in the given direction, so the control
surfaces move as they would in flight.
Triggered by `{MAV,VEHICLE}_CMD_ACTUATOR_GROUP_TEST`. Only runs when
pre-armed (control surfaces, tilts) or armed (thrust). Test runs for 0.5
seconds -- for longer duration, send repeatedly from the GS.
Check is rejected in flight and cancelled when nav_state changes.
There's a check to disallow arming in modes that are not suite for takeoff. The allowed autonmous ones are:
Mission - desired
Loiter - does not make sense but needs to be kept for **** MAVLink MAVSDK workflow of first arming then switching mode
Offboard - acceptable advanced case even for RC
Takeoff - desired
VTOL Takeoff - desired
* forwarding offboard setpoints in modes using the external mode registration
* requesting offboard setpoint in RAPTOR
* adding old message versions
* bumping vehicle status
* adding message translations
* updating reference to versioned old message on previous translations
* fix(commander): add tab character to critical system loss messages
* fix(commander): extend timeout for traffic avoidance system heartbeat check
* Commander: Only Warn the user about traffic avoidance system loss if COM_ARM_TRAFF is set
Signed-off-by: Claudio Micheli <claudio@auterion.com>
---------
Signed-off-by: Claudio Micheli <claudio@auterion.com>
Co-authored-by: Claudio Micheli <claudio@auterion.com>
The failure_detector_status bitmask in vehicle_status duplicates the
separate FailureDetectorStatus topic. Remove it and read directly from
the dedicated topic in failureDetectorCheck and HIGH_LATENCY2.
Extend the arm throttle safety check to all vehicle types including
rovers, which were previously excluded. Unify the two separate throttle
checks into a single evaluation at arm-time that accounts for vehicle
type and control mode: rovers require centered stick, climb-rate modes
require stick at or below center, and manual/stab/acro modes require
stick at bottom.
Overhauls the DShot driver with per-timer BDShot selection, multi-timer
sequential capture, Extended DShot Telemetry (EDT), and AM32 ESC EEPROM
read/write via MAVLink. Expands ESC support from 8 to 12 channels.
BDShot:
- Per-timer BDShot protocol selection via actuator config UI
- Multi-timer sequential burst/capture on any DMA-capable timer
- Adaptive per-channel GCR bitstream decoding
- Per-channel online/offline detection with hysteresis
Extended DShot Telemetry (EDT):
- Temperature, voltage, current from BDShot frames (no serial wire)
- New DSHOT_BIDIR_EDT parameter
- EDT data merged with serial telemetry when both available
AM32 EEPROM:
- Read/write AM32 ESC settings via MAVLink ESC_EEPROM message
- ESCSettingsInterface abstraction for future ESC firmware types
- New DSHOT_ESC_TYPE parameter
Other changes:
- Per-motor pole count params DSHOT_MOT_POL1–12 (replaces MOT_POLE_COUNT)
- EscStatus/EscReport expanded to 12 ESCs with uint16 bitmasks
- Numerous bounds-check, overflow, and concurrency fixes
- Updated DShot documentation
On Linux targets with high-rate external sensor data (>1000Hz), all
sensor calibrations (gyro, accel, mag) can freeze PX4 by starving
other threads of CPU. Normal flight is unaffected — only calibration
triggers the problem.
Two compounding issues in the calibration worker threads:
1. calibrate_cancel_check() creates a new uORB::Subscription on every
call, which triggers getDeviceNodeLocked() — an O(n) linear strcmp
scan through all uORB nodes. In gyro/mag calibration this was called
on every sensor sample, consuming the majority of CPU in strcmp alone.
2. SubscriptionBlocking::updatedBlocking() returns immediately when data
is already available (it only blocks when no data is pending). With
continuous high-rate sensor data, the calibration loops never yield,
spinning at 100% CPU.
These problems are addressed with this patch as follows:
- Throttle calibrate_cancel_check() to once per 200ms in gyro
and mag calibration loops.
- Add 1ms px4_usleep() yield before updatedBlocking()/updateBlocking()
in all calibration loops (gyro, accel, mag, orientation detection).
This caps the effective loop rate at ~1000Hz — still far above what
calibration needs (250-750 samples).
- Force Commander main loop to sleep during calibration so it does not
compete with calibration worker threads for CPU.
Tested under Linux (x64, aarch64) both with RT and non-RT scheduling,
with sensor data arriving at ~3600Hz. Calibration completes normally
and no longer results in a deadlocked process.
* added vehicle command and support to remotely activate/deactivate the safety system (#26078)
* added print_status support for prearm safety status
* updated safety button to map to MAV_CMD_DO_SET_SAFETY_SWITCH_STATE = '5300'
* safety switch cmd: fixed incorrect catch-all and added commanded_state variable for easier reading
When operating fully autonomously (i.e., without manual control or a guaranteed link to the ground station), tuning a vehicle can be difficult since the current autotune process requires either RC input or a GCS command. For these scenarios, it it useful to be able to start autotune inside a mission.
The mode executor can run land mode which updates the home position to the landing location. This
can be not the desirable behavior and the home position should stay at the original location.
A flag is added to the configuration overrides to control if the home position is updated or not.