Commit Graph
30294 Commits
Author SHA1 Message Date
Jukka LaitinenandHamish Willee 94fada627b feat(bootloader): Add support for standalone prepended TOC (#28228)
* feat(bootloader): Add flag BOOTLOADER_SKIP_VERIFY_SIG to skip post-flash signature check

In case the full image is not available in memory after flashing, the signature check
can't be performed. This is the case if flashing image in chunks to e.g. SD card or eMMC.

The image will be anyhow verified before booting, so the check is redundant.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* feat(bootloader/toc): Support separately signed TOC in front of the image

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* feat(bootloader): Add support for loading TOC separately into buffer

This changes the prototype of find_toc to pass the address and maximum length of the
area where TOC is to be searched, instead of just letting find_toc search from the
hard-coded APP_LOAD_ADDRESS.

This allows searching for TOC from a separately allocated buffer, which is useful for
a platform where the mass storage is not XIP, where one can first only load a TOC
separately. To keep it secure, the TOC itself needs to be separately signed though.

In image_toc.h two new flags are introduced by taking the reserved bits into use:

The TOC_FLAG2_RELATIVE_ADDRESSES can be set in case of entry being loaded from non-XIP
media to arbitrary addressed buffer; the address entry in TOC can be specified to be
an offset from the load address start instead of being an absolute address in memory.

The TOC_FLAG2_USE_SBI can be used with risc-v targets, in case the entry needs to be
booted via SBI interface.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* docs(secure bootloader): Add prepended toc documentation

Document the feature to add a separately signed TOC in front of the
image.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>

* docs(docs): Release note

* fix(bootloader/fmu-v6xrt): Increase bl stack by 200 bytes

It is on the edge and overflows if crypto functionality is added.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* feat(bootloader/fmu-v6xrt): Add signed boot targets for fmu-v6xrt

This adds these two new targets:
- px4_fmu-v6xrt_secureboot : Signed PX4 image, with prepended TOC, for v6xrt
- px4_fmu-v6xrt_bootloader_secureboot: Bootloader version to verify the signed image

Specifically, the implementation has
- px4board for both targets
- A new linker script for px4_fmu-v6xrt_secureboot, including the script.ld and
  overriding the "flash" memory area for start and size to account for prepended
  TOC structure
- TOC source and linker script
- Bootloader configurations added in hw_config.h

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

---------

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
2026-10-21 21:03:49 +11:00
f002dd461b feat(uxrce_dds_client): bridge sensor_gnss topic to allow GNSS injection (#28645)
* feat(uxrce_dds_client): bridge sensor_gps topic to allow GPS injection

Subscribing to /fmu/in/sensor_gps lets an off-board ROS 2 node feed GPS
data into the estimator, e.g. from an external receiver or a simulated
source, without a MAVLink detour.

* fix(uxrce_dds_client): use current GNSS topic

Co-authored-by: yannickpoffet <247171465+yannickpoffet@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yannickpoffet <247171465+yannickpoffet@users.noreply.github.com>
2026-10-21 11:20:53 +02:00
Julian Oes 9db0446174 fix(mavlink): make the receiver's component count atomic (#29358)
The receive thread appends to _component_states in update_rx_stats() while
the main mavlink thread reads it in component_was_seen() before sending a
COMMAND_ACK, and other instances read it for command forwarding. Nothing
synchronized the two, which ThreadSanitizer reports as a data race in the
SITL tests.

Each slot's system and component ID is written once, before the count is
bumped, and never changes after that. Making the count atomic is therefore
enough for readers to safely look at all entries below it, without adding a
lock to the receive path.

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

Signed-off-by: Julian Oes <julian@oes.ch>
2026-10-21 20:10:01 +13:00
Ahmet Burak Tektas b8b689dec2 fix(parameters): migrate SENS_IMU_TEMP* and SENS_TEMP_ID to HEATER1_* (#29354)
The multi-instance heater driver (#26325) replaced the single heater's
SENS_IMU_TEMP, SENS_IMU_TEMP_FF/_I/_P and SENS_TEMP_ID with HEATER<n>_*
parameters without a translation, so values stored by v1.17 are dropped
on upgrade and the heater runs with the defaults.

The controller is unchanged, so the values carry over to heater 1 as they
are. SENS_TEMP_ID 0 kept the heater from starting, while HEATER1_SENS_ID 0
selects a sensor automatically, so 0 becomes -1 (disabled).

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

Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>
2026-10-20 16:42:55 -06:00
Balduin e3229f9645 refactor(uavcan): two flash optimisations to avoid overflow (#29101)
* refactor(drivers/uavcan): de-templatize GlobalDataTypeRegistry::registerDataType

registerDataType<Type> expanded the full registration logic once per
data type, 56 times on px4_fmu-v6x_default. Move the type-independent
body into an out-of-line registerDataTypeImpl() so the template only
constructs the per-type descriptor arguments. The template is marked
noinline so the thin per-type body stays a single weak symbol the
linker can deduplicate, instead of being inlined into every translation
unit's static initializer.

px4_fmu-v6x_default flash: -1904 B

(cherry picked from commit f6249b453c)

* refactor(drivers/uavcan): out-line type-independent part of transfer decoding

GenericSubscriber<>::handleIncomingTransfer() expanded the bit stream
and codec setup, the transfer release and the failure accounting once
per subscribed data type, 40 times on px4_fmu-v6x_default. Move that
body into GenericSubscriberBase::decodeTransfer(), which invokes the
per-type decode function through a small type-erasing forwarder, so the
template only constructs the temporary storage and dispatches the user
callback.

px4_fmu-v6x_default flash: -1120 B

(cherry picked from commit c77fe827c7)
2026-10-20 16:32:57 -06:00
9e9bee968e feat(simulation): multiple IMU, magnetometer, barometer and GNSS sensors (#28357)
feat(simulation): support multiple IMU, magnetometer, barometer and GNSS sensors

The Gazebo bridge subscribed to exactly one sensor of each type, so
redundancy and multi-EKF behavior could not be exercised in simulation.

SIM_GZ_EN_IMU, _MAG, _BARO and _GPS now take a sensor count instead of
a 0/1 flag (max 3 for IMU, 2 for the others). Additional sensors are
named with a _1, _2 suffix in the model SDF, and each one is published
as its own uORB instance. Topic names are built in one helper instead
of three. A single sensor behaves as before.

Verified in SITL with two of each sensor: failing the first accelerometer
with the failure injection command makes the EKF2 selector switch to the
second instance.

---------

Co-authored-by: Matheo Taillandier <matheo.taillandier@rigi.tech>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
2026-10-20 17:58:53 -04:00
Michael Rogov Papernov 3fe7acc19d refactor(events): move the message-less send() out of line
events::send(id, log_levels, message) was an inline function, so every
module using it got either a private clone or the body inlined at each
call site. The message is never part of the sent event: it only feeds
the build-time event generator and the optional console print.

Keep a thin inline wrapper so the compiler still drops the unused
message string, and build the event in one out-of-line function that
takes the two log levels as scalars to keep the call sites small. This
saves 1760 bytes of FLASH on px4_fmu-v6x and 1184 bytes on px4_fmu-v2.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Michael Rogov Papernov <michael@membrowse.com>
2026-10-20 16:45:03 +02:00
j3kestrel 878877ad02 fix(fw_latlon_control): pass the low-height and underspeed flags to TECS (#29313)
* fix(fw_latlon_control): pass the landing low-height flag to TECS

updateLongitudinalControlConfiguration() never copied
enforce_low_height_condition from the incoming configuration, so the
landing's request to scale the TECS altitude time constant by
FW_LND_THRTC_SC had no effect. With no height-rate setpoint on the
approach, TECS trails the glide slope by about (1 - FW_T_HRATE_FF) x sink
rate x time constant; in SITL with FW_T_ALT_TC 10 the aircraft flew ~6 m
above the slope and touched down ~60 m long, and with FW_LND_THRTC_SC 0.2
now applied, 1.3 m and 13 m.

disable_underspeed_protection is dropped the same way; the next commit
passes it through.

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

* fix(fw_latlon_control): pass the disable-underspeed flag to TECS

updateLongitudinalControlConfiguration() never copied
disable_underspeed_protection from the incoming configuration, so the
request from takeoff and landing to switch off TECS underspeed handling
had no effect (the same omission as enforce_low_height_condition).

On every catapult and hand launch in our logs the underspeed ratio sat
at 1.0 for the first 0.4-1.1 s after release, while airspeed was still
building. TECS asked for nose-down and the pitch setpoint was held at the
takeoff minimum pitch. In SITL with the fix, the underspeed ratio stays
at 0 and the pitch demand rises 0.1-0.2 s earlier after launch.

Assisted-by: Claude:claude-opus-5-5
2026-10-20 10:04:43 +02:00
Saibernard 7efdb01978 fix(dataman): widen client IDs to 16 bit (#28944)
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
2026-10-20 08:23:31 +02:00
Jonas Perolini 30d778e28c fix(navigator): keep mission validity tied to checked inputs (#29068) 2026-10-20 07:20:52 +02:00
4964fa5995 feat(sensors/gnss): select the GNSS receiver on failures and the strict checks (#28798)
* feat(sensors/gnss): select the GNSS receiver on failures and reported accuracy

The interim selection took the receiver with the best fix type and the most satellites, and the preferred one whenever it had a 3D fix. Fix type and satellite count compare poorly across receivers, and nothing held a switch, so a one-sample fix blip flipped the output and back.

A preferred receiver (SENS_GNSS_PRIME, or with -1 the moving base of a moving base pair) is used until it fails: no usable, on-time sample for 2 s, or clearly less available than the other receiver. The selection returns to it once usable again, after 10 s while armed. Without one, it moves after 5 s to a receiver reporting at most half the eph and no worse epv, floored at 5 cm. SENS_GNSS_PRIME defaults to -1. vehicle_gnss carries the reason for the last switch, sensors_status_gnss each receiver's availability. GpsBlending becomes GnssSelector.

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

* docs(sensors/gnss): rewrite the SENS_GNSS_PRIME description

The description walked through the selection's internal timings and thresholds, and claimed that every switch resets the EKF2 position, which it doesn't while another source constrains the position. The availability comment left out that late samples count as unavailable.

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

* fix(sensors/gnss): update the selection while no receiver publishes

The selector and sensors_status_gnss only updated when a sample arrived. When every receiver stopped, the last status kept reporting the receiver healthy and available, the receiver never timed out, and on its return the gap counted as available time.

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

* refactor(sensors/gnss): keep the GNSS samples in the module, not the selector

The selector stored full samples and antenna offsets only to hand them back, a leftover from blending; it reads just each sample's timestamp, eph and epv. The module now keeps every receiver's latest sample and publishes the selected one, which is the sample its checks ran on, and the heading path reads the receiver state from it instead of copying every receiver out of uORB. A timed-out receiver is reset in one place, without the writes to the fix type and satellite count that only blending ranked on.

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

* feat(sensors/gnss): rank receivers on the requirements and RTK fix, without returning to a failed one

The eph ratio switched receivers on reported accuracy alone, and the 10 s return to the primary went back to a receiver likely to fail again in the same flight, at the cost of another EKF2 position reset. While disarmed, the selection fell back to the other receiver, so a vehicle could take off on it with a failing primary.

While disarmed the primary is now selected whenever it publishes, so commander reports its failed checks before arming. While armed, a receiver left because it failed is selected again only when the selected one fails, until disarmed. Without a primary, receivers rank by meeting GNSS_REQ_EPH/EPV/SACC/FIX, which GnssChecks now also evaluates in flight, then by an RTK fixed solution; the selection moves up after 10 s armed or 2 s disarmed.

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

* feat(gnss_checks): always run strict checks to have the information for the selection algorithm, switch to simplified checks in-air when the strict checks fail

* feat(GnssSelector): rework selection algorithm

* fix(lib/gnss): pass the checks again and relax them only after a strict pass

493c86ce58 set the fail time on every sample that hadn't passed yet, including samples still inside the required pass duration, so the duration restarted on every sample and no receiver ever passed: EKF2 never fused GNSS. It also relaxed the checks only while flying, so a vehicle armed on the ground lost GNSS for GNSS_REQ_TIME on a single strict failure, and a receiver that first published in flight got the relaxed checks without ever passing the strict ones.

The relaxed checks apply again once the strict ones passed, until disarmed on the ground. The strict checks still run on every sample, and meetsRequirements() is their result for that sample, without a pass duration: the selection holds its own, and a duration here would turn one failed sample into GNSS_REQ_TIME of not meeting the requirements. Once relaxed, only the relaxed checks are reported as failed.

* fix(sensors/gnss): restore failover and switch holds, leave a primary that misses the requirements

a23b25aa3b failed over to the preferred receiver where it meant the higher ranked one, which selects instance -1 without a preferred receiver, read the availability of instance -1, stayed on a failed primary whose late samples still met the requirements, and replaced a failed receiver only with one that met the requirements or was far more available. Without the hold, two receivers whose RTK fixed solutions came and went switched on every change, each switch an EKF2 position reset.

Its design stays: the primary is kept while it meets the requirements and left when it hasn't met them through the hold while the other receiver has. Receivers rank by being usable, then meeting the requirements, then, without a primary, an RTK fixed solution, and the primary ranks above an equal receiver that meets them. So it is taken back once it meets them through the hold, unless it failed, and an RTK fixed solution never outranks it, as a moving-base rover reports one while being the worse position source. A silent or failed receiver is replaced at once by the best publishing or usable one, a rank switch waits 10 s armed and 2 s disarmed, and while disarmed the primary is selected only while it publishes, so that a vehicle without it still has a position and the pre-arm check reports the missing primary. getSelectionReason() returns a value set in update().

* feat(sensors/gnss): double the switch hold with every rank switch in a flight

The hold rides through changes shorter than 10 s, but a receiver that goes in and out of the requirements for longer still costs two EKF2 position resets per cycle, for as long as it keeps doing so: under sustained interference, switching is worse than staying on one receiver and letting the failsafes act. Doubling the hold with every rank switch while armed, up to 160 s, bounds the switches in a flight while a single recovery, such as the corrections coming back, still returns after 20 s. Failovers keep switching at once.

* fix(sensors/gnss): report a receiver as healthy only while the selection can use it

sensors_status_gnss.healthy took only the checks into account, while the selection also requires samples at the receiver's usual rate. A receiver whose rate collapsed showed as healthy next to its falling availability and the selection leaving it, and commander's redundancy check counted it.

* docs(releases): note the SENS_GNSS_PRIME default change in the upgrade guide

Setups that never set SENS_GNSS_PRIME move from preferring the main serial receiver to Auto without migration.

* fix(sensors/gnss): learn a receiver's lower update rate instead of failing it for good

The late threshold followed the shortest interval a receiver ever reached, so a receiver that slowed to below a third of its rate had every sample late from then on and stayed out of the selection, although receivers slow down for reasons that don't make their samples worse, such as processing RTCM corrections. With the no-return rule, a primary that slowed down was left for the rest of the flight.

Samples are now late against the receiver's recent interval, which follows a lower rate within a sample: only the first sample at the lower rate is late, so a single gap still counts. Below about 1 Hz the first two intervals at the lower rate still add up to the 2 s that fail a receiver.

* feat(lib/gnss): meetRequirements() requires to pass the strict checks for min_health_time_us. Report checks as strict for as long as the strict checks pass.

* refactor(lib/gnss/test): remove hardcoded min_health_time_us from setParams(GnssChecks::Params params) method

* feat(sensors/gnss):  restructure receiver selection

- don't select a previously failing receiver as better if the current is still usable and hasn't failed
- priority of availability over higher rank (and preferred), but still choose the highest rank (or preferred) in case multiple have high availability

* fix(sensors/gnss): prefer the primary receiver only while it meets the requirements

Once both receivers missed the requirements, the selection moved back to the primary after the hold: an EKF2 position reset with no better receiver to show for it. The primary is kept while it meets the requirements; when neither does, nothing favours it.

* docs(lib/gnss): describe when meetsRequirements() restarts its pass duration

The comments still said that meetsRequirements() holds no pass duration and that strict() is true only before the first pass. A sample that fails only the strict checks deliberately doesn't restart the duration once the relaxed checks apply, so that one bad sample doesn't drop the receiver's rank for GNSS_REQ_TIME and switch it away after the selection's hold.

* refactor(sensors/gnss): name the two GNSS check sets strict and relaxed

The same two sets of checks went by strict, initial fix, requirements, simplified, pre-flight and in-flight, and failed_checks reported whichever set decided usable, so its meaning changed with the vehicle state. Each result now names its set: vehicle_gnss and sensors_status_gnss report failed_strict_checks and failed_relaxed_checks for every sample, and strict says which of them decides usable. In code the sets are runStrictChecks() and runRelaxedChecks(), the held strict result is passedStrict(), and the selector ranks on RANK_STRICT and reports SELECTION_STRICT. No behaviour changes.

* refactor(ekf2): drop EKF2_REQ_SACC and the GNSS restart wait, move the heading wait to EKF2_GPS_YAW_RST

EKF2 kept its own copies of two GNSS check thresholds after the checks moved to the sensors module. Whether a receiver's sample is good is the sensors module's call and reaches EKF2 on vehicle_gnss; EKF2 keeps only waits about its own estimate.

Trusting GNSS vertical velocity while the accelerometer clips, and feeding GNSS velocity to the yaw estimator, now use the sample's strict speed accuracy check (GNSS_REQ_SACC) from vehicle_gnss.failed_strict_checks, evaluated on every sample, also in flight. vehicle_gnss.usable alone would not do: in flight the relaxed checks decide it, which only bound the speed accuracy at 10 m/s.

The wait before GNSS fusion restarts after EKF2 stops it only reproduced the requalification EKF2 forced by resetting the checks when they lived in EKF2. GNSS_REQ_TIME now does that in the sensors module, and a restart after a stop EKF2 decided on its own is already gated on GNSS agreeing with the estimate. The replay test output is unchanged.

The wait before a yaw reset to the GNSS heading after a heading fusion failure or a spoofing or jamming report is EKF2's own and moves to EKF2_GPS_YAW_RST. Saved EKF2_REQ_SACC and EKF2_REQ_GPS_H values migrate to GNSS_REQ_SACC and GNSS_REQ_TIME.

* fix(sensors/gnss): checking for better availability now works both ways

* test(sensors/gnss): add unit test for availability taking precedence over rank. Assisted by Codex 6.1 Sol

* refactor(lib/gnss): name the relaxed-checks gate _initial_strict_checks_passed

"since disarm" read as the moment of disarming, while the flag is cleared on every sample the vehicle sits disarmed on the ground.

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

* refactor(ekf2): keep starting_conditions_passing in the GNSS fusion control

The other aid source controls decide a start on starting_conditions_passing; keep that structure even though it now equals the continuing conditions.

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

* fix(sensors/gnss): keep the strict rank through a failure shorter than the fail time

In flight a sample that fails the relaxed checks restarts GNSS_REQ_TIME for passedStrict(), and GNSS_REQ_TIME (10 s) is as long as the armed switch hold. A one-second failure on the primary receiver, such as a spoofing flag, therefore switched to the other receiver after the hold and back once the doubled hold passed: two EKF2 position resets for a blip.

A receiver now gains the strict rank only once its strict checks held for GNSS_REQ_TIME, and keeps it while its samples pass them until it fails (FAIL_TIME_US without a usable sample). occasionalFailureDoesNotSwitch kept passed_strict true through the failures, which GnssChecks never reports, so it missed this.

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

* fix(sensors/gnss): report a receiver unhealthy only once the selection fails it

healthy followed isUsable(), which goes false for a single sample arriving 300 ms late. The commander's GNSS redundancy check counts healthy receivers without hysteresis, so with SYS_HAS_NUM_GNSS set one late sample triggered the GNSS loss failsafe, and with two receivers it reported "GPS n unhealthy". healthy now means usable within FAIL_TIME_US (2 s), when the selection fails over; that still covers a receiver whose rate collapsed below about 1 Hz.

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

* fix(sensors/gnss): count receiver availability from arming

While disarmed the strict checks keep a receiver unusable for GNSS_REQ_TIME after every failure, and the availability kept counting that time. Arming within a few seconds of the primary receiver requalifying after a ground outage left the other receiver more available by over 0.2 for the whole armed hold, so the selection left a healthy primary 10 s after arming and returned 20 s later. Availability is meant to catch intermittent failures in flight, so it now starts over at arming.

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

* fix(sensors/gnss): don't count a receiver that hadn't qualified at arming as failed in flight

While disarmed the primary receiver is selected whenever it publishes, even before it passes its checks. Armed in that state, the selection failed over at once and marked the primary failed for the flight, so it was never used again even after it passed its checks, while a primary that was silent at arming is taken once it qualifies. A receiver is now marked failed only if it was working at some point since arming.

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

* docs(sensors/gnss): correct the selection comments and parameter descriptions

The AVAILABILITY_MARGIN comment described a half margin the code never applied, SELECTION_RTK_FIXED claimed both receivers pass the strict checks, and SENS_GNSS_PRIME said the primary returns after 10 s, while the doubled hold makes the first return take 20 s, and left out switches on availability. GNSS_REQ_SACC now says it also gates the EKF-GSF yaw estimator and the GNSS vertical velocity while the accelerometer clips, which turning off the speed accuracy check disables. Drops _time_usable_since_us, which nothing read.

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

* docs(releases): list the GNSS check parameters that moved from EKF2

EKF2_GPS_CHECK, EKF2_REQ_* and EKF2_REQ_GPS_H are migrated to GNSS_CHECK, GNSS_REQ_* and GNSS_REQ_TIME, but the upgrade guide had no entry for them, and the GNSS rename entry still said the EKF2 parameters were unchanged.

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

---------

Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: thomas <thomas@rigi.tech>
2026-10-19 20:18:40 -06:00
Julian Oes d5a3f19ba7 fix(mc_pos_control): compute limitTilt angle with atan2 (#29333)
acosf() amplifies rounding errors near +-1. A body z vector that should
be exactly vertical can come out of normalization as 0.99999994, which
acosf() turns into a tilt of about 3.5e-4 rad. Since the horizontal part
is zero, the parallel-vector fallback then tilts that small angle towards
+x, producing a spurious horizontal thrust.

This makes PositionControlBasicTest.IdleThrustInput and
IntegratorWindupWithInvalidSetpoint fail on clang builds with
-freciprocal-math (e.g. the AddressSanitizer build).

atan2f() of the rejection norm and the dot product is well conditioned
over the whole range and yields exactly 0 in this case.

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

Signed-off-by: Julian Oes <julian@oes.ch>
2026-10-20 10:13:56 +13:00
Jonas Peroliniandjonas a99287097a fix(vision_target_estimator): reacquire target after attitude resets (#29339)
Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-19 19:07:44 +02:00
Jonas Peroliniandjonas b2bce30859 perf(vision_target_estimator): fuse same-cycle observations in timestamp order (#29334)
Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-19 19:04:36 +02:00
Jonas Peroliniandjonas 383e3b26b9 docs(vision_target_estimator): shorten long param description to save flash (#29308)
Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-19 10:40:12 -06:00
msli-dev 8fc6cf05ae feat(open_drone_id): add locked Basic ID storage and Mach RID target (#29076)
* feat(open_drone_id): add locked Basic ID storage and Mach RID target

Persist the first serial-number Basic ID in MTD storage so DroneCAN can
reuse the identity after reboot without falling back to the board GUID
in locked mode.

Provide a separate Mach RID build with EEPROM storage and locked-mode
defaults while keeping EEPROM registration out of the default build.

Signed-off-by: msli-dev <747640013@qq.com>
Assisted-by: Codex

* fix(open_drone_id): gate storage and preserve legacy forwarding

Keep the optional EEPROM identity library, parameters and per-instance
state out of builds that do not enable CONFIG_BOARD_HAS_RID_EEPROM.
Use the same option for Mach EEPROM registration and module dependencies.

Restore the original Basic ID forwarding path when locking is disabled,
including builds without identity storage. Limit persistent identity
resolution to the enabled locked mode.

Signed-off-by: msli-dev <747640013@qq.com>
Assisted-by: Codex

---------

Signed-off-by: msli-dev <747640013@qq.com>
2026-10-19 10:30:20 -04:00
Claudio-Chies d354c4e504 fix(uavcan): warn when GetNodeInfo retries are exhausted
Log nodes whose GetNodeInfo request never succeeded, so a missing
device_information entry can be traced back to the node.
2026-10-19 09:24:23 +02:00
Claudio Chies 11acc3a19e fix(uavcan): publish device_information for nodes whose GetNodeInfo arrives before first capability
registerNodeInfo() dropped the node info when it created a new entry, so
nodes answering GetNodeInfo before registering a capability never had
their name/version/serial published. Restore populateDeviceInfoFields()
for that path and log extendDeviceInformationsArray() failures at the
source.
2026-10-19 09:24:23 +02:00
Matthias Grob c67f1810f0 fix(node_info): avoid heap fragmentation by allocating memory for 4 devices at a time 2026-10-19 09:24:23 +02:00
Matthias Grob 29bfbc2070 refactor(uavcan_node_info): simplify registerNodeInfo() 2026-10-19 09:24:23 +02:00
Matthias Grob 0abd7b039f fix(uavcan_node_info): store unique_id instead of string formated serial_number 2026-10-19 09:24:23 +02:00
Matthias Grob d1c700e6e4 refactor(uavcan_node_info): remove duplicate device_type enum abstraction 2026-10-19 09:24:23 +02:00
Matthias Grob d8702d5323 refactor(uavcan_node_info): remove separate NodeInfo abstraction 2026-10-19 09:24:23 +02:00
gguidone f382afe889 refactor(uavcan_node_info): split registerDevice into registerNodeInfo and registerCapability
- NodeInfoPublisher: split registerDevice into registerNodeInfo + registerCapability
- Store versions as integers and format them to strings at publish time
- Remove unused parseNodeName declaration

Assisted-by: Claude Code
2026-10-19 09:24:23 +02:00
Matthias Grob 7a05d9191f refactor(uavcan): early-return when ESC node health is not a failure
Don't report DroneCAN node warnings as ESC failures; return before
parsing vendor specific flags.
2026-10-19 09:24:23 +02:00
Matthias Grob 3561baeaa1 fix(uavcan): properly map vendor specific ESC failures from VertiQ escs 2026-10-19 09:24:23 +02:00
Matthias Grob d5491fac79 refactor(uavcan): adapt some newlines and a comment 2026-10-19 09:24:23 +02:00
j3kestrel ebf8b69c66 fix(qmc5883p): scale for the +-2 G range is 15000 LSB/G (#29301)
The driver selects RNG = 11 (+-2 G) and checks it, but scaled the data
by 1/12000, so every field reading was 1.25x too large (measured 1.252x
the world magnetic model), which also triggers the strong magnetic
interference preflight check. The QST datasheet (13-52-19 Rev A) gives
15000 LSB/G for the +-2 G range.

Existing compass calibrations must be redone after this change: the
stored offsets are in the old units.

Assisted-by: Claude:claude-opus-5-5
2026-10-18 22:08:18 -04:00
Julian Oes 04a0e03c22 fix(navigator): free the RTL mission type handle on destruction (#29331)
RTL allocates its mission-based return helper on the heap and only freed
it when replacing it, so the last one leaked when RTL was destroyed. This
is harmless in flight, where RTL lives for the whole run, but
LeakSanitizer reports it in functional-test_RTL once a test selects a
mission RTL type.

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

Signed-off-by: Julian Oes <julian@oes.ch>
2026-10-19 14:12:53 +13:00
Julian Oes 14586c2d91 fix(mavlink): stop PX4 over-driving a telemetry radio (#28714)
* fix(mavlink): rate-limit the parameter dump to its share of the link

A full PARAM_REQUEST_LIST dump was only throttled in
MAVLINK_MODE_LOW_BANDWIDTH. In every other mode the sole backpressure was
get_free_tx_buf() in send_param(), which on NuttX is just FIONSPACE on the
UART and knows nothing about what the link behind it can carry. MAV_x_RATE
scales _rate_mult, which applies to the streams only, so the dump ignored
it entirely. Since _main_loop_delay is floored at 100 Hz, the dump ran at
~100 Hz (~3.9 kB/s) no matter how low MAV_x_RATE was set.

On a 57600 SiK radio (AIR_SPEED=64) that hands the radio roughly three
times what it can carry. The radio drops whole MAVLink packets, which
shows up as 4-6% loss across everything sharing the link - the parameters
themselves still arrive, it is the rest of the telemetry that suffers.
Measured on an FMU-v6C: 4.4-6.2% loss during a dump, going to 0.00% with
this change.

Derive a minimum send interval from the configured data rate instead, so
the dump takes a bounded share of the budget and scales with the link. The
8 Hz low bandwidth cap is kept as a floor so that mode does not speed up.
Fast links are unaffected: on USB the computed interval falls below the
main loop period, so it never fires.

Also stop advancing _send_all_index when send_param() fails for want of TX
buffer space. The return value was discarded after the index had already
moved on, so that parameter was skipped silently and never resent, leaving
the ground station to notice the gap and re-request it.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): let streams yield budget during a parameter dump

With the dump now taking a defined share of the link budget, the streams
were still sized against the whole of it, so the two together could
over-subscribe the link and push it back into dropping packets.

Reserve the dump's share in update_rate_mult() while a full dump is in
progress, the same way const_rate streams and ulog streaming are already
accounted for. Links with spare bandwidth are unaffected by construction:
bandwidth_mult is capped at 1.0 regardless, so subtracting the reserve only
bites once the streams are actually close to the limit. Verified on USB,
where tx rate mult stays at 1.000 throughout a dump.

This keys off a full PARAM_REQUEST_LIST transfer rather than the existing
sending_parameters(), which stays true for 2 s after any single parameter
goes out and would reserve bandwidth far more often than intended.

Measured on an FMU-v6C over a 57600 SiK: during a dump the streams scale
back from 0.473 to 0.232 and total output drops from 1428 to 1052 B/s,
inside the 1200 B/s budget, with no loss.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): pin the TELEM1 data rate to a radio-safe default

MAV_0_RATE defaulted to a hardcoded 1200 B/s while every other instance
defaulted to 0, meaning baudrate/20. The value predates the yaml config
migration in 2018 and no rationale is recorded for it.

Deriving it from the baudrate is tempting but wrong for a telemetry
radio, where the serial rate says little about what goes over the air. A
SiK radio at 57600 baud with the common 64 kbps air rate carries around
2000 B/s with error correction enabled, and roughly twice that without,
where baudrate/20 would suggest 2880. Error correction is not visible to
us from here, so 2880 over-drives the link on any radio that has it on,
and the radio drops packets rather than telling us.

Measured on an FMU-v6C over a 57600 SiK: at 2880 with error correction
enabled a parameter download loses 1.3-1.8% and an FTP burst download
fails outright, while at 2000 both complete cleanly. With error
correction off there is more headroom and 2880 is fine, so 2000 is the
value that works either way.

Pin instance 0 to 2000 rather than deriving it, and say why in the
parameter description so that anyone on a better link knows they can
raise it.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): keep the FTP session alive while a burst is streaming

_last_work_buffer_access is only updated by _ensure_buffers_exist(), which
runs when a client request arrives. A burst download streams without any
client requests, so nothing refreshes it for the duration of the burst and
send() closes the session out from under the transfer once the inactivity
timeout expires.

A burst is bounded by a 35 KiB chunk, which over USB is done long before
the timeout, so this never shows there. Over a telemetry radio a single
chunk easily takes longer than 30 s, and the session is then torn down
mid-transfer: reproducible against an FMU-v6C over a 57600 SiK as a
failure at just over 31 s, every time.

Treat streaming a burst as the activity it is.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): fit FTP burst downloads to a telemetry radio

A burst download was bounded only by get_free_tx_buf(), the local UART
buffer, which knows nothing about what the radio behind it can carry. Over
a 57600 SiK that hands the radio several times its capacity: the radio's
reported txbuf collapses to zero, PX4 sheds 600-1500 B/s of its own, the
regular streams are squeezed to 40%, and the transfer dies around 10% of
the way through a 128 KiB file. It cannot be reproduced over USB, where
there is no such bottleneck.

Three things are needed, and none of them is sufficient alone.

Keep the packet inside one radio packet. A SiK splits anything larger than
its max_data_packet_length across several radio packets and reassembles
them correctly, but the split costs air time and drops the rate the link
can carry by roughly a third, which is enough to push the burst over the
edge. That limit is 250 bytes without error correction and 118 with it,
and we cannot tell which from here, so size for the smaller. The payload
is derived rather than hardcoded because the framing overhead depends on
whether signing is active.

Pace the burst against its share of the configured rate, scaled by the
radio's own txbuf feedback so it finds whatever the link actually carries:
that differs by more than two to one depending on error correction. Note
this deliberately does not use get_rate_mult(), which folds in the budget
split that this share has already been subtracted from - applying it here
too counts the reduction twice and starves the burst into the client's
inter-packet timeout.

Reserve that share in update_rate_mult() so the streams yield it instead
of the two together over-subscribing the link.

All of it is conditional on a radio reporting RADIO_STATUS, so a direct
serial or USB connection is unaffected.

Measured on an FMU-v6C over a 57600 SiK, downloading a 128528 byte file
with MAVSDK. Without error correction, at the default rate: three runs of
three complete byte-identical in 2:05, with no timeouts, no gap-fill reads
and 1414 burst packets for 1414 packets' worth of file, where the same
download fails outright before this change. With error correction enabled,
which halves both the capacity and the packet size, it completes in 3:10.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* docs(telemetry): note what a SiK link actually carries

The page says the vehicle-side radio typically needs no configuration,
which is true for getting a link up but leaves out that the serial
baudrate says little about what goes over the air, and that setting
MAV_0_RATE above what the link carries makes the radio drop packets rather
than making telemetry faster.

Add a short section with the rough figures, what to do about it, and the
two AT commands that report the radio's own limits.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): honour the size requested for an FTP burst

_workBurst recorded the offset, sequence number and target ids from a
BurstReadFile request but not its size, and the streaming loop always read
a full payload. A client could not ask for smaller packets, which the
spec provides for and which ArduPilot already honours, so the two servers
behaved differently for the same request. The single-shot ReadFile path
was never affected.

Record the requested size, treating zero as "as much as fits" to match
ArduPilot, and use it for the burst.

The clamp against what a radio carries in one piece stays, and has to be
applied after the request rather than instead of it. Every ground station
in the field asks for a full payload today, so honouring the request on
its own would hand a radio packets it has to split, which is the behaviour
this series set out to fix. Asking for less than the radio can carry is
respected; asking for more is not.

Reported by @DonLakeFlyer.

Measured against an FMU-v6C over a 57600 SiK with error correction on,
where the radio carries 118 bytes in one piece: a request for 239 is
answered with 91 bytes per packet, 200 likewise, and a request for 64 is
answered with 64.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): keep single-shot FTP reads within one radio packet too

_workRead already honoured the size a client asked for, so it was left
alone when the burst path was taught to stay inside one radio packet. That
leaves a hole: when a burst loses something, the client fills the gap with
ReadFile requests, and those go out at the size it asked for. Against a
radio carrying 118 bytes in one piece, a 110 byte request is 137 bytes on
the wire and is split - which is exactly what the burst clamp exists to
avoid, reappearing on the recovery path.

Observed against QGroundControl master over a 57600 SiK with error
correction on: burst packets came back at 91 bytes as intended while the
gap-filling reads came back at 110, and both of the retries in that
download were on the latter.

Apply the same clamp to both, and share it rather than repeating it.

Reducing the reply is safe and stays within the spec, which lets a server
return less than was asked for. Clients already handle it because they
track what is outstanding from the size in the reply: QGroundControl
answers a short read by requesting the remainder, and MAVSDK writes
whatever arrives at the offset given.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(boards): no more RGB LEDs for out of flash v2

* fix(mavlink): address review of the FTP and parameter pacing

Keep batching parameters. The dump was throttled with a minimum interval
between messages, which the batch loop for USB and UDP links immediately
ran into: it sends up to 20 messages per call, and every one after the
first was refused. Take the budget in bytes instead, accumulated over
time, so a link with room to spare still sends its batch while a slow one
is spread out as before.

Share one budget between bulk transfers. A parameter dump and an FTP burst
each paced themselves against half the link, and the streams only yielded
the larger of the two shares, so the pair of them together could take the
whole link and leave the telemetry nothing. Split one bulk share between
whichever of them are running.

Leave MAVLink 1 replies alone. Only MAVLink 2 drops the trailing zeros of
a payload, so shrinking an FTP reply on a MAVLink 1 link costs the client
bytes without making the packet any smaller, and the pacing has to budget
for the whole payload there.

End a burst that fails. The server returned 'not complete' for a failed
read, so it sent the same NAK every couple of milliseconds until the
client reset the session. ArduPilot marks that packet as the end of the
burst; do the same.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fixup! fix(mavlink): rate-limit the parameter dump to its share of the link

Signed-off-by: Julian Oes <julian@oes.ch>

* fixup! fix(mavlink): fit FTP burst downloads to a telemetry radio

Signed-off-by: Julian Oes <julian@oes.ch>

* fixup! fix(mavlink): address review of the FTP and parameter pacing

Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): treat a UDP data rate of 0 like USB

Now that the parameter dump follows the configured data rate, MAV_x_RATE=0
on an ethernet link matters more. UDP has no baudrate, so 0 fell through to
the 57600 serial initialiser and resolved to 2880 B/s, throttling the dump
to about 39 parameters per second. Every in-tree ethernet configuration
sets a rate explicitly, so this only bites when ethernet is moved to an
instance left at 0, or on av/x-v1, which starts UDP without -r.

Give UDP the same 100000 B/s fallback that USB already has.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): pace LOG_DATA log downloads behind a radio

A LOG_DATA download was bounded only by the local UART buffer, so it
over-drives a telemetry radio the same way an FTP burst did: the radio
gets far more than it can carry over the air and drops packets, including
the telemetry sharing the link.

Pace it like the FTP burst. Behind a radio that reports RADIO_STATUS, send
one packet per call, against the bulk share of the configured rate scaled
by the radio's txbuf feedback. A log download now also counts as a bulk
transfer, so it splits the bulk share with a parameter dump or FTP burst
running at the same time, and the streams yield that share while it runs.

A direct serial, USB or UDP link is unaffected.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>

---------

Signed-off-by: Julian Oes <julian@oes.ch>
2026-10-18 19:08:09 -06:00
Jacob Dahl 9ad42167e0 fix(simulation): publish every gz optical flow frame (#29306)
The plugin gave the flow library the camera rate as its output rate. The
library's rate limiter publishes only after more than one period has
passed, so it withheld every other frame and returned quality -1 for it.
The plugin published those frames anyway and the bridge stored -1 as
quality 255, so over a featureless floor EKF2 fused zero flow at full
quality and the vehicle drifted. The averaged frames counted the time of a
quality-0 frame but not its motion, under-reading flow on patchy texture.

Output rate 0 disables the limiter, so every frame goes out with its own
quality and a 20 ms integration time.

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

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-18 17:55:50 -06:00
Liandrikaken2004 50c4845d36 mavlink: fix false DOES_NOT_EXIST when param read hits full TX buffer (#28975)
MavlinkParametersManager::send_param() returns 1 both for PARAM_INVALID
and for a full TX buffer, and handle_message() maps 1 to
MAV_PARAM_ERROR_DOES_NOT_EXIST. On a congested link a PARAM_REQUEST_READ
for an existing parameter can therefore be answered with "param does
not exist" (plus a misleading "Unknown param" PX4_ERR).

Return a distinct code (3) for the TX-buffer-full case and handle it in
both PARAM_REQUEST_READ branches by skipping the read without sending an
error; the GCS retries on timeout. The remaining call sites either
ignore the return value (PARAM_SET echo, send_one()) or treat any
non-zero as stop (send_untransmitted()) and are unaffected.

Fixes #28974

Co-authored-by: rikaken2004 <244897142+rikaken2004@users.noreply.github.com>
2026-10-19 12:32:25 +13:00
Jonas Peroliniandjonas 95a29758f0 fix(vision_target_estimator): replay updates after delayed fusion (#29316)
* fix(vision_target_estimator): replay updates after delayed fusion

* perf(vision_target_estimator): size replay buffers per filter

* board(vte): include SIH

* docs(vision_target_estimator): add fmu v6c measurements

* docs(vision_target_estimate): remove table of contents

---------

Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-18 17:22:29 -06:00
Jonas Peroliniandjonas 9e1c635ae7 fix(vision_target_estimator): correct startup timing and uncertainty (#29307)
Assisted-by: Codex

Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-18 17:02:15 -06:00
Jonas Peroliniandjonas ddcaad6601 fix(vision_target_estimator): respect vehicle GNSS quality (#29304)
Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-17 22:57:38 +02:00
Jonas Peroliniandjonas cd7f0c8901 fix(vision_target_estimator): apply GNSS bias model at fusion time (#29302)
Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-17 22:38:01 +02:00
Jonas Peroliniandjonas 1c6e73a071 fix(vision_target_estimator): use corrected GNSS velocity at startup (#29303)
Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-17 22:37:35 +02:00
Jonas Peroliniandjonas c90b118694 fix(vision_target_estimator): correct GNSS offset freshness checks (#29300)
Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-17 20:34:00 +02:00
Benjamin Cabé e2f45b2fa2 refactor(uavcan): build without NuttX headers (#29280)
* refactor(uavcan): drop unused NuttX headers

uavcan_main.cpp and uavcan_servers.cpp include arch/chip/chip.h, which neither uses, and uavcan_servers.cpp also includes nuttx/config.h, which px4_config.h already includes.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>

* refactor(uavcan): build without NuttX headers

The DroneCAN driver included NuttX headers outside its NuttX-specific code and masked the interrupts with the NuttX functions directly. The interrupts are now masked with UavcanCriticalSection, which uses the NuttX functions on NuttX and a process-wide lock on POSIX, which has no interrupts, and the NuttX headers are only included on NuttX. On NuttX, the interrupts are masked as before.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>

---------

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-17 12:09:24 -06:00
Benjamin Cabé 63032c5ac9 perf(land_detector): run the multicopter detector at 50 Hz (#29262)
The land detector runs on every vehicle_local_position update, the EKF
output rate (100 Hz or more), although every multicopter detection
state goes through a time-based hysteresis of 300 ms or longer. Limit
the multicopter (and VTOL) detector to 50 Hz, like flight_mode_manager
on the same topic. Detection latency grows by at most 10 ms.

The fixed-wing detector keeps its rate: its per-run low-pass filters
would change their time constants.

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

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-17 11:37:19 -06:00
Benjamin CabéandJacob Dahl 93579610c6 perf(ekf2): reconstruct the output position once per update (#29261)
* perf(ekf2): reconstruct the output position once per update

After each filter update, the local position, odometry and global
position publishers each rebuilt the output position in double
precision: getLatLonAlt() three times, with trigonometry in the
local-to-global step, and the projection back to local NED twice.
Nothing changes the output predictor between them, so compute the
global position and its local projection once and pass them to the
publishers. The published values are bit-identical.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>

* refactor(ekf2): name the global-to-local conversion globalToLocalPosition

getPosition(lla) projects any global position into the EKF's local frame rather than returning the estimator's position, so name it as the inverse of Ekf::localToGlobalPosition().

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

---------

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-16 18:10:00 -06:00
Jacob Dahl b8b35ed014 fix(uavcan): report CAN init failures and close stale SocketCAN sockets (#29273)
* fix(uavcan): close the previous SocketCAN socket before opening a new one

Every uavcan stop/start, and every retry after a failed driver init, opened a new socket per interface and left the old one open and bound, queueing received frames that nothing reads.

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

* fix(uavcan): reject a UAVCAN_BITRATE outside its range at start

Run() initializes the CAN driver with the rate uavcan start read and retries it on every cycle when the driver rejects it, logging an error each time, until the node is restarted.

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

* fix(uavcan): report a failed node init

init() returned errors from the controllers, sensor bridges and node start that Run() ignored, so the node came up partly initialized without a message.

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

* refactor(uavcan): return from the bit rate check instead of exiting

#29228 turns the uavcan command's exit() calls into returns; the new check should not add one back.

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

* fix(uavcan): report each CAN driver init error once

Run() retries the CAN driver init every cycle and logged every failure. The start-time range check missed most rates the drivers reject: the STM32 and Kinetis timing solvers only accept a rate that divides the CAN clock, so 800 kbit/s on fmu-v5 still logged every 3 ms. Reporting in Run() covers every driver and cause, so the check, a copy of the parameter's range that CAN FD would raise above 1 Mbit/s, goes.

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

* fix(uavcan): close the SocketCAN sockets when the node stops

After uavcan stop the sockets stayed bound until the next start. Nothing reads them, and with no per-socket receive limit their queued frames take IOBs the IP stack shares. Run() closes them because they belong to the work queue's task group, which the shell running uavcan stop is not in.

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

* fix(uavcan): close SocketCAN sockets that nothing will read or bind

A node whose init() failed never starts, and spinOnce() does not read the sockets of an unstarted node, so they stayed bound and filled the IOB pool for the module's lifetime. A socketInit() failure after socket() left an unbound socket open that CanDriver::init() then polled and sent on while reporting success.

Assisted-by: Claude:claude-opus-5-5
2026-10-16 18:08:39 -06:00
Benjamin Cabé 9368a9826a perf(sensors/flight_mode_manager): drop two per-cycle topic copies (#29263)
VotedSensorsUpdate::imuPoll() copied the whole vehicle_imu_status of
each IMU on every vehicle_imu sample (200 Hz or more) to read two error
counters that are published at 10 Hz. Keep the latest counters and
update them only when a new status arrives; the voter gets the same
values as before.

FlightTaskManualAcceleration::update() copied vehicle_local_position by
value on every run, although it only reads it and the subscription only
changes in updateInitialize(). Take it by reference.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-16 17:41:45 -06:00
Ahmet Burak Tektas 4ee456bd90 fix(mc_raptor): build with clang (#29276)
Apple clang stops px4_sitl_raptor in mc_raptor on two warnings:
-Wcast-align for the pointer rl_tools stores in front of its aligned
allocations, and -Wunused-private-field for
timestamp_last_manual_control_input, which is never used.

Build the module with -Wno-cast-align, as mc_nn_control does, and
remove the unused timestamp and its _set flag.

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

Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>
2026-10-16 17:38:37 -06:00
Jacob Dahl 0262f30251 fix(uavcan): free the node only after Run() has stopped (#29275)
* fix(uavcan): free the node only after Run() has stopped

uavcan stop deleted the node and left the wait for Run() to the destructor. The destructor freed the firmware and node ID servers before that wait, while Run() on wq:uavcan still used them, and after 50 ms freed the rest regardless, leaving _instance pointing at freed memory for the bus event interrupt, uavcan status and uavcan start. stop() now waits for Run() to clear _instance before deleting the node, and leaves the node allocated if Run() never gets there.

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

* fix(uavcan): clear the node instance before descheduling it

Run() descheduled itself and then cleared _instance. A bus event interrupt in between still saw the instance and queued Run() again; if that run blocked, the shell's stop() saw _instance clear and freed the node under it.

Assisted-by: Claude:claude-opus-5-5
2026-10-16 17:26:42 -06:00
Benjamin Cabé c384eae89e fix(uavcan): return from the uavcan command instead of exiting (#29228)
The uavcan command ended with exit(), which ends the command task on NuttX but the whole process where exit() is the one of the C library, as on POSIX. It now returns its result. The exit() of UavcanNode::Run() on an invalid node ID is left to #29084.

Assisted-by: Claude:opus-5.5

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-16 16:47:23 -06:00
Benjamin Cabé 06d3d0c400 fix(uavcan): keep running when the time sync slave fails to start (#29255)
Run() returned with _node_mutex locked when the time sync slave failed to start, so the next work item on wq:uavcan to lock it (the node itself, or the ESC and servo outputs) blocked the work queue. It also returned before the teardown that uavcan stop waits for, so the destructor gave up after 50 ms and freed the node while _instance still pointed to it. Log the error and continue, as Run() already does with the node status monitor: the slave only lets the node follow a higher-priority time master, and the node keeps publishing its own time without it.

Assisted-by: Claude:opus-5.5

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-10-16 16:47:03 -06:00
Benjamin CabéandJacob Dahl 997ba57dea fix(uavcan): initialize the node with the node ID of uavcan start (#29084)
* fix(uavcan): stop the node on an invalid node ID instead of exiting

With an invalid UAVCAN_NODE_ID, the first run of the node called exit() from the work queue of the CAN drivers, which stopped all of its work items. The node now reports the error and stops. "uavcan start" already refuses an invalid node ID, so this only happens when the parameter changes before the node runs.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>

* fix(uavcan): initialize the node with the node ID and bit rate of uavcan start

Run() read UAVCAN_NODE_ID and UAVCAN_BITRATE again, after uavcan start had read and validated them, and stopped the node when the node ID had become invalid in between. A node stopped that way could no longer be torn down: uavcan stop schedules Run(), which returned before the teardown, so the destructor gave up after 50 ms and freed the node while _instance still pointed to it. The node now keeps the node ID and bit rate that uavcan start validated, and initializes with them, so Run() has no error path left.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>

* fix(uavcan): pass the node ID and bit rate to the node constructor

start() set them after publishing the new node in _instance. After uavcan stop, the bus event callback stays registered on the CAN driver and schedules _instance from the interrupt, so on the next uavcan start a frame arriving in between could run Run() with an invalid node ID and the default bit rate, leaving the node passive until it is restarted. As const members set by the constructor, they are in place before the node is published, and can->init() takes _bitrate directly.

Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>

* fix(uavcan): reject the node IDs DroneCAN reserves for maintenance tools

uavcan start accepted node IDs 126 and 127, which UAVCAN_NODE_ID excludes. Now that Run() no longer checks the ID again, this check is the only one, so it matches the parameter's range.

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

---------

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-10-16 16:38:03 -06:00
Mathéo Taillandier 9ce8f5ae74 feat(mavlink): use MAV_SYS_STATUS_SENSOR_LASER_POSITION (#29193)
* feat(mavlink): use MAV_SYS_STATUS_SENSOR_LASER_POSITION

* docs(mavlink): add documentation
2026-10-16 10:50:48 -06:00
Benjamin Cabé 33109cd71d fix(top): stop when the input can't be polled (#29227) 2026-10-16 15:43:00 +02:00