Commit Graph
29648 Commits
Author SHA1 Message Date
gguidone 4438ad7913 fix(mavlink): stop sizing the receive thread stack by sizeof(MavlinkReceiver)
The receive thread stack is requested as sizeof(MavlinkReceiver) + 2840,
but the object is not on that stack. It is a member of the heap-allocated
Mavlink object (mavlink_main.h), and pthread_create is handed only
(void *)this, which start_trampoline casts straight back to a pointer.
Every MAVLink instance therefore reserves a second copy of the object as
stack the thread can never touch.

The term is a leftover from a refactor round trip:

  before 0a0c404a08  heap (new/delete in start_helper), stack 2840
  0a0c404a08         object became a stack local, stack sizeof + 2840
  4498509426         object became a heap-resident member, term left behind

so the pairing has been wrong since 4498509426 (Apr 2021).

On px4_fmu-v4 sizeof(MavlinkReceiver) is 4592 and sizeof(Mavlink) is 5568,
so the receiver is 82% of its heap-allocated parent. PX4_STACK_ADJUSTED is
the identity on NuttX and this board has no networking, so the request was
7432 B per instance. Deepest measured high-water over the receive paths is
1908 B, 26% of that.

Replaced with a flat 4000 B, 2.1x the deepest measurement, returning 3432 B
per MAVLink instance. Measured on px4_fmu-v4 with CONFIG_STACK_COLORATION=y,
taking top once between each of: full parameter download and rewrite, 30-item
mission upload and readback, MAVFTP listing and 400 kB log download, and
COMMAND_LONG handling. MAVFTP was the deepest path.

Effect on hardware: with a USB ground station attached the board goes from no
MAVLink heartbeat at all in 110 s to a heartbeat in 1 s.

(cherry picked from commit 61b7efcbc3)
2026-08-08 20:31:58 -07:00
Jacob Dahl 760e4830d4 fix(flashparams): compact the param sector at boot instead of at the disarm-edge save (#28093)
Armed-time param writes are deferred to the disarm edge (autosave), so
when the append wraps the single 128 KB sector, the full sector erase
lands right after disarm. On dual-bank H7 parts with firmware spanning
into the param bank (ark/fpv: ~780 KB of .text in bank 2), the erase
hardware-stalls every same-bank fetch for its 1-2 s duration — the
DShot outputs go silent long enough to trip the AM32 ESC signal-loss
reset (0.5 s armed). Paying the wrap at boot keeps in-service saves
append-only.

(cherry picked from commit 4b5ea8f04a)
2026-08-08 20:31:58 -07:00
Roman Bapst 5150435de4 fix(navigator): resolve DO_JUMP set as current mission item (#28063)
* test(mavsdk): add multicopter DO_JUMP set-current regression test

Add an integration test for an external MISSION_SET_CURRENT that targets a
DO_JUMP item mid-mission - the scenario that used to strand the vehicle on an
invalid IDLE setpoint (fixed in the following navigator commit).

The test flies a multicopter mission containing a DO_JUMP that loops back to an
earlier waypoint, commands the current item to the DO_JUMP index while airborne,
and checks that the mission still resolves the jump, runs to completion, lands
and disarms within the timeout.

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* fix(navigator): resolve DO_JUMP when loading the current mission item

An external MISSION_SET_CURRENT sets the current sequence verbatim, with no
jump resolution. If it points directly at a DO_JUMP item, the navigator loaded
that jump as the current mission item. A DO_JUMP carries no position, so
setActiveMissionItems() never overwrote the current setpoint left behind by
reset_triplets() - an invalid IDLE setpoint. The vehicle then loitered in place
at altitude indefinitely, never resolving the jump and never completing the
mission (observed in a real flight).

Resolve the jump when loading the current item: follow it to its target without
consuming a repetition (a set-current is an out-of-band action, not a normal
traversal). For an already-resolved, non-jump current item this is a no-op, so
normal mission traversal is unaffected.

Also harden two related paths:
- getNonJumpItem() now reports failure instead of returning a still-unresolved
  DO_JUMP when it runs out of iterations (jump loop or a chain longer than
  MAX_JUMP_ITERATION), which would otherwise be loaded as the current item.
- treat a DO_JUMP as reached/completed in the mission block as a safety net, so
  the navigator advances rather than hanging should one ever reach that point.

Signed-off-by: RomanBapst <bapstroman@gmail.com>

---------

Signed-off-by: RomanBapst <bapstroman@gmail.com>
(cherry picked from commit 9467506bff)
2026-08-08 20:31:58 -07:00
Jacob Dahl 43b3346510 fix(uavcan): publish non-valid range readings with quality 0 (#27963)
The rangefinder bridge published TOO_CLOSE, TOO_FAR and UNDEFINED
readings with signal_quality -1 (unknown) and the raw wire range, so
consumers treated them as usable measurements. DroneCAN rangefinder
nodes commonly report an out-of-range sentinel value in the range field
for these reading types (e.g. max_distance + 1 for TOO_FAR); flight
logs show the EKF fusing a node's 101 m TOO_FAR sentinel as terrain
distance at 45-113 m AGL.

Per the distance_sensor uORB convention (0 = invalid signal), mark all
non-VALID_RANGE readings as quality 0 so downstream consumers reject
them.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
(cherry picked from commit d11b996d89)
2026-08-08 20:31:58 -07:00
msl-dev 52723c9ad0 fix(mavlink): handle unknown battery time remaining (#27929)
(cherry picked from commit eddc929db3)
2026-08-08 20:31:58 -07:00
Marco Hauswirth 037c248dce fix(ekf2): hard reset external position estimate while position aiding active (#27856)
(cherry picked from commit 1d02832798)
2026-08-08 20:31:58 -07:00
yi chen a01442c003 fix(battery): use unclamped dt for discharged_mah coulomb count (#27866)
Battery::updateDt() clamps _dt to a maximum of 2 seconds:

    _dt = math::min((timestamp - _last_timestamp) / 1e6f, 2.f);

This same _dt is then used for two different purposes:

1. Battery::sumDischarged(), the coulomb count that accumulates
   discharged_mah: discharged_mah_loop = current_a * dt.
2. The current average low-pass filter update
   (_current_average_filter_a.update(current_a, _dt)).

The 2-second clamp makes sense for (2): a low-pass filter update
generally assumes a roughly steady sample interval and shouldn't see a
single very large dt distort its state. It does not make sense for
(1): the coulomb count is a plain physical integral (charge = current
x time), and clamping dt there just means an update that arrives less
often than every 2 seconds (e.g. some DroneCAN/UAVCAN battery devices,
as reported in #27797) has its actual elapsed time silently truncated
to 2 seconds, systematically underestimating discharged_mah for that
update - the error accumulates over the life of the battery.

Fix: track a second, unclamped dt (_dt_discharge) alongside the
existing clamped one, and use it specifically for the coulomb count in
sumDischarged(). The filter update keeps using the existing clamped
_dt unchanged.

Fixes #27797

Test plan:
- I don't have hardware with a >2-second-interval battery update
  source to reproduce this end-to-end, so I verified the corrected
  arithmetic with a standalone C reproduction of updateDt()/
  sumDischarged(): a 5-second update interval at a constant 10A
  before the fix accumulates 5.56 mAh (current x 2s, clamped) instead
  of the physically correct 13.89 mAh (current x 5s); after the fix it
  correctly accumulates 13.89 mAh.
- Verified a normal high-frequency update pattern (10 x 100ms updates
  at 5A) is unaffected: both before and after the fix accumulate the
  same, correct 1.39 mAh for that 1-second span.

Signed-off-by: yi chen <94xhn1@gmail.com>
Co-authored-by: yi chen <94xhn1@gmail.com>
(cherry picked from commit 795c69a362)
2026-08-08 20:31:58 -07:00
Eurus fea38f5866 fix(vtol_att_control): correct tailsitter quadchute attitude frame (#27834)
* fix(vtol_att_control): correct tailsitter quadchute attitude frame

* refactor(vtol_att_control): precompute tailsitter FW frame rotation

(cherry picked from commit d60fea65d2)
2026-08-08 20:31:58 -07:00
Mahima Yoga ba690cf198 fix(mavlink): accept INT32_MIN as "param not used" in mission item validation (#28079)
QGC leaves unused float params as NaN and converts them into the int32
x/y fields of MISSION_ITEM_INT, which comes out as INT32_MIN. This made
PX4 reject any mission with camera items (set mode, take photo/video,
stop photo/video) with INVALID_PARAM5. Treat INT32_MIN as "param not
used", the same as INT32_MAX.

Signed-off-by: mahima-yoga <mahima@auterion.com>
(cherry picked from commit 8e7b370cde)
2026-08-08 17:32:32 -07:00
Julian Oes 88c9699be7 fix(mavlink): accept spec-defined params in mission item validation
The param validation table rejected mission items that QGC-generated
plans legitimately contain:

- NAV_VTOL_LAND param3 is the approach altitude per the MAVLink spec.
  QGC writes it in every VTOL landing pattern; PX4's mission logic
  ignores it, but that is no reason to reject the upload.
- DO_LAND_START param5-7 are the optional lat/lon/alt marker position
  per the spec, which QGC also writes.

Both made any QGC VTOL landing plan fail to upload with
MAV_MISSION_INVALID_PARAMx, surfaced by the SIH SITL VTOL tests.

Signed-off-by: Julian Oes <julian@oes.ch>
(cherry picked from commit fb4e62fd92)
2026-08-08 17:32:32 -07:00
Koi 60a6d6e86a fix(mavlink): accept NAV_TAKEOFF param1 on multicopters (#27853)
Strict command-parameter validation added in #27541 rejects
MAV_CMD_NAV_TAKEOFF when an unsupported param is set. QGroundControl
sends param1 (minimum pitch) = -1 on multicopter takeoff, which is
non-zero/non-NaN, so commands were silently denied (MAV_RESULT_DENIED
with no log) on MC airframes and QGC guided takeoff stopped working.

Extend the NAV_TAKEOFF override to include VEHICLE_MC so param1 is
accepted and ignored on multicopters, matching FW/VTOL handling.

(cherry picked from commit 785ede83d4)
2026-08-08 17:32:32 -07:00
Claudio Chies 9a81b02afa fix(mc_autotune): unregister torque setpoint callback on autotune stop
(cherry picked from commit 749cce11d4)
2026-08-08 17:32:32 -07:00
Claudio ChiesandAnil Kircaliali ca42c60061 fix(commander): add warning-only mode to COM_PARACHUTE (#27903) (#28068)
Co-authored-by: Anil Kircaliali <anil.kircaliali@auterion.com>
2026-08-07 09:41:29 +02:00
mahima-yoga 7405573881 fix(fw_latlon_control): prevent NaN eas2tas from zero-airspeed division 2026-07-31 09:07:15 +02:00
Eric Katzfey b8dbb948a1 fix(mathlib): avoid Hexagon NaN comparison issues 2026-07-22 20:37:26 -07:00
Jacob DahlandHamish Willee 993f542f4d fix(gps): split RTCM corrections and moving-baseline uORB topics (#27097) (#27933)
* fix(gps): split RTCM corrections and moving-baseline uORB topics

The single gps_inject_data topic served two unrelated purposes:
external fixed-base RTCM corrections (from MAVLink GPS_RTCM_DATA or
UAVCAN RTCMStream) and moving-base-to-rover RTCM 4072. In a
dual-GPS-with-moving-base plus fixed-base setup, the two streams
collided on the same queue and the FMU UAVCAN bridge mirrored
fixed-base RTCM onto the MovingBaselineData CAN message, breaking
rover heading or RTK fix (see PX4/PX4-Autopilot#27088).

Split by role:
- rtcm_corrections    (renamed from gps_inject_data): external RTCM
                       flowing into the vehicle; producers are
                       MAVLink, UAVCAN RTCMStream, and GPS drivers in
                       dump mode.
- rtcm_moving_baseline (new): moving-base GPS output intended for a
                       rover; single producer per vehicle
                       (MAX_INSTANCES = 1).

The GPS driver routes its own RTCM output to the right topic via
GPSHelper::isMovingBase(), and gates the two inbound streams per role
using new GPSHelper virtuals (PX4-GPSDrivers#212):
shouldInjectRTCMCorrections() is true for any configured receiver, so a
UART2 moving-base rover still accepts fixed-base corrections over its
main link; shouldInjectMovingBaseline() is true only for a UART1/CAN
heading rover, since a UART2 rover gets the baseline directly in
hardware and a moving base produces rather than consumes it. That
submodule PR also renames the ambiguous UBXMode fields to name their
UART explicitly (RoverWithMovingBase -> RoverWithMovingBaseUART2,
MovingBase -> MovingBaseUART2).

Septentrio's publish_rtcm_corrections() always publishes to
rtcm_moving_baseline (only the Secondary moving base calls it).
Rover-side consumers (gps, septentrio, uavcan bridge) drain both topics
independently; each topic gets its own stale-link switchover timer so
corrections failover is not suppressed by moving-baseline traffic, or
vice versa.

FMU UAVCAN bridge: two independent drain loops, one per topic. No
more dual-publish of a single uORB message onto both RTCMStream and
MovingBaselineData CAN streams.

CANnode MovingBaselineDataPub subscribes to rtcm_moving_baseline. The
bus_type == UAVCAN check is kept, now purely as a loop guard so a node
with both CANNODE_PUB_MBD and CANNODE_SUB_MBD does not rebroadcast a
peer's moving-baseline data back onto the bus. CANnode RTCMStream
subscriber maps each CAN source node ID to its own rtcm_corrections
instance (one PublicationMulti per source, capped at MAX_INSTANCES) so
multiple CAN RTCM sources (e.g. dual rovers outputting MSM7 for logging
plus a fixed-base feed) land on independent uORB instances instead of
interleaving on one, which would otherwise defeat the consumer's
per-instance stale-link selection.

Depends on PX4-GPSDrivers#212 (submodule bump included).



* fix(gps): use separate RTCM parsers for corrections and moving baseline

On a rover injecting both fixed-base corrections and moving-baseline RTCM, feeding both streams through a single parser allowed a fragmented frame from one source to be corrupted by bytes interleaved from the other. Reassemble each stream in its own Rtcm3Parser so frames are recovered independently.

Also collapse the two near-identical topics into a single RtcmData.msg published under both rtcm_corrections and rtcm_moving_baseline (the SensorGps pattern), track corrections and moving-baseline injection on separate perf counters so the reported corrections rate is no longer inflated by moving-baseline traffic, and zero-initialize the CAN DeviceId unions before populating their fields.



* fix(septentrio): avoid bugprone sizeof division on RTCM byte buffer

moving_baseline.data is a uint8_t array, so sizeof(data)/sizeof(data[0]) divides by 1; clang-tidy's bugprone-sizeof-expression flags this as a suspicious sizeof(T)/sizeof(T). Use sizeof(data) directly - the capacity value is unchanged.



* refactor(gps): use dedicated per-stream RTCM drain functions

rtcm_moving_baseline has a single publisher (instance 0), so its
consumers are now a plain uORB::Subscription instead of a 4-instance
SubscriptionMultiArray, and the per-stream selected-instance and
stale-link timer members it no longer needs are removed.

With each RTCM stream now a fixed type with a single caller, the
templated drain helpers (drain_rtcm_subscriptions, the overloaded
drain_rtcm_to_can) bought nothing, so replace them with dedicated
functions: drainRtcmCorrections()/drainMovingBaseline() in the GPS
driver and the UAVCAN bridge, drain_rtcm_corrections()/
drain_moving_baseline() in Septentrio. The UAVCAN bridge calls
PublishRTCMStream/PublishMovingBaselineData directly instead of through
Forward lambdas.

Rename SeptentrioDriver::publish_rtcm_corrections() to
publish_moving_baseline(): it is only reached from the Secondary
moving-base decode path and only ever emits moving-baseline RTCM.

Corrections-path behavior (instance selection, generation-gap warning,
burst cap, self-injection filter) is unchanged.



* refactor(gps): rename RTCM inject gate to receiverReady and simplify chunk helper

Rename GPSHelper::shouldInjectRTCMCorrections() to receiverReady(). The
virtual gates injection of both RTCM corrections and moving-baseline, and
for UBX it simply reports whether the receiver is configured, so the name
now describes what it actually gates rather than implying it only concerns
corrections. Bumps the GPS-drivers submodule to the matching rename.

Drop the vestigial message-type template parameter from publish_rtcm_chunks:
both topics share rtcm_data_s, so only the publication type needs templating.

* fix(septentrio): log dropped RTCM uORB generations

Match the gps driver and warn when the RTCM corrections or moving-baseline
subscription skips a uORB generation, so dropped injection data is visible.

* docs(docs): Docs only update to the RtcmData msg

* chore(gps): pin GPSDrivers to merged main

Contains #212 (RTCM/moving-baseline gating virtuals), #213 (X20 CFG-ODO
NAK tolerance), and #215 (SPARTN input enable, best-effort VALSET).



* fix(septentrio): reassemble RTCM frames per stream before injecting

Both drains wrote raw uORB chunks to the receiver, so a fragmented frame
on one stream could get the other stream's bytes spliced in mid-frame and
corrupt both. Reassemble each stream in its own parser and only write
complete frames, mirroring the gps driver. Injection stats now count
frames instead of uORB chunks.



* refactor(mavlink)!: remove GPS_RTCM_DATA output stream

GPS_RTCM_DATA is a GCS-to-vehicle correction transport; echoing
rtcm_corrections back out over MAVLink had no consumer and the echo was
lossy anyway (uint8 len and 180-byte payload truncate 300-byte uORB
chunks). Receiving GPS_RTCM_DATA is unchanged.



---------



(cherry picked from commit 5d8874cd2b)

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
2026-07-20 17:21:26 -06:00
CUAV Chen fb83cd5485 perf(drivers/imu/analog_devices/adis16607): Use FIFO feature to read data (#27228) 2026-07-08 10:43:56 -06:00
Jo TaeHyeon bd750e3bdf fix(zenoh): allow CDR padding margin in subscriber payload guard 2026-07-08 10:48:00 +02:00
Eurus 395ea6da11 fix(ekf2): count EV velocity as NE aiding (#27538) 2026-07-07 21:51:05 +02:00
Wang Jiayue 48bc4a8576 fix(ekf2): use HAGL validity for range height ref 2026-07-06 11:36:43 -07:00
Wang Jiayue cac770e333 fix(ekf2): add HAGL validity check for range height ref 2026-07-06 11:36:43 -07:00
Julian Oes 225c1b70ef fix(mavlink): require CONFIG_PTHREAD_MUTEX_TYPES for recursive send mutex
The per-channel send mutex is genuinely recursive: callers hold lock_send()
while the MAVLink C library re-enters send_start()/send_finish() on the same
mutex via MAVLINK_START_UART_SEND. On NuttX a recursive mutex only works with
CONFIG_PTHREAD_MUTEX_TYPES; without it pthread_mutexattr_settype() is a no-op
and the nested lock deadlocks. Only a handful of boards happened to enable the
option (for Zenoh), so mavlink could deadlock at startup on most boards, e.g.
when bringing up a USB link.

Enable CONFIG_PTHREAD_MUTEX_TYPES on the NuttX boards that build mavlink, add
a compile-time guard so a board missing the option fails the build loudly
instead of deadlocking silently, and check the settype() return. Enabling the
option is free in flash and RAM on these boards since they already enable
CONFIG_PRIORITY_INHERITANCE / CONFIG_PTHREAD_MUTEX_ROBUST.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-06 08:46:35 -07:00
Julian Oes 81ab99c2a9 fix(mavlink): make mission shared-state mutex non-recursive
The mission manager's _shared_state_mutex was recursive only because the
count updaters (update_geofence_count / update_safepoint_count) called the
public update_active_mission(), which re-took the same lock. That is the
"public method calls another public locking method" antipattern, not a
genuine need for recursion.

Split the state update into an update_active_mission_locked() helper that
assumes the lock is held and returns the mission_s to publish. The count
updaters call it while already holding the lock and publish after unlocking;
the public update_active_mission() locks around the helper. The mutex is now
a plain, statically-initialized (PTHREAD_MUTEX_INITIALIZER) mutex, dropping
the pthread_once runtime init and the non-portable recursive attribute.

This removes the dependency on CONFIG_PTHREAD_MUTEX_TYPES for this mutex,
which is not enabled on most NuttX boards.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-06 08:46:35 -07:00
elisaaferraraaandMatthias Grob 7ed3c5bad4 feat(FlightTaskAuto): manual control yaw override during Auto modes (#27691)
* feat(FlightTaskAuto): add RC yaw override during Auto modes

* feat(FlightTaskAuto): disengage RC yaw nudge on flight-mode switch

* docs: document MPC_AUTO_RC_YAW in MC Auto mode pages

Describe the RC yaw nudge (MPC_AUTO_RC_YAW) on the Mission page.
Add parameter rows to the Hold and Land pages where MPC_LAND_RC_HELP takes
precedence over it for yaw, and document MPC_LAND_RC_HELP there too.

* feat(FlightTaskAuto): updated param description to warn against COM_RC_OVERRIDE disabled

The long description recommends to have a switch on the RC to change to Position mode

* fix(FlightTaskAuto): unified yaw nudging with new MPC_AUTO_NUDGING parameter

* docs(FlightTaskAuto): MPC_AUTO_RC_YAW and MPC_LAND_RC_HELP parameters were replaced by the unified MPC_AUTO_NUDGING bitmask

* fix(parameters): migrate MPC_LAND_RC_HELP to MPC_AUTO_NUDGING bit 1

* docs(1.18): move stick override and add nudging changes

---------

Co-authored-by: Matthias Grob <maetugr@gmail.com>
2026-07-06 13:52:03 +02:00
Balduin 0a5692bc16 test(fw_att_ctrl): tailsitter frame rotation
The test provides a guard against the _q_mc_to_fw quaternion changing,
and sanity checks a _copy of_ the conversion implemented in Run().
It cannot guard against breaking the implementation in Run() without
changing the quaternion - that is the job of integration tests.
2026-07-06 13:21:15 +02:00
Balduin 5dd5b8dda6 refactor(fw_att_control): clean up tailsitter attitude conversions
- replace rotation matrix manipulation by rotation quaternion
 - standardise and clarify wording in comments
2026-07-06 13:21:15 +02:00
Kirill 56ede3a888 fix(fw_att_control): use adapted tailsitter attitude for FW error
- In tailsitter case, construct current quaternion from _R, which is
   aready rotated correctly a bit above
 - Downside: bloaty solution of converting to rotation matrix, adjusting
   that, and converting back to quaternion
2026-07-06 13:21:15 +02:00
Hamish Willee 4af6fbeabf fix(mavlink): DO_SET_GLOBAL_ORIGIN - enable in release (#27789)
* feat(mavlink): Add DO_SET_GLOBAL_ORIGIN to invalid param use checking

* feat(mavlink): DO_SET_GLOBAL_ORIGIN - remove development gating
2026-07-06 10:30:35 +12:00
Alexis Guijarro fc8aaedfbe fix(mavlink): init mutexes before argument parsing (#27809) 2026-07-06 09:26:37 +12:00
Wang Jiayue bfb48ad17e FlightTasks: initialize smoothing with current acceleration 2026-07-03 14:44:35 -07:00
Wang Jiayue 04e656edb9 vtol_takeoff: use takeoff position for default transition yaw 2026-07-03 14:34:12 -07:00
Eurus c51aabcfec fix(commander): require GNSS altitude fusion for raw home position (#27604)
* HomePosition: require GPS altitude fusion for raw GNSS home

* Commander: name GNSS position fusion mask
2026-07-03 14:29:14 -07:00
gguidone 671f60e6da fix(flight_mode_manager): keep auto-takeoff vertical on a moving deck
On a moving deck the lift-off XY lock alone still leaned the vehicle: the
position smoother carried the inherited deck velocity into the takeoff and
braked it with a backward tilt during the thrust-limited ramp, which sprang
back at FLIGHT.

Give altitude priority for the first metre after lift-off: hold the live
horizontal position through the ramp (zero tracking error, no lean or spring
at FLIGHT) and the live horizontal velocity through the ramp and the first
metre of climb. Self-nulling on a static takeoff (no inherited velocity), so
the path is identical for static and moving takeoffs - no new param, no branch.

Signed-off-by: gguidone <gennaroguido2002@gmail.com>
2026-07-03 13:55:40 -07:00
gguidone 76fdc0f134 fix(flight_mode_manager): hold lift-off XY through the takeoff climb
Track the live horizontal position during the takeoff ramp and freeze it at
TAKEOFF_STATE_FLIGHT, overriding the position target (not just the smoother) so the
climb stays vertical over the lift-off point instead of running to the commanded
lat/lon once tilt authority opens at FLIGHT. Reset the lock on (re)activation.
2026-07-03 13:55:40 -07:00
gguidone 8ce9389afa fix(flight_mode_manager): hold lift-off point during moving-platform takeoff
Pin the smoother's horizontal position to the live position during the takeoff ramp so a moving platform doesn't stall the climb; released at TAKEOFF_STATE_FLIGHT.

Signed-off-by: gguidone <gennaroguido2002@gmail.com>
2026-07-03 13:55:40 -07:00
Wang Jiayue 733be29297 fix(navigator): clear course on loiter reposition 2026-07-03 13:28:41 -07:00
saad1551 cf0f76101b fix(navigator): enforce NAV_MIN_LTR_ALT in MC braking loiter
When a multicopter enters Hold (AUTO.LOITER) below NAV_MIN_LTR_ALT the
documented behavior is to first climb to that minimum altitude. The
clamp was added in 2022 to setLoiterItemFromCurrentPosition (the
fixed-wing branch) but never applied to the sibling
setLoiterItemFromCurrentPositionWithBraking, which is the rotary-wing
Hold path selected at loiter.cpp:131. As a result, multicopters
silently held at the entry altitude.

Apply the same min-altitude clamp in the braking variant so the
rotary-wing path matches the fixed-wing one.

Verified in SITL (jMAVSim x500): with NAV_MIN_LTR_ALT=20 and Hold
engaged from a 5m hover, the vehicle now climbs to 20m as documented.

Fixes #27578

Signed-off-by: saad1551 <saad.ashraf.9094@gmail.com>
2026-07-03 12:41:48 -07:00
Beat Küng 5d2cec97f1 chore(commander): remove unused flag_control_termination_enabled flag 2026-07-03 12:33:03 -07:00
Beat Küng f33b5769fc chore: use setpoint_config in mc_raptor and mc_nn_control 2026-07-03 12:33:03 -07:00
Beat Küng 9fb0f1e43a chore(VehicleControlMode): remove unused flag_control_acceleration_enabled 2026-07-03 12:33:03 -07:00
Beat Küng 343eab2f05 feat(commander): add setpoint types
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.
2026-07-03 12:33:03 -07:00
Beat Küng 0280f41867 fix(navigator): resend mode_completed when mode is completed
Important for external modes in case a topic sample gets dropped.
2026-07-03 12:33:03 -07:00
Beat Küng 604fe59ed7 fix(commander): add config_overrides_confirm topic
Allows an external mode to check if the request got processed
2026-07-03 12:33:03 -07:00
yannickpoffet d0f7b7d8fc feat(uxrce_dds_client): drain / unlimited rate options for topic bridging (#27688)
* feat(uxrce_dds_client): add "drain" and "unlimited" rate options for dds_topics bridging

Drain option allows to specify that a queued uORB topic being bridged should
have its queue drained completely at every rate interval, instead of sending
only the latest message. This is useful to prevent jitter and delay being
added on topics subject to burst and irregular publishing patterns.

The "unlimited" rate option allows to specify that a uORB topic being bridged
should be sent as fast as possible, without any rate limiting. This is useful
for reducing latency on topics where no message loss is acceptable and where
the uORB topic is being published at a high rate.

* fix(dds_topics): remove "drain" option and safe guard against inf loop

Drain option is removed to be coupled with rate_limit = unlimited.

The loop is gated to the size of the uorb queue to avoid infinite loops
if publisher is faster that this loop.

* fix(dds_topics): simplification recommended in review
2026-07-03 12:14:40 -07:00
f19c9f98c5 fix(tecs): prevent NaN propagation in pitch controller (#27749)
* tecs: Prevent. NaN in pitch integrator

Prevents NaN propagation into _pitch_integ_state when seb_rate.setpoint is non-finite (as seen when exiting FW velocity Offboard). Mirrors the existing throttle integrator finite check. Fixes #25906.

* tecs: Harden the TECS pitch integrator against NaN contamination

* fix(tecs): guard pitch output against non-finite SEB rate

The integrator guard alone does not prevent the reported NaN lockup when
the non-finite value originates on the energy/speed side: the feedforward
and damping terms in _calcPitchControlOutput feed seb_rate straight into
the pitch demand, bypassing the integrator. constrain() does not reject
NaN, so the pitch setpoint latches NaN permanently and the aircraft
becomes uncontrollable.

Fall back to the (now guaranteed finite) integrator state when the
uncorrected pitch setpoint is non-finite, and drop the stray trailing
whitespace introduced by the previous commit.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>

* test(tecs): regression test for NaN pitch integrator and output

Drives TECSControl::update with a non-finite true airspeed setpoint, the
same way seb_rate goes non-finite on the energy/speed side when exiting
offboard velocity mode, and asserts the pitch integrator state and the
pitch setpoint both stay finite, across a single bad frame and sustained
non-finite input. Both assertions fail against unguarded TECS.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>

* test(tecs): cover the corrupted-integrator-state safety reset

Addresses review feedback on #27749: the existing tests inject a
non-finite airspeed setpoint, which the integrator-input guard rejects
before it can reach _pitch_integ_state, so the state-corruption reset
branch in _calcPitchControlUpdate was never actually exercised.

Add a FRIEND_TEST seam so the regression test can pre-corrupt
_pitch_integ_state directly, then confirm a single update() call detects
the non-finite state, resets it, and keeps the pitch setpoint finite.
Verified the test fails against the code with the reset guard removed and
passes with it in place.

---------

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
Co-authored-by: Ryan Johnston <31726584+ryanjAA@users.noreply.github.com>
Co-authored-by: Ryan Johnston <rjohnston@appliedaeronautics.com>
2026-07-03 11:58:33 -07:00
Alexis Guijarro f903391f44 feat(drivers): add DPS368 variant support via -8 flag (#27724)
* feat(drivers/dps310): add DPS368 variant support via -8 flag

Register DRV_BARO_DEVTYPE_DPS368 (0x77) and extend the dps310 driver
entry point with a -8 flag to select the DPS368 devtype at startup.

* fix(drivers/dps310): set device type from devid_driver_index after init
2026-07-03 10:00:03 -07:00
Balduin 580e9750fd refactor(sih): use basic Publication + class member
needs less flash
2026-07-03 09:48:22 -07:00
Balduin d8847067a8 refactor(sih): remove local variable to save stack
A recent SIH log (V6X) was full of:

WARNING: [px4] [load_mon] sih low on stack! (144 bytes left)

Using PublicationData (which holds the esc_status_s in heap rather than
stack) fixes them and adheres to the philosophy from the module
description: "Most of the variables are declared global in the .hpp file
to avoid stack overflow"
2026-07-03 09:48:22 -07:00
Julian Oes 94c12f468c fix(mc_pos_control): allow disabling trajectory time-stretch and fix docs
The trajectory time-stretch is skipped when the max-error param is at or below
FLT_EPSILON, so zero is a valid 'disabled' setting. Lower the minimum of
MPC_XY_ERR_MAX and MPC_Z_ERR_MAX from 0.1 to 0 so users can actually select it,
and document it in both params.

Also fix the setMaxAllowedVerticalError() doc comment, which incorrectly
claimed zero was the default: the MPC_Z_ERR_MAX param default is 1 m.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-03 09:46:48 -07:00
Julian Oes 49535090a8 refactor(motion_planning): remove unused clampToXYNorm/clampToZNorm
These helpers are no longer called from production code after the smoother
was reworked to clamp XY and Z velocity components independently. Their only
remaining references were in TrajectoryConstraintsTest.cpp, which is not
registered in CMake and therefore never compiled. Drop both the functions and
the orphaned tests.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-03 09:46:48 -07:00