Commit Graph
51529 Commits
Author SHA1 Message Date
Benjamin Cabé 33109cd71d fix(top): stop when the input can't be polled (#29227) 2026-10-16 15:43:00 +02:00
PX4BuildBot 4d7e4de777 docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-10-16 12:01:21 +00:00
Saibernard Yogendran fefe51e8e0 test(commander): cover Offboard loss without manual control
Two cases that fail without the fix, NAV_RCL_ACT 7 and a value outside
the list, both ending in Hold, and one with manual control available
that pins the Position mode fallback.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
2026-10-16 13:43:55 +02:00
Saibernard Yogendran 68a2124f5c fix(commander): hold on Offboard loss without manual control for NAV_RCL_ACT 7
An Offboard vehicle without manual control, the companion computer
setup that NAV_RCL_ACT 7 "Hold mode (no failsafe)" was added for,
stayed in Offboard when its companion stopped. #26289 made the
Offboard loss fallback into Position mode use the NAV_RCL_ACT action
instead when manual control is lost, since Position mode needs it.
Value 7 maps that action to None, because Commander switches to Hold
on its own, but that switch only fires while a manual mode is flown.
So the vehicle kept flying its last setpoint, with a velocity
setpoint that means flying off, and nothing was reported.

The replacement now maps None to Hold, which is what value 7 promises,
and the action cascade escalates to Return and Land from there when
Hold cannot run. The manual control loss trigger itself is untouched
and still takes no failsafe action for value 7.

In SITL with the sih quadcopter, no manual control and a velocity
setpoint stream that stops, main kept flying at 0.9 m/s for the whole
12 s watched. With this change the vehicle is in Hold 1.4 s after the
stream stopped. Both changes are in v1.18.0-rc1.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
2026-10-16 13:43:55 +02:00
Silvan 12b111c3cc docs(return): update geofence avoidance limits and messages
The page still described the old fixed 99-vertex limit, which since #28929
is set by GF_AVOID_NODES. The mission path return warning also contradicted
the geofence awareness table: RTL_TYPE 2 is not wired to the avoidance
planner. List the user-facing messages so returns can be diagnosed from logs.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Silvan <silvan@auterion.com>
2026-10-16 13:31:15 +02:00
Benjamin Cabé 44159002d3 fix(board_adc): stop when requested and free the samples with delete[] (#29225)
Run() never checked should_exit(), so board_adc stop waited 5 s, printed "timeout, forcing stop", failed and deleted the driver from the shell while its work item could still run. The destructor also freed the samples, allocated with new[], with delete.

Assisted-by: Claude:opus-5.5

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-15 15:10:56 -06:00
VincelloandFarhang cd0a3eded7 fix(boards/corvon_743v2): replace stale Kconfig symbols (#28753)
The default build omits fixed-wing position control and the MS4525DO
driver. Use the current symbols and drop the obsolete ones.

Signed-off-by: holydust <holydust@live.ca>
Co-authored-by: Farhang <46557204+farhangnaderi@users.noreply.github.com>
2026-10-15 16:05:32 -04:00
Silvan 43c6d582ad feat(fw_rate_control): remove 2% thrust motor cutoff
This avoids non-linear beahvior around the 2% mark, especially when the motor
has a slew rate defined (as it is the case for IC engines).

Signed-off-by: Silvan <silvan@auterion.com>
2026-10-15 14:09:11 +02:00
fe0662edb1 fix(fixed-wing): Update underspeed detection thresholds, add bank limiting (#26859)
Underspeed mitigation used to ramp in from tas_min - 0.15*trim and only
reached full effect at tas_min - 0.30*trim. On typical airframes this was
below stall, so in practice the protection never kicked in.

- Start the ramp at tas_min. It reaches full effect at 90% of tas_min, or
  halfway to tas_stall if that is higher (a step if stall >= min). The
  stall airspeed comes from FW_AIRSPD_STALL via the performance model and
  is load-factor and flaps compensated, like the minimum airspeed. Drop
  the hardcoded tas_error_percentage.
- While the underspeed ratio is above 0.5, reset the altitude reference to
  the current state. This stops altitude error from building up and then
  commanding a hard pitch-up (and a possible secondary stall) on recovery.
- Blend the roll limit from FW_R_LIM down to min(20 deg, FW_R_LIM) as the
  underspeed ratio rises, ahead of the roll slew-rate limit, to reduce load
  factor during recovery.
- Add TECS unit tests for the ramp, the stall handling and the altitude
  reference hold.

Takeoff and landing turn underspeed protection off, so none of this
applies there.

---------

Signed-off-by: RomanBapst <bapstroman@gmail.com>
Co-authored-by: RomanBapst <bapstroman@gmail.com>
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
2026-10-15 12:08:57 +00:00
PX4BuildBot eacf497fa0 docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-10-15 10:15:49 +00:00
Federico MagriandSilvan Fuhrer de2b404dc4 feat(fw): allow autolanding without flare (#29173)
* feat(fw): allow autolanding without flare

* Update src/modules/fw_mode_manager/fw_mode_manager_params.yaml

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

---------

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
2026-10-15 12:09:50 +02:00
PX4BuildBot f13d47d034 docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-10-15 06:38:38 +00:00
Silvan Fuhrer b4134d75f2 feat(tecs): don't trade altitude for speed above trim airspeed (#29009)
* fix(tecs): don't trade altitude for speed above trim airspeed

With an airspeed setpoint above trim and the throttle at `FW_THR_MAX`, TECS pitches down to
keep chasing the setpoint and settles below the altitude setpoint.
Accelerating above trim should be the throttle's job; losing altitude at high speed is not wanted.

The pitch loop now sees the airspeed setpoint capped at max(trim, current airspeed);
the throttle loop still tracks the full setpoint. Below trim, pitch still trades height for speed, up to trim.
Overspeed above the setpoint is still corrected with pitch.
The cap fades out as the effective `FW_T_SPDWEIGHT` goes from 1 to 2, so gliders (weight 2),
fast descend and underspeed recovery keep using pitch to reach their airspeed.
The behaviour is documented in the TECS docs and the `FW_T_SPDWEIGHT` description.

Signed-off-by: Silvan <silvan@auterion.com>

* fix(tecs): use tas and not tas_sp for the pitch loop

Signed-off-by: Silvan <silvan@auterion.com>

* fix(tecs): don't counter throttle acceleration with pitch above trim

Capping the pitch loop's airspeed setpoint at max(trim, airspeed) keeps
pitch from diving to gain speed, but between trim and the setpoint the
throttle's acceleration still shows up in the kinetic energy rate
estimate. Against a kinetic energy rate setpoint of zero, the pitch loop
then pitches up and turns the throttle's energy into height. At a speed
weight of 1 this halves the acceleration and lifts the vehicle above the
altitude setpoint while accelerating.

Remove the kinetic term, setpoint and estimate, from the pitch loop
between trim and the setpoint, so pitch controls height only there. As
for the cap, this fades out with speed priority.

Point-mass simulation with the TECS defaults, speed step from 15 m/s:
- to 20 m/s: 95% of the step in 21 s instead of 37 s, 1.2 m instead of
  2.4 m above the altitude setpoint
- to 28 m/s, above the 24.7 m/s the vehicle can reach: 2.2 m instead of
  5.2 m above the altitude setpoint, still no altitude loss
- deceleration, climbs, a speed weight of 2 and cruise at trim are
  unchanged; in turbulent cruise above trim the pitch rate RMS is 6%
  higher, as the kinetic term switches when the airspeed crosses the
  setpoint

The remaining rise comes from the lift gained with speed at constant
pitch, which only altitude feedback corrects.

Assisted-by: Claude:claude-opus-5-5

* fix(tecs): fade the pitch loop's kinetic setpoint only once

Between trim airspeed and the airspeed setpoint, the capped pitch loop
setpoint already fades the kinetic energy rate setpoint in with the
speed weight between 1 and 2. Scaling it by the same fade factor again
faded the setpoint quadratically but the estimate only linearly, so at a
speed weight of 1.5 the pitch loop countered acceleration it should only
half ignore. Scale only the estimate.

Speed weights up to 1 and of 2 are unaffected. In a point-mass
simulation at a speed weight of 1.5, a step from 15 to 20 m/s now takes
30 s instead of 37 s and rises 1.6 m instead of 2.4 m, between the
results at weights 1 and 2 instead of worse than both.

Assisted-by: Claude:claude-opus-5-5

* docs(tecs): show the pitch and throttle speed roles in a diagram

The paragraph on how pitch and throttle share speed control above trim
was hard to follow. Show the three regions of measured airspeed (below
trim, between trim and the setpoint, above the setpoint) with what the
pitch and throttle loops do in each, and describe each region in its own
bullet. Also state that there is no middle region with a setpoint at or
below trim.

Assisted-by: Claude:claude-opus-5-5

---------

Signed-off-by: Silvan <silvan@auterion.com>
2026-10-15 08:33:02 +02:00
Yang-Rui Li 1ae8c9e135 fix(mavlink): do not hold the shell mutex while writing to the shell (#28928)
* fix(mavlink): do not hold the shell mutex while writing to the shell

The receiver thread held _mavlink_shell_mutex while writing SERIAL_CONTROL
input into the shell pipes. That write blocks while a pipe is full, and the
only thread that drains the shell output (Mavlink::handleMavlinkShellOutput())
needs the same mutex, so both threads deadlock and the MAVLink instance stops
sending entirely (no more HEARTBEAT) until reboot.

Two paths trigger it:
- input arrives while the shell output pipe is full (e.g. during 'ver all'):
  the input echo added in #28242 blocks on the output pipe.
- more input than the input pipe holds (CONFIG_DEV_PIPE_SIZE, 70 bytes)
  arrives while a command runs: the shell does not read its input then.

The shell is only created and deleted by the receiver thread, so it can use
the shell without the lock. Keep the lock only around get_shell() and
close_shell(), which is what the race fixed in #25082 needs.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yang-Rui Li <yang77567789@gmail.com>

* docs(mavlink): clarify which shell pipe needs the lock to drain

The input pipe is drained by the shell itself, only the output pipe is
drained by Mavlink::handleMavlinkShellOutput(), which takes the lock.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yang-Rui Li <yang77567789@gmail.com>

* fix(mavlink): make the shell pointer atomic

Mavlink::handleMavlinkShellOutput() checks _mavlink_shell without the lock
before taking it, while the receiver thread sets and clears the pointer
under the lock. ThreadSanitizer reports this as a data race.

Make the pointer a px4::atomic, so the check without the lock is an atomic
load. Under the lock, load it once and use the local copy.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yang-Rui Li <yang77567789@gmail.com>

---------

Signed-off-by: Yang-Rui Li <yang77567789@gmail.com>
2026-10-15 17:19:49 +13:00
Isak Åslund 2d1cdfc4c9 fix(motion_planning): fly legs that change altitude as a straight line (#29021)
* revert(motion_planning): restore clampToXYNorm and clampToZNorm

This reverts commit 49535090a8.

The straight-leg option added in the next commit needs these helpers again.

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>

* fix(motion_planning): fly legs that change altitude as a straight line

1ae8f2383f made the smoother compute the XY and Z velocity towards the next
waypoint independently, each at its own limit. On a leg that changes altitude
the vehicle no longer flies a straight line: at 6 m/s XY and 1.5 m/s Z, a
climb from 10 to 60 m over 100 m arrives over the waypoint about 20 m low
and climbs the rest vertically, and a descent from 60 to 10 m over 400 m
reaches 10 m halfway and flies the rest level, up to 30 m below the line
(SIH).

Go back to one 3D velocity along the line to the waypoint, scaled to fit both
limits, so the slower axis limits the other and the leg is straight. Waypoint
navigation is expected to follow the straight line between the waypoints.

Fixes #29020

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>

---------

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>
2026-10-15 17:17:21 +13:00
Jonas Peroliniandjonas 7cc4bc18b5 build(modules): remove MAX_CUSTOM_OPT_LEVEL from SIH and config-mode builds (#29208)
* build(simulation): remove MAX_CUSTOM_OPT_LEVEL from SIH build (back to -Os)

* build(build): remove MAX_CUSTOM_OPT_LEVEL on other config and idle modes

* build(control_allocation): remove MAX_CUSTOM_OPT_LEVEL from actuator effectiveness lib

* build(logger): use default optimization for setup helpers

* build(modules): remove size optimisation from ActuatorEffectiveness and follow_target_estimator

* build(flight_mode): remove MAX_CUSTOM_OPT_LEVEL from follow_target_estimator

---------

Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-14 20:21:22 -06:00
e146fe4cc6 fix(uorb): keep shared topics advertised on publisher teardown (#29176)
* fix(dataman_client): keep request topic advertised on client teardown

* fix(uorb): keep shared topics advertised on publisher teardown

Single-instance publications share one advertised flag, so destroying one
publisher must not hide updates from the others.

Keep automatic unadvertising in PublicationMultiBase and remove the
DatamanClient workaround. Cover surviving publishers and instance reuse,
and reset retained input samples between test cases.

Tested: make tests (215/215), make format.
Signed-off-by: jonas <jonas.perolini@rigi.tech>
Assisted-by: Codex

* docs(uorb): correct unadvertise comments and document teardown

The unadvertise comment claimed it has no effect on single-instance
topics, which is how one publisher's teardown came to hide the others.
State what clearing the shared flag does, and document that only
PublicationMulti releases its instance on destruction.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: jonas <jonas.perolini@rigi.tech>

* test(uorb): keep test cases independent of retained samples

A destroyed single-instance publication now leaves its last sample
visible, so ManualControlTest, test_prec_takeoff and mixer_module_tests
passed only in declaration order and failed under --gtest_shuffle.
Reset with an inert sample where one exists, otherwise unadvertise the
test's own publications, and drop module outputs left over from a
previous case.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: jonas <jonas.perolini@rigi.tech>

* fix(boards): drop the PublicationBase destructor from the ITCM lists

The destructor is now trivial and no longer emitted, so itcm_check.py
fails on the missing section.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

---------

Signed-off-by: jonas <jonas.perolini@rigi.tech>
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: jonas <jonas.perolini@rigi.tech>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-14 16:53:20 -06:00
Saibernard fd66527244 fix(precland): start at the current position when selected as a mode (#29050)
* fix(precland): start at the current position when selected as a mode

Since #27836 Precision Land continues to whatever valid setpoint the
previous mode left. When it is selected during a mission, that setpoint
is the active waypoint, so without a target in view the vehicle flies
all the way there before it searches or lands. A mission landing starts
Precision Land from within its own mode, with the setpoint already at
its land point, and that holds when the landing goes on after Return
was commanded, so the setpoint is continued only then. Selected as a
flight mode, Precision Land starts at the current position again, as
it did before #27836. Only main is affected, release/1.18 still clears
the triplet when Precision Land is selected.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>

* test(precland): cover where Precision Land starts

Selected as a flight mode while a mission waypoint a kilometre away is
the current setpoint, Precision Land has to start at the current
position, and the same without any setpoint. Started by a mission land
item with precision landing once the move to land waypoint is accepted
a few metres short, it keeps the land point, also when Return was
commanded during that landing and the mission goes on. Started by a
mission without a valid setpoint it lands at the current position. The
first case fails without the fix, the Return case fails when only
Mission is allowed to continue the setpoint.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>

---------

Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
2026-10-14 16:29:52 -06:00
Hamish Willee 67a9e81d42 docs: replace GNSS blending text with receiver selection (#29098)
* docs: replace GNSS blending text with receiver selection

GNSS blending and SENS_GNSS_MASK were removed in #28921, but the dual
receiver section of the EKF tuning guide and three ARK DroneCAN pages
still told users to configure it, through links to a parameter that no
longer exists.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

* Apply suggestion from @hamishwillee

---------

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
2026-10-14 15:24:42 -06:00
SaibernardandJacob Dahl 1168b1a8e7 fix(temperature_compensation): mag fallback read the accel sample into a baro struct (#28997)
* fix(temperature_compensation): read the barometer, not the accelerometer, for a magnetometer without a temperature

A magnetometer that reports no temperature, which is most compasses,
is meant to take the primary barometer's. The fallback copied the
primary accelerometer's sample into a barometer struct instead. The
accelerometer sample is 48 bytes and the barometer struct is 40, so
every copy wrote 8 bytes past the end of a stack variable in the
module's work queue, once a second, and the value published as the
magnetometer's temperature was the accelerometer's y axis.

The barometer entry of the corrections also carried the calibration
slot index after a parameter update instead of the device id, so the
consumer, which matches on the device id, found no correction for it
until the next temperature change wrote the id again. The other three
sensor types write the device id there.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>

* test(temperature_compensation): cover the temperature fallbacks and the published device ids

The module's first tests. Four cases drive Run() with queued sensor
samples, as on a vehicle where the sensors publish far faster than the
module runs. Without the fix the magnetometer case aborts under
AddressSanitizer with the stack buffer overflow and the barometer case
sees the slot index in place of the device id.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>

* test(temperature_compensation): drop the module tests

The barometer device id test asserted a state that baroPoll() overwrites before
anything is published, two tests covered unchanged fallbacks, and the
magnetometer test guarded a one-off typo. They cost a friend hook in the module
header and depended on private members, uORB queue lengths and the shared
parameter store.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

---------

Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-14 12:54:40 -06:00
Benjamin Cabé fb29b85b63 fix(bench): download the logs that take longer than 4 s (#29220)
The logs were downloaded with process_ftp_reply() called in slices of 4.2 s, to send heartbeats between them and to detect a stall. pymavlink terminates the session when process_ftp_reply() times out, so any download longer than one slice was aborted at its first byte count, and reported as stalled at 0 bytes after 30 s: a 290 KB log over a serial link at 115200 baud, or a long log over a telemetry radio. The download is now driven in one call bounded by the budget, the idle detection of pymavlink detects a stall, and the heartbeats are sent from the progress callback.

Assisted-by: Claude:opus-5.5
2026-10-14 12:33:19 -06:00
2114fe2f78 fix(sensors): use the previous angle in the coning correction (#29215)
* fix(sensors): use the previous angle in the coning correction

The coning term crossed each increment with the angle accumulated two
samples back instead of through the previous sample, as in the cited
reference. At the default rates it removed 21 % of the coning drift
within an integration window instead of 83 %.

Assisted-by: Claude:claude-opus-5-5

* refactor(sensors): fix coning test license header

* refactor(sensors_integrator): simplify alpha state to a single member

* fix(sensors): clear the previous increment after a sample gap

An invalid dt restarts the trapezoid from the current sample, but the
next coning term still crossed the first increment with the one from
before the gap.

Assisted-by: Claude:claude-opus-5-5

* refactor(sensors): fix the previous increment comment

Assisted-by: Claude:claude-opus-5-5

---------

Co-authored-by: Matthias Grob <maetugr@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-14 11:21:03 -06:00
Benjamin Cabé 9a1429ae90 fix(platforms): sleep with nanosleep() in px4_usleep() (#29218)
* fix(platforms/common): sleep with nanosleep() in px4_usleep()

Outside of the SITL lockstep build, px4_usleep() was usleep(). POSIX only requires usleep() to accept less than 1000000 microseconds and lets it fail with EINVAL from there; POSIX.1-2001 marked it obsolescent and POSIX.1-2008 removed it in favour of nanosleep(). glibc, NuttX and macOS sleep for longer anyway, but other implementations return EINVAL at once, and as no caller checks the result, the sleep would silently not happen. More than twenty call sites ask for a second or more, such as uorb top, mavlink, the ESC calibration or voxl2_io, and some durations are computed at run time, such as the one-second idle period of the POSIX HRT thread.

Outside of the lockstep build, px4_usleep() is now a px4_platform function that converts the microseconds to the timespec of nanosleep(), so the call sites keep passing microseconds of any duration. It is not inline: expanding the conversion at every call site grew px4_fmu-v6xrt_default by 4 kB of flash. QURT has no nanosleep(), which PX4 only stubs there, but its usleep() accepts a second or more, so px4_usleep() remains usleep() there. system_usleep() remains usleep(), for the wall-clock sleeps that bypass the lockstep scheduler.

A signal still ends the sleep early, with -1 and EINTR, rather than restarting it for the remaining time: on POSIX, the HRT and work queue threads sleep in px4_usleep(), and hrt_work_queue() and work_queue() wake them with SIGCONT, so a restarted sleep would delay hrt_call_*() callouts by up to a second. On NuttX, no PX4 code signals its tasks, and px4_task_delete() does not depend on the sleep returning: without cancellation points, which no board enables, task_delete() terminates the task wherever it is.

Failures are now -1 with errno, where the usleep() of NuttX returned the error number. No call site checks the result, so none changes. The sleep test now also sleeps for 1.2 s.

Assisted-by: Claude:opus-5.5

* perf(boards): keep the sleep path in ITCM on i.MX RT boards

The ITCM lists of these boards hold the sleep path of NuttX: usleep(), clock_nanosleep() and nxsig_nanosleep(). px4_usleep() now enters it through its own function and nanosleep(), which take the place of usleep(), so the path stays in ITCM. usleep() remains linked for the code that still calls it directly, such as the start-up code of the boards and NSH.

Assisted-by: Claude:opus-5.5

* fix(drivers): sleep for a second or more with px4_usleep()

bmi088_i2c, microstrain, frsky_telemetry and the bit rate detection of the kinetis, stm32 and stm32h7 UAVCAN drivers asked usleep() for a second or more, which POSIX doesn't require it to accept. The usleep() of NuttX accepts it, but px4_usleep() now does on every platform.

Assisted-by: Claude:opus-5.5
2026-10-14 10:36:30 -06:00
Andrew Brahim c06973172f Revert "fix(lightware): consume exactly the parsed frame (#29167)" (#29219)
This reverts commit 1341c655e7.
2026-10-14 09:38:35 -06:00
bresch 7635d64f97 fix(ekf2): set Earth rate and gravity near the equator
The Earth rate and gravity were only evaluated once the latitude moved
more than 1 deg away from a reference initialised to 0, so within 1 deg
of the equator the filter kept a zero Earth rate and standard gravity.
Evaluate them at the first latitude known after the origin is set.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: bresch <brescianimathieu@gmail.com>
2026-10-14 17:03:05 +02:00
Jonas Perolini 6130b089a2 refactor(ekf2): move inlined helpers out of headers to save flash (#29206) 2026-10-14 15:29:40 +02:00
PX4BuildBot 8f6b41fbad docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-10-14 11:50:28 +00:00
b457d486fb feat(commander): relax GNSS redundancy check (#29188)
* feat(commander): let COM_GNSSLOSS_ACT decide whether GNSS loss blocks arming

The GNSS redundancy check blocked arming whenever fewer receivers than
SYS_HAS_NUM_GNSS were healthy, regardless of COM_GNSSLOSS_ACT. Setups that
want a warning only had no way to arm. Arming is now blocked only when
COM_GNSSLOSS_ACT is above Warning, and the new value 4 (Block arming +
In-flight warning) keeps the previous on-ground behavior without an in-flight
failsafe action.

Receivers can report an optimistic eph, which made the divergence gate fire
on receivers that agree within their real accuracy. The reported eph is now
floored with EKF2_GPS_P_NOISE, looked up at runtime so commander does not
depend on EKF2 being part of the build.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>

* fix(commander): Avoid param_get() log spam when EKF2 parameter is unavailable

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix(commander): Fix formatting issue

* fix(gnssRedundancyCheck): shorten parameter option string for blocked arming

* fix(gnssRedundancyCheck): simplify logic to decide when to block arming

---------

Signed-off-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Matthias Grob <maetugr@gmail.com>
2026-10-14 13:34:40 +02:00
Balduin 317a681cae fix(airspeed_selector): do not invalidate a sensor on the cycle it is detected (#29214)
* fix(airspeed_selector): do not invalidate a sensor on the cycle it is detected

A sensor that starts publishing after the selector's init (e.g. the SITL
airspeed sim, which waits for a global position) was flagged stale on the
first cycle after detection: its last-update timestamp was still zero, so
the 1 s missing-data timeout fired before a single sample was read. With
ASPD_FS_T_START at its default of -1 the validator never recovers, the
selected source stays DISABLED and preflight reports "Airspeed invalid".

Seed the timestamp when a new sensor index is detected so the timeout
counts from detection. Also silence the DISABLED-to-sensor transition
message, which otherwise reports a spurious "healthy, start using again".

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Balduin <balduin@auterion.com>

* fix(airspeed_selector): only silence reporting when new sensor added

* fix(airspeed_selector): remove newly dead line

 - this time is always set check_for_connected_airspeed_sensors
 - there it depends on:
     - primary index set - otherwise nothing really happens
     - i >= _number_of_airspeed_sensors: always true on init

* test(mavsdk_tests): give the VTOL return with approaches 180 s to disarm

The flight from the end of the approach check to disarm takes about 155 s
of autopilot time, over the 150 s budget. The test only passed because
poll_condition_with_timeout checks elapsed time once per 15 s of autopilot
time and usually landed a check before the budget ran out; when the
lockstep sim ran slightly faster than the speed factor the disarm fell
inside a poll sleep and the test timed out at 158 s.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Balduin <balduin@auterion.com>

---------

Signed-off-by: Balduin <balduin@auterion.com>
2026-10-14 13:20:58 +02:00
Benjamin Cabé 1064bf28f7 fix(safety_button): blink the 16 bits of each safety LED pattern
The driver runs at 30 Hz and shows each bit of the 16-bit LED pattern for 3 runs, as the PX4IO firmware shows one per run at 10 Hz, but it restarted the pattern after 46 runs instead of 48: the last bit lasted one run instead of three, and each pattern 1.52 s instead of 1.58 s.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 12:35:20 +02:00
Benjamin Cabé fe434f93e6 fix(safety_button): show the safety state on the safety LED
On the boards without PX4IO, the driver blinks the safety LED with the patterns of the PX4IO firmware: a slow blink while safety is on and the vehicle disarmed, a quad blink while armed with safety on, a double blink once safety is off, and solid on while armed with safety off. It selected the safety off patterns while the button was pressed, as it doesn't keep the safety state, which Commander holds, so that the LED showed the button instead of the safety state. It now follows safety_off of vehicle_status, which the px4io driver passes to the PX4IO firmware for its safety LED.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 12:30:59 +02:00
Benjamin Cabé 7b09390bdd fix(crsf_rc): drain the UART each cycle at high ELRS packet rates
Each cycle read at most 64 bytes and then waited 4 ms, so the driver
drained less than 16 kB/s. An ExpressLRS receiver sends a 26-byte RC
channels frame per received packet, about 26 kB/s at the 1000 Hz rates
(F1000, K1000). The UART receive buffer, of 256 to 800 bytes on the
NuttX boards, then fills within 25 to 80 ms and drops bytes for as long
as the link runs: frames fail their CRC, and the ones that get through
are 16 to 50 ms old.

Keep reading while a read fills the buffer. Parsing each 64-byte chunk
before reading the next keeps the parser queue from overflowing.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 12:11:58 +02:00
Benjamin Cabé c76ba712e0 fix(romfs): add the missing space in tune_control play -t 17
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 12:10:40 +02:00
Benjamin Cabé cfef6b0bac fix(tune_control): play the note given with -f
tune_control play -f <frequency> -d <duration> fills a custom tune, tune ID 0, with the note, but then replaced the tune ID 0 with 1, the startup tune, so the tone alarm played the startup tune instead of the note. The startup tune is now the default only when neither a tune nor a frequency is given.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 12:09:58 +02:00
Benjamin Cabé f9858e1fb7 fix(tone_alarm): stop without waiting for the next note
The driver only checks should_exit() in Run(), which is not scheduled while no tune is played, and is scheduled at the next note while a tune is played. "tone_alarm stop" then waited for the next note, or for its 5 s timeout and deleted the driver with "timeout, forcing stop" when no tune was played. The driver now schedules Run() when it is asked to stop.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 12:08:40 +02:00
Benjamin Cabé 0ea6a82b3d fix(tone_alarm): cancel the end of the note when the driver stops
The driver ends each note with an HRT callout on its _hrt_call member. When the driver stopped while a note was playing, the callout stayed queued after the object was deleted, and the HRT then read the freed hrt_call at the end of the note and called InterruptStopNote() from it, or crashed if the memory had been reused.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 12:07:52 +02:00
Benjamin Cabé 5d6b1c2c67 fix(cyphal): depend on the mixer module
The Cyphal driver includes the mixer module, whose output functions header is generated, without depending on it: it was only generated because other modules of the boards need it too.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 11:59:27 +02:00
Benjamin Cabé 5aa935ef23 fix(uavcan): depend on the libraries and MAVLink headers it uses
The DroneCAN driver uses the battery, tunes and circuit breaker libraries, and its remote ID controller the MAVLink headers, without depending on them: they were only built because other modules of the boards need them too. The driver now depends on these libraries, and the remote ID controller is built with the MAVLink module only, after its headers are generated.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 11:59:27 +02:00
Benjamin Cabé b48d4397af fix(cyphal): initialize and free the CAN interface and heap
The CAN interface of the Cyphal driver was only set when a CAN interface is built in, but always closed and deleted without a check. The heap of libcanard was allocated with memalign(), which is not standard and only NuttX declares in stdlib.h, and freed with delete. The interface now starts as nullptr and is checked, and the heap is allocated with aligned_alloc() and freed with free(). The unused network and ioctl headers are no longer included.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 11:55:19 +02:00
Benjamin Cabé a53b5a615a fix(cyphal): ignore a register list response that doesn't deserialize
NodeManager::HandleListResponse() used the response even when it failed to deserialize, with its name length uninitialized, which GCC 14 reports at -O2.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 11:55:05 +02:00
Benjamin Cabé 9d5d5c4dda build(cmake): allow building PX4 as a CMake subproject
Let another CMake project build PX4 with add_subdirectory(), for instance the build system of an RTOS that links the firmware image. A subproject leaves to its parent project what applies to the whole build:

- the build type and ccache, which affect every target
- the CMake cache: the board configuration is kept in normal variables, so that its CONFIG_* entries do not mix with the parent project's
- the firmware image, so the airframe metadata, packaging and size analysis targets are not created

PX4's CMake modules are prepended to the module path, so that modules of the parent project with the same name, such as kconfig or ccache, do not replace them. Standalone builds are unchanged.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-14 11:41:53 +02:00
bresch 30e4a1c78e fix(ekf2): add transport rate to the attitude prediction
The NED frame rotates with the vehicle's motion over the curved Earth,
not only with the Earth itself. The velocity prediction already used the
transport rate, but the attitude prediction left it out, tilting the
attitude by v/R during dead reckoning.

Assisted-by: Claude:claude-opus-5-5
2026-10-14 10:56:40 +02:00
bresch 1624564f79 fix(ekf2): remove Earth rate from the zero gyro update
At rest the gyro measures the Earth rotation in addition to its bias.
Fusing the raw rate as a bias observation made the bias absorb the Earth
rate, which the prediction then subtracted a second time once moving,
drifting the attitude by up to 15 deg/h.

Assisted-by: Claude:claude-opus-5-5
2026-10-14 10:56:40 +02:00
PX4BuildBot 5d0b8f090b docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-10-14 08:56:14 +00:00
Akash KarkeraandHamish Willee d57419e2c8 fix(commander): introduce a mode_not_supported flag to route rovers to Stabilized mode on position loss (#28696)
* Refactor rover failsafe: Replace Parked mode with mode_req_not_possible flag

* Rename unsupported flag and restrict from ground station UI

* Complete global rename of mode_not_supported flag

* Apply PX4 CI code formatting

* Apply PX4 CI code formatting for ui.hpp

* Restrict VTOL/Descend on rovers and reroute fallback to disarm

* docs(rover): add failsafe fallback cascade to manual modes

* fix(failsafe): update rover fallback docs, honor COM_POS_FS_ACT, and add unit test

* style: fix indentation for CI

* docs: move rover failsafe sequence to end of page and format

* docs(rover): move failsafe fallback sequence to drive modes overview

The fallback cascade applies across rover drive modes rather than to
Manual mode specifically, so it belongs on the parent overview page.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

---------

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
2026-10-14 10:50:06 +02:00
Mathieu BrescianiandJacob Dahl 49b856b500 fix(lat_lon_alt): correct meridian radius of curvature (#29171)
* fix(lat_lon_alt): correct meridian radius of curvature

The meridian radius divided by (1 - e^2 sin^2(lat))^2.5 instead of ^1.5,
mis-scaling north displacements in EKF2 global position propagation by
up to 0.67 % (0.36 % at 47 deg latitude).

Reported-by: SunyangLi <54950309+SunyangLi@users.noreply.github.com>
Assisted-by: Claude:claude-opus-5-5

* test(lat_lon_alt): sweep the ECEF round trip over real latitudes

The loop passed radians to the degrees constructor, so the round trip only covered latitudes within 3.14 degrees of the equator.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-13 18:48:01 -06:00
treston 0d25f6c081 fix(control_allocator): clamp the surface and tilt counts with plain comparisons (#29203)
Assisted-by: Claude:claude-fable-5-1
2026-10-13 22:32:37 +01:00
Jacob Dahl 633af12ea4 fix(boards): drive PWM outputs low at reset instead of input pull-up (#28746)
* fix(boards): drive PWM outputs low at reset instead of input pull-up

board_on_reset() was written in 2017 to put the FMU timer pins into a
driven low state so ESCs see a defined level from reset until the
output driver claims them. The fmu-v5 refactor in 54bd0a9f2a switched
the pin list to GPIO_INPUT|GPIO_PULLUP without comment, and the 2020
timer-config refactor propagated that as PX4_MAKE_GPIO_INPUT() to every
board derived from fmu-v5. The px4/fmu-v2..v4 lineage and later
px4/fmu-v6x (#19535) kept the driven low output.

A weak pull-up on the motor line is the state the AM32 bootloader
treats as "stay in the bootloader": it tests the pin against its own
pull-down and only jumps to the application on a clean low
(am32-firmware/AM32-bootloader#24). On boards where the MCU pin goes
straight to the ESC pad, a battery-only boot therefore leaves the ESCs
uninitialised (#27696, #28731). A weak pull in either direction also
leaves unassigned channels high impedance, so edges on a neighbouring
DShot line couple in and can spin a motor with no output assigned
(#26525). The 2021 attempt at pull-downs (#17686) hit the same problem
from the other side.

Switch the remaining STM32, kinetis and rt106x boards to
io_timer_channel_get_gpio_output(), matching the boards that already
drive low. The rt117x boards are unchanged because their input macro
has no pull.

The ARK boards additionally overrode the reset state with a pull-down
via PX4_GPIO_INIT_LIST; those entries are removed so the driven low
from board_on_reset() stands.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

* fix(boards): keep capture channels as inputs and cover the missed boards

Driving every timer pin low at reset also drove the capture channels on
fmu-v5, fmu-v5x, fmu-v6u, durandal-v1, pix32v5 and corvon/v5, where a GPS
PPS or camera output may be wired. Until pps_capture or camera_capture
claims the pin, that output would fight a push-pull low, so those
channels keep their previous input state.

The three fmu-v6xrt boards float their PWM pins through a different
input macro and zenfc/h743 landed after this branch was cut; all four now
drive low as well.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-13 15:10:19 -06:00
trestonandJacob Dahl 95ede794c0 fix(control_allocator): clamp the control surface and tilt counts to their maximum (#29130)
CA_SV_CS_COUNT and CA_SV_TL_COUNT size loops over fixed arrays, and a parameter's range is not enforced when it is set, so an out-of-range count indexed past them.

Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-13 11:10:39 -06:00
ASHUTOSH VISHWAKARMAandJacob Dahl b11126a00c fix(collision_prevention): bound body-frame obstacle loop to BIN_COUNT (#27826)
A body-frame OBSTACLE_DISTANCE with bins narrower than 5° made the loop read past the 72-entry distances array and add made-up obstacles to the map. The world-frame branch already had this bound.

Signed-off-by: ragnar-vallhala <ashutoshvishwakarma208@outlook.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-13 11:07:24 -06:00