Commit Graph
50618 Commits
Author SHA1 Message Date
Ramon Roche 6d1773f4c1 docs(releases): sync the v1.18 notes from main
Copies docs/en/releases/1.18.md from main at 83960122a5 (#29843), which
now holds everything this branch's copy had plus the notes edits made on
main since the branch was cut. Seven of those notes commits were never
backported, so the file is synced whole instead of cherry-picked.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
v1.18.0-rc2
2026-11-17 09:54:02 -08:00
pkwr-air 824dd4c75a fix(USB): prevent hardfault on unplugging [v1.18] (#29187)
* fix(cdcacm_autostart): wait for mavlink stop before serdis on USB unplug

  On VBUS loss, 'mavlink stop' was spawned and serdis called on the next
  cycle without waiting for the stop to finish. serdis could then tear
  down the CDC/ACM driver while mavlink still had /dev/ttyACM0 open,
  causing a use-after-free in the driver (hardfault in cdcacm_recvpacket).

  Keep the pid of the stop task and only run serdis once it has exited
  (polled with kill(pid, 0), up to 5 s). waitpid() is not used because
  CONFIG_SCHED_WAITPID is not enabled on all boards. Also log
  exec_builtin() failures.

* fix(mavlink): close log files in the receiver thread

  The log handler opens the log file in the receiver thread, but on
  'mavlink stop' its destructor ran in the stop task and fclose()d it
  there. On NuttX a FILE belongs to the task group that opened it:
  fclose() from another task frees it while it stays linked in the
  owner's stream list, and the owner frees it again on exit. This double
  free corrupted the heap when USB was unplugged during a log download
  (hardfault in mm_free, or load_mon hanging in mallinfo()).

  Close the files at the end of MavlinkReceiver::run(), in the owning
  thread.

* fix(nuttx): update submodule with CDC/ACM use-after-free fix

  - drivers/serial,usbdev/cdcacm: free cdcacm device on last close
    (adapted from apache/nuttx#12199)
  - drivers/usbdev/cdcacm: flush rxpending on reset and harden paths
    after unbind
2026-11-17 10:38:54 +13:00
Hamish Willee e95bcda092 fix(mavlink): accept DO_SET_ROI_WPNEXT_OFFSET pitch/roll/yaw offsets (#29758)
The param validation table allowed only param1 for
MAV_CMD_DO_SET_ROI_WPNEXT_OFFSET, but params 5-7 carry the pitch, roll and
yaw offsets that navigator copies into vehicle_roi and the gimbal applies.

As a result, every QGroundControl Structure Scan upload was rejected
(INVALID_PARAM5, or INVALID_PARAM7 with a zero gimbal pitch, because QGC
sends a 90 degree yaw offset), and the command form was denied.

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

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
(cherry picked from commit 5a533b77d1)
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-11-16 12:37:55 -08:00
Yang Hau 094b080262 fix(mavlink): reject SET_ATTITUDE_TARGET with a non-finite thrust (#29328)
A NaN thrust setpoint means "stop the motors on that axis" to the control
allocator. SET_ATTITUDE_TARGET validated the attitude but passed thrust
through unchecked, so a companion sending a NaN thrust stopped all lift
motors of a multicopter in Offboard, while the message kept the offboard
heartbeat alive so the offboard loss failsafe never triggered.

Drop the whole message, as is already done for an unusable attitude.

Tested in SIH: streaming SET_ATTITUDE_TARGET with a NaN thrust in Offboard
no longer produces a non-finite vehicle_thrust_setpoint; the offboard loss
failsafe takes over and the vehicle holds altitude.
(cherry picked from commit 6d2620a418)
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-11-16 12:37:55 -08:00
Mathieu Bresciani ae111266eb 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>
(cherry picked from commit 2114fe2f78)
[release/1.18 has no src/modules/sensors/test directory (added on main by #28811);
 create it with only the coning test and add the BUILD_TESTING hook]
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-11-16 12:37:55 -08:00
treston ad0a4867b5 fix(control_allocator): zero non-finite torque setpoint components (#29156)
* fix(control_allocator): zero non-finite torque setpoint components

vehicle_torque_setpoint is also written by external producers over
uXRCE-DDS and Zenoh. The torque vector was copied unchecked while the
thrust path is sanitised; one NaN component makes every actuator
setpoint NaN, which the mixer maps to the disarmed output. Zero
non-finite components as the rate controllers do, on both allocation
instances (and the second instance's thrust).

* fix(control_allocator): note that the second instance has no NaN based motor stopping
(cherry picked from commit e50af4085d)
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-11-16 12:37:55 -08:00
treston 8f3a392f4d fix(mavlink): fit a full-size signed frame in the send buffer (#29164)
send_bytes() rejected a chunk when it filled the buffer exactly. The
buffer is MAVLINK_MAX_PACKET_LEN (280) bytes, which is the size of a
signed frame with a 255-byte payload, so the last chunk of such a frame
(its signature) was dropped while the rest was sent with the signed
flag set. With signing enabled every LOGGING_DATA frame of the MAVLink
log streaming was unparsable and the receiver also lost the following
frame.
(cherry picked from commit 0a33696cb9)
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-11-16 12:37:55 -08:00
Isak Åslund 9d8cfcfc91 fix(ekf2): keep the output predictor attitude correction in earth frame (#29062)
* fix(ekf2): keep the output predictor attitude correction in earth frame

The attitude correction is the error between the EKF and the output
predictor at the delayed fusion time horizon, expressed in the body
frame at that time. It was added unchanged to the delta angle at the
current time horizon, where the body has turned by yaw rate x delay.
Above about 61 deg (7 rad/s with a 150 ms delay) this feedback loop is
unstable and vehicle_attitude diverges while the EKF state stays right,
e.g. when a quadrotor spins after losing a motor.

Hold the correction in earth frame and express it in the current body
frame when it is applied. This is the same as correcting at the delayed
horizon and integrating the gyro forward. Attitude resets rotate the
earth frame, so they rotate the held correction too.

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

* test(ekf2): check output predictor attitude tracking while spinning

Drive the output predictor with a constant body rate about roll, pitch
or yaw and a perfect but delayed EKF attitude: an attitude error must
be removed at 0 to 25 rad/s. The old body-frame correction fails at
7 rad/s and above on every axis.

Also check that a yaw reset commutes with a pending attitude correction.

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

* refactor(ekf2): compute output predictor attitude error in earth frame

Form the attitude tracking error directly as an earth-frame rotation
instead of computing it in the delayed body frame and rotating it out;
the result is identical and saves a vector rotation per EKF update.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: bresch <brescianimathieu@gmail.com>

---------

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>
Signed-off-by: bresch <brescianimathieu@gmail.com>
Co-authored-by: bresch <brescianimathieu@gmail.com>
(cherry picked from commit 004f014719)
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-11-16 12:37:55 -08:00
FARHANG 727f5f5b5f fix(boards/matek-h743): match bootloader BOARD_TYPE to Matek H743 board ID
PX4-Bootloader/board_types.txt assigns 1013 to Matek H743 and 139 to
Durandal. hw_config.h's BOARD_TYPE was hardcoded to 139 (Durandal's
ID) on both h743 and h743-mini, causing QGroundControl to reject
flashing with a "board ID 1013 != 139" mismatch.

Fixes #27731

Signed-off-by: FARHANG <farhang.nba@gmail.com>
(cherry picked from commit 0b7837cccf)
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-11-16 10:39:58 -08:00
PX4BuildBot 01f0eeefa5 docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-11-16 18:21:43 +00:00
Jacob Dahl 43c3ee2857 fix(gps): run a moving base and its rover at 5 Hz on every board (#28986)
* fix(gps): run a moving base and its rover at 5 Hz on every board

PX4-GPSDrivers f6f5c2d89a (PX4/PX4-GPSDrivers#244, with the style pass of #245): a moving base and its rover must share one navigation and measurement rate, and u-blox caps a moving base at 5 Hz on the F9P and the X20P. With the board defaults (F9P 5 Hz, X20P 10 Hz) a mixed pair was mismatched and the X20P rover reported no heading for the epochs its base never observed.

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

* docs(gps): moving base and rover share one navigation rate

The driver now holds both to 5 Hz in the moving base modes; the pages say so and tell the reader to leave GPS_UBX_RATE at 0.

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

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
(cherry picked from commit b12d17f632)

The submodule points at the port of PX4/PX4-GPSDrivers#244 to that repo's release/1.18 branch.
2026-11-16 10:15:19 -08:00
Ahmet Burak Tektas 2ceaf38c6a fix(metadata): document the parameters that moved to yaml files (#29389)
#26833 moved the spacecraft and systemcmds/tests parameters from
params.c to yaml files, which metadata_parameters does not read: the
yaml glob has no src/systemcmds, and the spacecraft filter drops
everything under spacecraft/. The filter was for the module.yaml that
#24734 removed, so it only hides parameters now.

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

Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>
(cherry picked from commit af36aca5ab)
2026-11-16 10:01:26 -08:00
Holybro-zebulon-86 19c81f3829 feat(boards): add LSM6DSV support for Kakute H7 Wing (#28780)
* feat(boards): add LSM6DSV support for Kakute H7 Wing

* fix(boards): lower Kakute H7 Wing OSD work queue priority

Run SPI2 below the SPI3 IMU queue to reduce delays caused by ATXXXX updates.

(cherry picked from commit 5a09e55fbc)
2026-11-16 09:58:42 -08:00
Holybro-Zebulon 84ecbb64ec feat(boards/px4_fmu-v6x): add LSM6DSV fallback support (#29697)
Probe ICM45686 and IIM42653 first on V6X008 and start LSM6DSV only when neither is detected, preserving existing IMU priority.

Assisted-by: Codex

Signed-off-by: Brown <zebulon-86@outlook.com>
Co-authored-by: Farhang <46557204+farhangnaderi@users.noreply.github.com>
(cherry picked from commit 100d257c91)
2026-11-16 09:57:31 -08:00
Jukka Laitinen df57a0730f fix(boards/fmu-v6x): Restore IMU driver startup on fmu-v6x rev 6 (#29403)
The commit f0a2fa9369 broke the ADIS and iim42652; it mistakenly
changes the spi setup for revision 6, instead of revision 8.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Co-authored-by: Jukka Laitinen <jukka.laitinen@tii.ae>
(cherry picked from commit a20be2f551)
2026-11-16 09:57:31 -08:00
Jacob Dahl 2521f1d01c feat(boards/ark_fmu-v6x): add the LSM6DSV32X revision
The ARKV6X-32X is the ARKV6X with three LSM6DSV32X in place of the
IIM-42653s, on the same pads and at the same orientations. It reports
FMUM ID 2, which matched no sensor set, so no IMU started.

Backport of the board change in #29767.

Assisted-by: Claude:claude-fable-5-2
2026-11-16 09:57:17 -08:00
Ramon Roche e068e63c76 fix(lockstep_scheduler): stop swallowing wakeups in cond_timedwait
cond_timedwait() re-waited on a 10 ms wall-clock timeout until either a
signal or its virtual timeout arrived. A signal from the caller's own
signaler (px4_sem_post, or the unit test's broadcast) that lands while
the waiter is between that wall-clock timeout and re-acquiring the mutex
finds no waiter and is lost, so the waiter sleeps until its virtual
timeout. In lockstep_scheduler_test nothing else advances time and the
test hangs; in SITL a posted semaphore can report ETIMEDOUT late.

The loop is not needed: the caller holds the mutex until
pthread_cond_wait() releases it and set_absolute_time() takes that
mutex before broadcasting, so a timeout broadcast cannot be missed. The
original signal loss came from the MAX_WAKEUPS cap that the signal_next
list already removed. Go back to a single wait and keep the three-phase
signaling.

Refs #28862

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
(cherry picked from commit 1fd3a84780)
Signed-off-by: Jeff Pierson <77620925+jpierson-at-riis@users.noreply.github.com>
2026-11-16 09:53:27 -08:00
Julian Oes 3d192a2aa0 fix(lockstep_scheduler): fix signal-loss race and ABBA deadlock
Two related thread-safety fixes for the cond_timedwait + set_absolute_time
dance, both surfaced under TSan with multi-instance Mavlink and a fast
sim clock advance:

1. Signal loss between releasing _timed_waits_mutex and entering
   pthread_cond_wait. set_absolute_time could have already broadcast
   to a waiter that hadn't actually started waiting yet, and the
   broadcast would be missed -> wait blocks forever.

   Fix: cond_timedwait uses pthread_cond_timedwait with a short
   wall-clock timeout (10 ms) and re-checks the timeout flag. Lost
   signals turn into a maximum of one loop iteration of latency.

2. ABBA between (passed_lock -> _timed_waits_mutex) used by
   cond_timedwait to mark `done`, and (passed_lock under
   _timed_waits_mutex) used by set_absolute_time to broadcast. TSan
   flagged the inversion immediately.

   Fix: split set_absolute_time into three phases. Phase 1 marks
   timed_outs and stages waiters onto a per-call signal_next list,
   under _timed_waits_mutex only. Phase 2 broadcasts to each waiter,
   outside _timed_waits_mutex but under a new _signaling_mutex held
   for the duration. Phase 3 clears _setting_time under the
   _timed_waits_mutex again.

   The waiter's "dance" (when it sees _setting_time still true on
   exit) acquires _signaling_mutex first, then _timed_waits_mutex,
   guaranteeing it cannot return — and let its stack-local
   passed_lock/passed_cond go out of scope — until set_absolute_time
   has finished signaling.

The TimedWait::timeout flag also becomes std::atomic<bool> since it
is now read by cond_timedwait without holding _timed_waits_mutex.

(cherry picked from commit 27a21488b2)
Signed-off-by: Jeff Pierson <77620925+jpierson-at-riis@users.noreply.github.com>
2026-11-16 09:53:27 -08:00
Jacob Dahl ad5d437be7 fix(uavcan): make DroneCAN time sync work on SocketCAN (#28458)
The FC-side GlobalTimeSyncMaster needs the TX timestamp of its previous
sync frame, delivered by a loopback receive; without it every broadcast
carries previous_transmission_timestamp_usec 0 and slaves never adjust.
The SocketCAN platform had no loopback at all, never filled the UTC
timestamp of received frames, and clock::adjustUtc() was a stub, so the
UTC clock was wall time rather than the HRT base the sensor bridges
expect. Time sync was therefore a silent no-op on every i.MX RT, Kinetis
and S32K board.

Frames sent with CanIOFlagLoopback are now handed back from receive()
stamped at the moment they entered a hardware mailbox: NuttX has no TX
echo, so this stands in for the true transmission time with a bias of at
most one frame time when the sync frame wins arbitration. All received
frames get a UTC timestamp derived from SO_TIMESTAMP, and SystemClock is
one shared instance whose first adjustUtc() is absolute, so the existing
hrt_absolute_time() seed makes bus time equal HRT as on STM32.

(cherry picked from commit 5208271705)

Conflict in socketcan.hpp: release/1.18 lacks the bus error and bitrate declarations from #28457; kept only hasLoopbackPending().

Assisted-by: Claude:claude-opus-5-5
2026-11-16 09:52:59 -08:00
Jacob Dahl c1602945a0 fix(uavcan): publish UNKNOWN node timestamps until time-synced and map them through the bus time base on the FC (#28176)
* fix(uavcannode): publish UNKNOWN until time-synced and fix RawIMU integration_interval units

The RawIMU and RangeSensor publishers computed the bus timestamp as
getUtcTime() - (hrt_now - sample_hrt). getUtcTime() is 0 until the time-sync
master disciplines the node's clock, so the unsigned subtraction underflowed and
the truncated uint56 field went out as ~7.2e16 us. Publish UNKNOWN until the
clock is disciplined, from one shared helper.

RawIMU.integration_interval is specified in seconds but was assigned
vehicle_imu.delta_angle_dt, which is in microseconds.

* fix(uavcan): map node timestamps through the bus time base in the sensor bridges

The accel, gyro and rangefinder bridges took msg.timestamp.usec verbatim as
timestamp_sample whenever it was non-zero, which assumes the bus shared time
base is HRT. It is not: the FC seeds its bus clock from HRT only after its own
init has run, so the base leads HRT by that duration, and the FC may also be a
slave to a lower node ID master. An undisciplined node, or one stamping a
foreign epoch, put the sample time arbitrarily far from HRT.

The CAN ISR stamps every received transfer in the same bus base the node used,
so the sample age is the difference between the two. Bound that age to a
plausible transport window and subtract it from the receive time, falling back
to the receive time otherwise, in one shared helper.

* fix(uavcan): stamp RelPosHeading and BatteryInfoAux in the bus base, map RelPosHeading on the FC

Both node publishers put node-local time into a bus-base field, and the
FC took the RelPosHeading stamp verbatim as HRT. Same defect as RawIMU
and RangeSensorMeasurement, same two helpers.

* fix(uavcan): read the bus clock and HRT together when mapping node timestamps

The ISR receive stamp is taken at the first frame of a transfer while HRT was
read in the callback, so the transfer and scheduling latency stayed in
timestamp_sample as jitter. Sampling both clocks at the same instant cancels
the bus-to-HRT offset exactly. The node-side helper takes the node for the same
reason.

The FC bus base leads HRT by the free-running timer phase at seeding, not by
the init duration; correct the comment.

* fix(uavcan): send true point samples in RawIMU and consume the integral on the FC

RawIMU.*_latest carried the window mean, delta / integration_interval,
under a field the DSDL defines as the latest point sample. The mean lags
the message timestamp by half the interval, 2.5 ms at IMU_INTEG_RATE 200,
and the FC published it as an instantaneous rate at the window end.

The node now fills *_latest from the sensor_gyro / sensor_accel instance
behind vehicle_imu, the same batch-end sample every PX4 IMU driver
produces, and keeps the integrals and timestamp as they were.

The FC bridges now consume the integral when one is present: divided by
its interval it is float32 rather than float16, anti-aliased against the
node's full-rate stream, and successive means spaced one interval apart
integrate back to the node's exact delta angle in VehicleIMU. It is
stamped at the window centroid. The point sample is used only when the
node reports no integral, as the DSDL specifies.

(cherry picked from commit 4af7b4e77e)
2026-11-16 09:52:59 -08:00
XiaoYang Chen 1224aa32fb fix null pointer dereference bug in param module (#28475)
Co-authored-by: godess <cxy2648680758@icloud.com>
(cherry picked from commit 02eabc08c9)
Assisted-by: GLM:glm-5.3-flash
Signed-off-by: jiakun <53556221+ddwolf87@users.noreply.github.com>
2026-11-16 09:52:39 -08:00
Jacob Dahl 54f886288b 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>
(cherry picked from commit 633af12ea4)

Dropped the agam and ARK fmu-v6xrt, nwblue pro-h757, tustin mach and zenfc h743 changes, because those boards are not on release/1.18.
2026-11-16 07:57:43 -08:00
Julian Oes bc510dbfd9 fix(mavlink): let a UDP client reconnect from a new port (#28518)
Once PX4 has latched onto a UDP client address, it keeps sending there
forever. A client that is restarted comes back with a different ephemeral
source port, so PX4 talks into the void and only a reboot brings the link
back. This is easy to hit when connecting straight to PX4's local port
(e.g. 18570) instead of listening on 14550/14540, which is what makes
some setups such as docker easier.

Instead of dropping the latched address on a timer, hand it over only
when someone else actually shows up: every incoming packet either
refreshes the latch, or - if it comes from a different source and the
current client has been quiet for 3 seconds - takes it over. A client
that only listens is therefore left alone, and an address configured
with -t or -c is never replaced.

The UDP read now resets nread before polling. It is declared outside the
loop and only assigned when POLLIN is set, so on a POLLERR wake-up the
stale value would have the previous buffer parsed again. It also lets
the source address comparison rely on nread to know it is valid.

Assisted-by: Claude:claude-opus-5

Signed-off-by: Julian Oes <julian@oes.ch>
(cherry picked from commit bc1eb6c062)
2026-11-16 07:57:30 -08:00
Julian Oes c8e321d1b7 fix(mavlink): accept unsigned traffic only on traffic receiver links (#29488)
(cherry picked from commit 36919f8415)

Dropped the SECURITY_SCOPE.md change, because release/1.18 has no such file.
2026-11-16 07:57:11 -08:00
Jacob Dahl d66af0321b fix(mavlink): compare the whole storage prefix in the FTP write check
The write check compared 12 bytes against CONFIG_BOARD_ROOT_PATH "/", which only fits "/fs/microsd/". On the /fs/flash boards the comparison runs past the end of the prefix, so every FTP write, create, remove, rename and mkdir was rejected.

Backport of the prefix length fix from #28582, without its POSIX root split.

Assisted-by: Claude:claude-opus-5-5
2026-11-16 07:56:54 -08:00
PX4BuildBot 1e1d238f81 docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-11-16 15:33:12 +00:00
Ramon Roche 7bc8abd8be test(ekf2): init the hrt in EKF2SelectorTest
The test starts the hrt worker without hrt_init(), so the callout lock
stays a default non-recursive mutex and the worker deadlocks on its own
nested lock in hrt_tim_isr() -> hrt_call_invoke() the first time a tick
fires. The selector's 10 ms backup reschedule normally keeps pushing the
tick out, so it only fires when Run() pauses under load or in the slower
Coverage build, where it hangs the test until the ctest timeout.
VehicleAirDataTest and VehicleMagnetometerTest already do this.

Refs #28862

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
(cherry picked from commit 2ce73120bd)
2026-11-16 07:26:09 -08:00
Jacob Dahl fac92f5be3 fix(dshot): reject invalid GCR telemetry symbols (#29553)
Illegal 5-bit GCR symbols decoded to 0x0, so a corrupted frame could alias a valid zero nibble and pass the 4-bit checksum, producing a false eRPM or EDT sample. Of all 2^20 received words the old decoder accepted 61440; only the 4096 valid codewords should pass.

Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit ed3c3c5553)

Hand-ported: release/1.18 decodes i.MX RT telemetry inline in up_bdshot_erpm() rather than in decode_gcr_payload(), which came with #28412. Its baud training compares the raw frame and never decodes it, so only the telemetry check changes.
2026-11-16 07:26:09 -08:00
Jacob Dahl 5aec4a3877 fix(uORB): unregister callback subscriptions before the subclass is destroyed (#29515)
A publisher calls call() under the node lock until the subscription is
unregistered. SubscriptionBlocking, SubscriptionCallbackWorkItem and
the MCP CallbackHandler left that to ~SubscriptionCallback(), which runs
after the subclass is gone, so a publication during destruction aborted
with "pure virtual method called". SubscriptionBlocking could also signal
its already destroyed condition variable. SITL mag calibration in SIH hit
this on almost every side.

The new functional test aborts on both subscription types within about
a second without the fix.

Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit ade867b1a5)
2026-11-16 07:26:09 -08:00
Jacob Dahl 76bd1d162c test(ekf2): trim the origin assertions to the ones that pin the fix
The Earth-rate components repeat the gravity check, and the local
position continuity is already covered by EkfFlowTest.deadReckoning.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
(cherry picked from commit 834919094d)
2026-11-16 07:26:09 -08:00
Jacob Dahl 0baae26810 fix(ekf2): place the global position at a manually set first origin
Before horizontal aiding is valid, setLatLonOrigin initialised the origin
but left _gpos at lat/lon (0, 0). The Earth rate, gravity and magnetic
field model are evaluated from _gpos once the origin is valid, so an
origin set on the ground before a GNSS fix or before flow/EV aiding ran
them at the equator until a later global position reset, and for a
flow-only flight never recovered. With aiding already valid, the
reprojection went through resetHorizontalPositionTo, whose delta spans
the frame switch and reported a position reset of thousands of km
although the local position did not move.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
(cherry picked from commit fd9fe58df8)
2026-11-16 07:26:09 -08:00
Jacob Dahl c55679977e fix(mavlink): ignore DISTANCE_SENSOR on a distance sensor link (#29454)
A rangefinder peripheral such as the ARK DIST sends its ranges on a link in distance_sensor mode. The flight controller streams every range it has back on that link, the peripheral's own included, and the peripheral published each one as a second distance_sensor instance, which its DISTANCE_SENSOR stream then sent back out. On the flight controller the peripheral's own range came back a round trip late, and any other rangefinder's range came back labelled as the peripheral. A distance sensor link exists only to send ranges, so ignore the ones it receives.

Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 4464ae66b5)
2026-11-16 07:26:09 -08:00
Julian Oes d00c2af091 fix(payload_deliverer): zero-initialize the gripper vehicle command
The gripper command sent at boot left all fields except command, param2
and timestamp uninitialized, so from_external and the target fields held
stack garbage. UBSAN caught an invalid bool load in the COMMAND_LONG
stream.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
(cherry picked from commit 75ab97e389)
2026-11-16 07:26:09 -08:00
Jacob Dahl 5798e0fd98 fix(afbrs50): keep the AFBR-S50 device type in the device ID (#29104)
set_device_type writes the device ID's devtype, so passing the MAVLink sensor type there replaced DRV_DIST_DEVTYPE_AFBRS50 with 0 and every AFBR-S50 reported an unknown device. The MAVLink type belongs in set_rangefinder_type.

(cherry picked from commit 97a3c7f017)
2026-11-16 07:26:09 -08:00
Jacob Dahl 71dd16ed2d fix(ekf2): publish the sideslip innovation variance in wind (#29080)
Since 408c30de13 the variance overwrote beta_innov, so the wind topic carried the variance in place of the innovation and beta_innov_var was always 0.

Assisted-by: Claude:claude-opus-5-5
(cherry picked from commit 9e36a52ab7)
2026-11-16 07:26:09 -08:00
Isak Åslund b364d30a88 fix(mc_att_control): reject invalid attitude setpoints (#29008)
* fix(mc_att_control): ignore invalid attitude setpoints in the reference model

Since the reference model (2a0e048171, PR #27255) the controller tracks _q_ref,
which is integrated from its previous value and only snapped to the setpoint on
the first call. A single attitude setpoint with a zero or non-finite quaternion
(normalizing a zero quaternion gives NaN) therefore makes _q_ref NaN for the rest
of the boot: every later setpoint is ignored, the rate setpoint stays NaN and the
vehicle has no attitude control, even after a mode switch. Before the reference
model the controller used q_d directly, so a bad sample only lasted one cycle.

One MAVLink SET_ATTITUDE_TARGET with q = [0, 0, 0, 0] in Offboard reproduces it
in SIH: vehicle_rates_setpoint stays NaN and the vehicle no longer responds to
the sticks after switching to Position mode.

Ignore setpoints and heading-reset deltas that are zero or non-finite, keeping
the last valid reference, and snap the reference to the next valid setpoint if
it ever becomes non-finite.

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

* fix(mc_att_control): drop the whole attitude setpoint when its quaternion is invalid

When the controller rejects an invalid quaternion, the thrust and timestamp
from the same message were still applied. The vehicle then flew the last
valid attitude with thrust from a message that cannot be trusted.

setAttitudeSetpoint() now returns whether the setpoint was accepted. The
thrust and the setpoint timestamp are only updated when it was. Keeping the
timestamp also gives the next valid setpoint the true dt since the last
accepted one.

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

* fix(mc_att_control): reject overflowing quaternions and drop invalid SET_ATTITUDE_TARGET

Review follow-ups:
- Validate the setpoint through its norm. A quaternion with a finite component
  above ~1.8e19 (e.g. q = (1e20, 0, 0, 0)) passed isAllFinite(), its norm
  overflowed to inf and normalizing it gave a zero quaternion. As the first
  setpoint this made the reference NaN for the next setpoint. One finite norm
  check rejects NaN, inf, zero and overflow.
- Drop the ref_valid / dt finiteness recovery branch: with every input of the
  reference model validated it cannot be reached, and it costs flash.
- Drop the adaptAttitudeSetpoint() guard: no estimator publishes an invalid
  delta with a changed reset counter, and it only protected the reference,
  not the yaw setpoint and StickYaw that use the same delta.
- MAVLink SET_ATTITUDE_TARGET: drop a message with an unusable q before
  publishing offboard_control_mode. Otherwise a companion streaming only
  invalid quaternions keeps the offboard heartbeat alive and the vehicle holds
  the last valid tilt and thrust indefinitely without triggering
  COM_OF_LOSS_T.

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

* docs(offboard): note that SET_ATTITUDE_TARGET with an invalid q is dropped

Since the previous commit, such a message no longer counts as the offboard
signal, which is a behavior change MAVLink users can see. Also name the 1e-3
norm threshold in the setAttitudeSetpoint() doc, and point the MAVLink and
controller checks at each other: if the MAVLink threshold were lowered below
the controller's, messages the controller drops would keep offboard alive.

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

---------

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>
(cherry picked from commit 7902349f7a)
2026-11-16 07:26:09 -08:00
Jacob Dahl 22b0d48f88 fix(sensor_calibration): default external accel/gyro priority below internal (#28594)
External IMUs inherited the magnetometer's external-first default of 75,
so an uncalibrated CAN IMU (ARK Flow, X20) took over as primary gyro the
moment it appeared, ahead of the on-board FIFO IMUs, and a calibration
then saved that priority. A magnetometer away from the power electronics
is the better primary; an IMU behind a bus with its own clock, transport
latency and no heater is not. Default external accel and gyro to Low (25)
so they only win when explicitly prioritized.

(cherry picked from commit 2322c173aa)
2026-11-16 07:26:09 -08:00
Jacob Dahl 44222e3b79 fix(commander): capture home on the ground before motors spin (#27734)
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>
(cherry picked from commit 0a441d9443)
2026-11-16 07:26:09 -08:00
Jacob Dahl 216b59329f fix(drivers/icm45686): retry WHO_AM_I on probe instead of requiring three matches (#28319)
The loop advertised three attempts but returned on the first mismatch, so a single garbage SPI read after power-up failed the probe. Match the ICM42688P retry: succeed on the first good ID, fail after three.

Assisted-by: Grok:grok-4.6

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
(cherry picked from commit a0071377f1)
2026-11-16 07:26:09 -08:00
PX4BuildBot 8303efda43 docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-11-11 22:48:19 +00:00
a58b94f81a fix(ekf2): keep v1.17 auxiliary global position settings on upgrade [1.18] (#29541)
* fix(ekf2): keep v1.17 auxiliary global position settings on upgrade (#29351)

* fix(parameters): migrate EKF2_AGP_* to EKF2_AGP0_*

The auxiliary global position parameters became per-source EKF2_AGP<n>_*
parameters in #26306 without a translation, so on an upgrade from v1.17
the stored EKF2_AGP_CTRL, _MODE, _DELAY, _NOISE and _GATE are dropped as
unrecognised. Move them to the first slot.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* fix(ekf2): mark EKF2_AGPn_ID as reboot required

The sources are created when EKF2 starts, for the slots whose ID is not
zero, so a changed ID only takes effect after a reboot.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* docs: explain EKF2_AGPn_ID for auxiliary global position

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* fix(parameters): set EKF2_AGP0_ID when migrating a v1.17 AGP source

Migrating EKF2_AGP_* alone fuses nothing: a slot with ID 0 has no source. v1.17 messages had no ID, but a v1.17 source now arrives with ID 1 either way, from the message translation node or as GlobalPositionMeasurementInterface's default, so a non-zero EKF2_AGP_CTRL also sets EKF2_AGP0_ID to 1.

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

---------

Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
(cherry picked from commit b3cee891b2)

* fix(ekf2): gate the auxiliary global position fusion on bit 0 of EKF2_AGPn_CTRL (#29204)

The parameter is documented as a bitmask but was only tested for non-zero, so bit 1 alone (vertical position, which has no fusion path) enabled the horizontal fusion. Gate on bit 0 and document bit 1 as reserved.

Fixes #29153

Assisted-by: Claude:claude-fable-5-1
(cherry picked from commit 77c04dcc4c)
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* docs(releases): note the new EKF2_AGPn_NOISE default

Only stored values are migrated, so a vehicle on the v1.17 default of
0.9 m takes the new default of 1.0 m.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

---------

Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: treston <jonhhjackson@gmail.com>
2026-11-11 15:42:11 -07:00
Tiberiu Gingu 0342c82f09 fix(boards/mr_tropic): place bootloader USB DMA buffers in DTCM)
Move the MR-VMU-TROPIC bootloader's USB DMA buffers into DTCM (non-cacheable)
to fix a cache-coherency failure that prevented flashing via QGroundControl

Signed-off-by: Tiberiu Gingu <tiberiu.gingu@nxp.com>
2026-11-11 13:22:23 +01:00
PX4BuildBot e1ccc2641d docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-11-09 09:30:01 +00:00
Matthias Grob c6ddbe1499 feat(commander)!: combine battery and bingo fuel failsafe into COM_LOW_BAT_ACT (#29620) 2026-11-09 10:22:41 +01:00
jiakun fedc33bdea fix(sensors): skip baro GNSS offset without baro samples (#29634)
Backport of the baro change from #28943 to release/1.18: with a baro
publishing at or below SENS_BARO_RATE (e.g. DroneCAN baros), the 50 ms
backup run can reach the offset calibration with zero accumulated baro
samples, and the _data_sum_count division yields NaN that feeds the
baro-GNSS altitude offset LPF.

Guard the division the same way as on main (e6db1b3a14), adapted to
the release/1.18 subscription (_vehicle_gps_position_sub), which main
has since renamed to _vehicle_gnss_sub.

Assisted-by: GLM:glm-5.3-flash

Signed-off-by: jiakun <53556221+ddwolf87@users.noreply.github.com>
2026-11-05 10:53:19 -07:00
PX4BuildBot 8c8de17ede docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-11-05 16:59:04 +00:00
Jacob Dahl c3f3442c12 [BACKPORT 1.18] fix(drivers/imu): InvenSense FIFO scale, invalid samples and clipping (#29529)
* fix(drivers/invensense): always publish full-scale FIFO data (#28134)

Publish the 16 bit FIFO registers directly and set the scale once in
Configure(), removing the dual decode pass and the per-batch scale
switch. The 20 bit extension nibble is no longer used.

Also corrects the IIM42653 range, which reported +/-16 g and +/-2000 dps
while ACCEL_CONFIG0/GYRO_CONFIG0 program +/-32 g and +/-4000 dps.

(cherry picked from commit 7eede5e670)

* fix(drivers/invensense): drop invalid gyro FIFO samples (#28308)

With FIFO_HOLD_LAST_DATA_EN clear the sensor inserts -32768 for accel and gyro samples that carry no data (power-on until the first ODR sample, a disabled sensor, mismatched ODRs) and limits valid samples to -32766..+32767. The accel path already drops these; the gyro path published them as negative full scale.

(cherry picked from commit 243936abe2)

* fix(drivers/imu): clip FIFO samples against the declared range, not the int16 rail (#28310)

* fix(drivers/imu): clip FIFO samples against the declared range, not the int16 rail

updateFIFO() counted a sample as clipped only within 1 LSB of INT16_MIN
or INT16_MAX, while update() compares against _clip_limit (range/scale).
The two agree only for sensors whose sensitivity is exactly range/32768.
ST parts leave headroom in the word: the LSM6DSV80X high-g channel at
+/-80 g and 3.904 mg/LSB saturates at 20492 counts, its gyro at
+/-4000 dps and 140 mdps/LSB at 28571, the LSM9DS1 and ADIS16607 are
similar, and the BMI055's 12-bit accel word never reaches the rail at
all. None of them could report a clip on the FIFO path, so the EKF's
delta-velocity clipping handling never engaged on those sensors.

Compare against _clip_limit on the FIFO path as well. For rail-scaled
sensors the threshold moves from 32766 to 32735 counts (the existing
0.999 margin), which is what the non-FIFO path already used.

* docs(msg): SensorGyroFifo/SensorAccelFifo counts are raw, not SI

x/y/z are int16 counts; SI is count * scale. The comments called them
rad/s and m/s^2, which is what sensor_gyro/sensor_accel carry.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
(cherry picked from commit b4f9388cd9)

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-11-05 09:53:10 -07:00
Jacob Dahl 3d50ebba3b fix(ekf2): don't reset yaw to an inaccurate GNSS heading (#28846) (#29534)
Nothing checked the reported heading accuracy before GNSS yaw fusion started, and the reset always claimed the default heading noise, so a receiver still resolving its baseline could align yaw to a heading it reported with a 172 deg accuracy.

(cherry picked from commit c7db242da4)

Hand-ported: release/1.18 has no separate GNSS heading buffer (#27102), so the accuracy gate reads gnss_sample.yaw_acc, and the test sets it through the GPS simulator, which gains setYawAccuracy().

Assisted-by: Claude:claude-opus-5-5
2026-11-04 11:22:55 -07:00
PX4BuildBot 42d3f1d151 docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
2026-11-03 19:24:44 +00:00
fe1bd3e03a fix(simulation): prevent unbounded memory growth in GstCameraSystem (#27873) (#29591)
* fix(simulation): prevent unbounded memory growth in GstCameraSystem

Each CameraStream pushed camera frames into an appsrc with no queue
bound (block=false, enough-data unhandled) and never read the pipeline
bus, so when the pipeline stalled the frames accumulated silently at
frame_size x fps (~110 MB/s per camera at 1280x960@30) until the host
froze. The stall is guaranteed on modern NVIDIA drivers because the
nvh264enc path sets legacy NVENC properties they reject, killing caps
negotiation before data ever flows, while set_state() only being
checked for FAILURE (pipelines with sinks return ASYNC) hid the error.

Bound the appsrc queue (max-buffers=3, leaky-type=downstream) so a
stalled pipeline drops frames instead of hoarding them, surface bus
errors/warnings through gzerr/gzwarn, verify the async transition to
PLAYING, retry once with software x264 when the NVIDIA encoder fails,
drop the driver-incompatible encoder properties, and guard the frame
memcpy against undersized frames. Also make ~CameraStream() call
stop() unconditionally: after a pipeline failure (_running == false)
the streaming thread could still be joinable, and destroying a
joinable std::thread terminates the process.



* fix(simulation): end the camera stream loop on stop during pipeline setup

stop() can run before runPipeline() sets _running, which then overwrote the cleared flag; the frame loop never checked _stopRequested, so join() blocked gz shutdown. The pipeline cleanup in stop() was unreachable: runPipeline() releases the pipeline on every return.

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

* fix(simulation): retry the camera stream with x264 only after an NVENC failure

The retry fired on any pipeline error, including runs where the NVIDIA element was never created and x264 was already in use, so it rebuilt the same pipeline under a misleading warning.

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

* fix(simulation): drop the PLAYING wait from the camera stream start

It cannot see an encoder failure, which happens on the first frame, and with rtmpsink it blocked for the full 5 s because the sink cannot preroll until this thread pushes a frame. The bus loop reports both kinds of failure.

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

* fix(simulation): warn once about undersized camera frames

The warning fired on every frame at the camera rate. GST_MESSAGE_SRC_NAME also handles a bus message without a source.

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

---------



(cherry picked from commit 4b1ac1879d)

Signed-off-by: PasinJ <porh8pasin@gmail.com>
Signed-off-by: jiakun <53556221+ddwolf87@users.noreply.github.com>
Co-authored-by: porh <155837075+porhJ@users.noreply.github.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-11-03 12:14:03 -07:00