The session open retry slept 5 s with sleep() and never checked for a
stop request, so `zenoh stop` timed out and force-deleted the task.
Wait in 100 ms steps instead and return as soon as a stop is requested.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Leonardo Cencetti <cencetti.leonardo@gmail.com>
A subscriber that could not be declared called exit(-1). That ended the
module task but left the zenoh-pico tasks running, so the session
stayed up with nothing bridged and `zenoh status` still reported it as
connected.
Return the error instead, and fail the topic setup when a subscriber or
publisher declaration fails.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Leonardo Cencetti <cencetti.leonardo@gmail.com>
* feat(commander): when disarmed, do not report ESC offline on battery blocking preflight checks
* fix(commander): keep the ESC checks with the supply check circuit breaker set
With CBRK_SUPPLY_CHK set the battery check returns without reporting a
missing required battery, so skipping the ESC checks let a vehicle arm
with that battery missing and its ESCs unpowered.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matheo-13 <matheo.taillandier@gmail.com>
* fix(commander): clear the ESC failure state while a required battery is missing
The skip only cleared the motor failure mask, leaving fd_motor_failure,
fd_esc_arming_failure and the ESC arming hysteresis at their last values:
after a battery dropped in flight and the vehicle disarmed, failsafe_flags
and failure_detector_status disagreed until the battery reconnected.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matheo-13 <matheo.taillandier@gmail.com>
* feat(commander): give the ESCs time to boot once a required battery connects
Once the battery reconnected the checks resumed against ESC timestamps
from before it was unplugged, so "ESC N offline" still showed while the
ESCs booted. Reuse the boot grace already given to ESC telemetry at
startup.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matheo-13 <matheo.taillandier@gmail.com>
* perf(commander): only read the batteries in the ESC checks when disarmed
The battery skip only applies on ground, so the armed path no longer
copies every battery instance each cycle.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matheo-13 <matheo.taillandier@gmail.com>
* test(commander): cover the ESC checks with a required battery missing
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matheo-13 <matheo.taillandier@gmail.com>
* fix(commander): block arming while the ESCs boot after a required battery connects
* test(commander): keep the failsafe flags across ESC check runs
Commander keeps the failsafe flags across check cycles, so zeroing them
before every run hid any flag the ESC checks forget to clear. Cover the
skip while a required battery is missing clearing a motor failure that
was latched in flight.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matheo-13 <matheo.taillandier@gmail.com>
* fix(commander): clear the motor stuck flag while a required battery is missing
The skip for a missing required battery returned before the motor stuck
flag was cleared, so a stuck motor flagged at spool-up stayed set on
the ground, unlike the other failure flags the skip clears.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Matheo-13 <matheo.taillandier@gmail.com>
---------
Signed-off-by: Matheo-13 <matheo.taillandier@gmail.com>
* fix(mavlink): read MAV_HB_FORW_EN via an atomic snapshot in the receiver
forward_message() reads it on the receiver thread while the main mavlink
thread updates the ModuleParams member in updateParams(). Flagged by TSan
in CI (hex, ThreadSanitizer, multicopter failure injection test).
Assisted-by: Claude:claude-opus-5-5
* fix(mavlink): read MAV_FWDEXTSP via an atomic snapshot in the receiver
The receiver thread reads it when handling setpoint messages while the
main mavlink thread updates the ModuleParams member in updateParams().
Assisted-by: Claude:claude-opus-5-5
* fix(mavlink): read SYS_FAILURE_EN via an atomic snapshot in the receiver
The receiver thread reads it when handling commands while the main
mavlink thread updates the ModuleParams member in updateParams().
Assisted-by: Claude:claude-opus-5-5
* fix(mavlink): read MAV_HASH_CHK_EN via an atomic snapshot in the receiver
MavlinkParametersManager runs on the receiver thread and reads it on
PARAM_SET of _HASH_CHECK while the main mavlink thread updates the
ModuleParams member in updateParams().
Assisted-by: Claude:claude-opus-5-5
* fix(mavlink): read MAV_TYPE via an atomic snapshot in the receiver
The receiver thread reads it when handling ODOMETRY while the main
mavlink thread updates the ModuleParams member in updateParams().
Assisted-by: Claude:claude-opus-5-5
* fix(commander): compare a GNSS home against GNSS while the global position is invalid
* test(commander): check that a GNSS home follows GNSS past the threshold
* feat(sensors/gnss): report how far each receiver is from the selected one
Commander compared the receivers itself, reading the sensors module's antenna offsets and comparing samples taken at different times. The sensors module has the receiver-to-slot matching and the corrected sample times, so it now publishes each receiver's disagreement with the selected one on sensors_status_gnss, horizontally and vertically.
The other receiver is moved along its velocity to the selected sample's time. The antenna baseline is rotated with the attitude, so swapped or misplaced antennas show once the primary estimator's heading is aligned. Before that only the distances are compared, since the yaw is arbitrary.
Co-authored-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
Assisted-by: Claude:claude-opus-5-5
* feat(commander): limit the GNSS divergence with COM_GNSS_H_MAX and COM_GNSS_V_MAX
The divergence gate came from the receivers' reported accuracy floored with EKF2_GPS_P_NOISE, so it was hard to predict and read another module's parameter. Commander now takes the disagreement from sensors_status_gnss and applies fixed horizontal and vertical limits. Three times the receivers' combined reported accuracy still widens them, so standalone receivers don't warn on default parameters.
Before arming a divergence is reported at once and clears after 2 s of agreement. In flight it has to persist for 2 s.
Co-authored-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
Assisted-by: Claude:claude-opus-5-5
* fix(commander): keep the GNSS divergence limits fixed
Widening the limits to three times the receivers' combined reported accuracy made them floors, not limits. With the default GNSS_REQ_EPH and GNSS_REQ_EPV the gate opened to 12.7 m horizontally and 21 m vertically before arming, and to about 210 m in flight once a receiver fell back to the relaxed checks. The limits now apply as set, with defaults of 5 m and 10 m so standalone receivers don't warn.
Assisted-by: Claude:claude-opus-5-5
* fix(commander): don't take an unknown GNSS disagreement for agreement
The sensors module leaves the disagreement unknown when the two latest samples are more than 0.5 s apart, while both receivers stay healthy. Commander treated that as nothing to compare, so a divergence before arming cleared for that check and an arm request could pass, and in flight the 2 s timer restarted. It happens on any gap over 0.5 s from a healthy receiver, and on 2 Hz receivers whose latencies differ. An unknown disagreement now keeps the state and its timer. A divergence still clears at once when there is no healthy pair to compare.
Assisted-by: Claude:claude-opus-5-5
* docs(commander): swapped GNSS antennas hide behind a moving-base heading
The moving-base heading takes its offset from the same antenna positions. With swapped antennas the heading turns by 180°, and the expected baseline turns with it, so the divergence check sees agreement.
Assisted-by: Claude:claude-opus-5-5
* docs(commander): reword the moving-base heading caveat
The sentence didn't say plainly that a moving-base heading from the same receivers stops the check from detecting swapped antennas.
Assisted-by: Claude:claude-opus-5-5
* docs(commander): fold the moving-base caveat into the swapped-antenna conditions
The caveat read as a repeat of the alignment sentence. It is one more condition for detecting swapped antennas, so it now sits with the others.
Assisted-by: Claude:claude-opus-5-5
* refactor(gnss): rotate the antenna baseline with the attitude as it is
The heading gate kept a limit below twice the antenna baseline from reporting a divergence before the heading aligned. With a mag the heading aligns before the receivers turn healthy. A heading from the same two receivers can't reveal swapped antennas anyway. The gate also never opened with an external INS, since only EKF2 publishes estimator_status_flags. Dropping it saves 168 B of flash on fmu-v2. The attitude age limit goes with it, since the last published attitude is a better guess than level and facing north.
Assisted-by: Claude:claude-opus-5-5
---------
Co-authored-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
* feat(simulation): add a differential rover to SIH
Add SIH_VEHICLE_TYPE 6 (Rover Differential) and the
10048_sihsim_rover_differential airframe, so rover_differential runs
headless with `make px4_sitl_sih sihsim_rover_differential`.
The model is a unicycle: each wheel is driven towards the ground speed
its motor command asks for (2 m/s at full command, matching
RO_MAX_THR_SPEED) up to its traction limit, and a lateral force keeps
the wheels from slipping sideways. Motor 1 is the right wheel and
motor 2 the left, as in the gz differential rover.
Closes#29838
Assisted-by: Claude:claude-opus-5-5
* docs(simulation): explain the forces in the SIH differential rover model
Label the longitudinal force block and the force, moment and drag
outputs of generate_rover_differential_dynamics(), as suggested in
review. Comments only, no change in behaviour.
Assisted-by: Claude:claude-opus-5-5
* feat(mavlink): make the MAV_x instance count a per-board Kconfig option
MAV_x_* params and rc.serial were fixed at 3, though up to 6 MAVLink
instances can run. CONFIG_MAVLINK_NUM_CONFIG_INSTANCES (default 3) sets it;
extra instances take instance 2's defaults.
Signed-off-by: abhijithcv <abhijithcv1212@gmail.com>
* feat(boards/agam): enable 5 MAVLink instances on the v6X-RT
Signed-off-by: abhijithcv <abhijithcv1212@gmail.com>
* docs(releases): add per-board MAVLink instance count to main release notes
Signed-off-by: abhijithcv <abhijithcv1212@gmail.com>
* fix(mavlink): share main's --board-config in the instance count generators
main already passes the boardconfig as --board-config to generate_params.py,
so the duplicate option failed every build after a rebase. Both generators now
read it through the shared load_board_config. Kconfig caps the count at 5,
or 3 on constrained-memory boards, leaving a channel for USB, and list
defaults keep their length check unless the count comes from Kconfig.
Signed-off-by: abhijithcv <abhijithcv1212@gmail.com>
---------
Signed-off-by: abhijithcv <abhijithcv1212@gmail.com>
exit_and_cleanup() deletes the instance, but Run() carried on into the
state machine and used the freed object.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
Drivers and arch code no longer include a header from inside the IO
firmware module.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Michael Rogov Papernov <michael@membrowse.com>
crc8_tab and crc_packet() were static in protocol.h, so every flight
controller image carried two copies of the table: one for the px4io
driver and one for the arch serial code.
Move them into a px4io_protocol library. This saves 304 bytes of FLASH
on px4_fmu-v6x; the IO firmware is unchanged.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Michael Rogov Papernov <michael@membrowse.com>
* fix(mag_bias_estimator): disable the mag bias estimator by default
It only helps if you have a very bad or no calibration in the first place or if the vehicle has magnets everywhere.
But it causes problems if you have a perfectly fresh calibration and no new disturbance
especially of course if the estimator runs twice, once on the can node, once on the autopilot.
* fix(mag_bias_estimator): remove the mag bias estimator from all cannodes
It will cause issues if the can nodes run their own online calibration and the autopilot expects to receive raw data. It's not super obvious but will lead to inaccuracies, drifts and inconsitencies in magnetometer heading.
Whenever the overall health/arming result changes, commander re-runs all
checks with the legacy mavlink_log publication and re-sends the
STATUSTEXT of every check that is still failing. Ground stations that
support events only drop these duplicates if the text starts with
"Preflight" or ends with a tab, so latched failures were shown again
each time an unrelated check changed.
Append the tab to the texts that duplicate an event but lacked it, as
described in docs/en/concept/events_interface.md:
- geofence violations (distance, altitude, custom fence)
- motor under/overcurrent and "not all ESCs armed"
- high ESC temperature
A mag bias reset that keeps the heading attributes the whole field
error to the bias, and its variance then converges without any
rotation. The bias is now only offered to the mag calibration once the
heading has changed by 90 degrees since its last reset.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: bresch <brescianimathieu@gmail.com>
The heading stays aligned when the mag stops in flight, so GNSS starts
against a heading that may have drifted. A 60 degree error is corrected
by the GNSS fusion, a reversed heading by a yaw emergency reset.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: bresch <brescianimathieu@gmail.com>
The trajectory only set the GNSS velocity, so the position stayed
fixed and contradicted it as soon as both were fused.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: bresch <brescianimathieu@gmail.com>
When the mag fusion stopped without North-East aiding, the yaw
alignment was cleared and the heading reset to the mag when it came
back, also in flight. As for GNSS yaw, the alignment is now only
cleared before takeoff, and never after a manual heading.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: bresch <brescianimathieu@gmail.com>
The manual heading flag expired after 30 s of heading fusion to allow
heading resets to the mag again. In flight those resets are gone, so
the flag now stays set and keeps protecting the heading on the ground.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: bresch <brescianimathieu@gmail.com>
A WMM update without North-East aiding reset the heading to the mag
and zeroed the learned mag bias, also in flight. The heading is now
only reset on the ground; in flight the bias absorbs the declination
change and the heading converges by yawing.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: bresch <brescianimathieu@gmail.com>
Without North-East aiding, a mag rejected for 7 s reset the heading to
the measured field, so a disturbed or wrongly rotated mag made the
heading jump in flight. The mag states now absorb the error instead.
Assisted-by: Claude:claude-fable-5-2
Signed-off-by: bresch <brescianimathieu@gmail.com>
Replaying about 150 logs found false positives only on standard VTOLs
after a quad-chute, with the tilt error above 60° for up to 1.75 s
while recovering from fixed-wing flight in multicopter mode.
All VTOL types switch to multicopter without back-transition on a
quad-chute, detected or commanded, and when a front transition is
aborted. The check now pauses for 5 s after such a switch instead of
raising the threshold for all VTOLs, so it protects the rest of the
multicopter flight.
The tilt check limits the error from the attitude setpoint, which the
FD_FAIL_R name no longer describes. FD_FAIL_R becomes FD_TILT_ERROR,
now a float, and FD_FAIL_R_TTRI becomes FD_TILT_ERROR_T.
The old roll and pitch limits and trigger times meant something else,
so they start at the new defaults instead of being taken over. Only a
check disabled for both roll and pitch stays disabled, as -1.
Cover the tilt error check: threshold in all directions, error relative
to the attitude setpoint, yaw ignored, fallback to level with a stale
setpoint, disabling, trigger time and its reset, and the tailsitter
fixed-wing frame.
Also make the altitude loss tests independent of each other: the
fixture set parameters after the detector had read them on
construction, so each test ran with the previous test's values. Both
fixtures are now the detector's parameter parent, like Commander, and
apply parameters with updateParams().
Checking the absolute tilt from level conflicts with the vehicle's own
tilt limits: the threshold can be set below the maximum tilt, and
external modes that tilt further than the autopilot's limits trip the
check, so they can't benefit from its crash detection.
Compare the tilt with the attitude setpoint's tilt instead, falling back
to level without a recent setpoint, e.g. on rovers. Before arming the
setpoint is level, so a vehicle lying on its side still can't arm. The
tailsitter transition exception is no longer needed because the
transition setpoint is in the multicopter frame. The default trigger
time goes from 0.3 s to 1 s so that fixed-wing stick reversals, which
pass through a large error at a limited roll rate, don't trigger it.
Also reset the tilt hysteresis while attitude control is off, so a
pending trigger from before e.g. Acro can't skip the trigger time when
attitude control comes back on.
Checking roll and pitch against separate limits misses a combined
tilt: 45° roll with 45° pitch is a 60° tilt but stays below both
default 60° limits. Euler angles are also unreliable near 90° pitch
and when inverted.
FD_FAIL_R and FD_FAIL_R_TTRI now set the maximum tilt and its trigger
time. FD_FAIL_P and FD_FAIL_P_TTRI are removed without migration
(see the Upgrade Guide). The check is disabled with -1; 0 still
disables it for existing setups. In FailureDetectorStatus, fd_roll
and fd_pitch are replaced by fd_tilt.
When the battery estimate did not reach Home, type 6 took the closest
rally point even when it was farther away than Home. Return compares
destinations only by straight-line distance, so it has no reason to
prefer a rally point that is farther away than Home, and return.md says
type 6 falls back to Home unless a rally point is closer. Returns
started by the distance-aware battery failsafe hit this case.
Compare the rally points with the distance to Home, as type 6 already
does without a battery estimate.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: jonas <jonspero@me.com>
* fix(failsafe): allow GNSS loss to recover during the Hold delay
A GNSS failure that clears during the COM_FAIL_ACT_T Hold still latched
Return or Land, because COM_GNSSLOSS_ACT uses the OnModeChangeOrDisarm
clear condition. The vehicle then abandoned a mission it could have
continued.
If the failure clears while the vehicle is still holding, the action is
dropped and the user-intended mode continues, e.g. the mission resumes.
Once Return or Land has started, it stays latched as before. With
COM_FAIL_ACT_T=0 there is no Hold, so nothing changes.
Assisted-by: Claude:claude-opus-5-5
* fix(failsafe): restart the Hold delay after a failure clears during it
When a failsafe cleared during its Hold delay, the remaining delay kept
counting down. A new failure within that time did not reload it and only
got what was left, so it could Return almost without a Hold.
Reset the delay once no failsafe is pending, so that the next failure
gets the full COM_FAIL_ACT_T again. This applies to every failsafe.
Repeated failures still escalate: the start delay shrinks while a Hold
is active and refills at a quarter of that rate.
Assisted-by: Claude:claude-opus-5-5
* revert(failsafe): keep the remaining Hold delay after a failure clears
This reverts commit 5e9a8e8a14.
Restarting the delay for every new failure changed how a flapping
condition is handled, for every failsafe and not only GNSS. Without the
reset, a failure that comes back keeps the delay left over from the
previous one, so the action still fires on time. With it, only the start
delay escalation limits the flapping, which can take much longer, or
never fire if the condition is active less than a fifth of the time.
Keep the PR scoped to letting GNSS loss recover during the Hold.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
* fix(failsafe): only clear GNSS loss during the Hold delay before Return starts
_current_delay is shared between failsafes. If another failsafe with a
delay is added on the same update as GNSS recovers, it re-arms the delay
and the GNSS Return or Land that was already running got removed.
Also require that the selected action is not beyond Hold yet.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
---------
Signed-off-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
Co-authored-by: Anil Kircaliali <anil.kircaliali@auterion.com>
The receiver thread answers TIMESYNC requests and REQUEST_EVENT
directly from handle_message(). Both sends went through
_mav_finalize_message_chan_send() without lock_send(), so they raced
with Mavlink::task_main on the shared per-channel mavlink_status_t
(current_tx_seq). TSan caught this in the SITL hex tests:
Read current_tx_seq task_main HIGHRES_IMU stream (holds lock_send)
Write current_tx_seq mavlink_rcv MavlinkTimesync::handle_message
The other receiver-side senders (mission, params, ftp, commands) already
take lock_send(); these two were missed.
Assisted-by: Claude:claude-opus-5-5
The log handler opens the log file in the receiver thread, but on
'mavlink stop' its destructor runs in the stop task and fclose()s 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 corrupts the heap when USB is 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.
Ported from the v1.18 fix in #29187.
Signed-off-by: Julian Oes <julian@oes.ch>
Run() calls exit_and_cleanup(desc) when should_exit() is set. That deletes the object, but Run() then continues to use _vehicle_status_sub, so the stop path reads freed memory.
Add the missing return. Reproduced with an ASan SITL build:
ERROR: AddressSanitizer: heap-use-after-free ... READ of size 8
#0 uORB::Subscription::subscribe() platforms/common/uORB/Subscription.cpp:48
#1 uORB::Subscription::updated() platforms/common/uORB/Subscription.hpp:133
#2 mag_bias_estimator::MagBiasEstimator::Run() MagBiasEstimator.cpp:84
freed by: MagBiasEstimator::~MagBiasEstimator()
Trigger: 'mag_bias_estimator start', then 'mag_bias_estimator stop'.
Assisted-by: deepseek
Signed-off-by: Summermu <23356722+Summermu@users.noreply.github.com>
* docs(parameters): add 4 new units
- A/V (ampere per volt)
- Pa (pascal)
- Pa/V (pascal per volt)
- MHz (megahertz)
* docs(parameters): add missing units
These parameters have a physical unit (often stated in their own
description) but no unit field, so QGC and the parameter reference show
them as unitless.
Add the missing units to 116 parameters.
Assisted-by: Claude:claude-opus-5-5
* docs(parameters): drop units from descriptions now in the unit field
Assisted-by: Claude:claude-opus-5-5
* fix(microstrain): label orientation parameters deg
src/drivers/ins/microstrain/MicroStrain.cpp requires these to be in
degrees (they are converted to radians at line 1121-1124), but the param
docstring mentioned which was moved to the unit field just before.
Fix by labelling correctly as degrees.
Signed-off-by: Balduin <balduin@auterion.com>
* docs(parameters): fix smaller inconsistencies
Address review from @dakejahl:
- mc_nn_control: MC_NN_MIN_RPM also in units of rpm
- sensors: remove redundant '#unit: Pa' comment
- microstrain: Typo in MS_GNSS_OFF2_Z
Signed-off-by: Balduin <balduin@auterion.com>
---------
Signed-off-by: Balduin <balduin@auterion.com>