Commit Graph
30603 Commits
Author SHA1 Message Date
Anil Kircaliali c348557ed0 test(navigator): reserve capacity for rally points in RTL test setup 2026-11-25 16:53:48 +01:00
Anil Kircaliali c4e66ad303 feat(navigator): RTL type 6 takes the quickest rally point instead of the closest 2026-11-25 16:48:22 +01:00
Anil Kircaliali eac17f53aa fix(navigator): publish a fallback estimate only for a quicker rally point 2026-11-25 16:22:00 +01:00
Anil Kircaliali fab43dd1a3 fix(navigator): compare the battery with the lowest RTL type 6 estimate
Signed-off-by: Anil Kircaliali <anil.kircaliali@auterion.com>
2026-11-25 15:45:06 +01:00
Balduin 07154a8eca fix(logger): two thread safety fixes (#29996)
* fix(logger): hold the writer lock while starting a log file

LogFileBuffer::start_log() resets _fd, _buffer, _head, _count and
_should_run without the lock, while the writer thread reads them under it
(it can already be running for the other log type). TSan flags this on
log start in SITL CI.

The PX4_CRYPTO failure path had the same problem, and could additionally
let the writer thread write to a file that is being closed.
init_logfile_encryption() also sets _min_blocksize, which the writer
reads under the lock, so it moves into the locked section as well.

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

* fix(logger): make the log buffer run flag atomic

is_started() reads _should_run without the writer lock, from the logger
thread and from print_status() on the shell thread. The writer thread
clears it on a write error.

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

* refactor(logger): use LockGuard instead of manual lock/unlock

 - Create extra scope in which to define the LockGuard
 - Replace return logic with early-return to avoid deepening scopes

---------

Signed-off-by: Balduin <balduin@auterion.com>
2026-11-25 13:10:09 +01:00
Jonas PeroliniandAnil Kircaliali 4c1d82bf37 fix(navigator): include the VTOL land approach in the Home reach check (#30007)
RTL_TYPE 6 estimated Home without the VTOL land approach to decide
whether Home is within reach, while the Return flies the approach and
the published estimate includes it. Home could count as reachable while
the published estimate already exceeded the battery. Estimate Home with
the land approach applyReturn() configures.


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

Signed-off-by: jonas <jonspero@me.com>
Co-authored-by: Anil Kircaliali <anil.kircaliali@auterion.com>
2026-11-25 12:03:47 +01:00
Jonas Perolini afc7f1aaca refactor(navigator): estimate Returns without configuring RtlDirect (#30006)
RtlDirect::calc_rtl_time_estimate() only estimates the configured
Return, so RTL_TYPE 6 configured RtlDirect for Home to estimate it and
relied on applyReturn() to configure the selected destination again
right after. estimateReturnTo() takes the target as input instead. The
Home estimate keeps the same inputs, so its result does not change.

on_inactive() writes out select, apply and publish, so the 2 s cycle
can pass a value from the selection to the publisher.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: jonas <jonspero@me.com>
2026-11-25 11:37:15 +01:00
Andrea BernasconiandMatthias Grob 6e3073e558 fix(timesync): replace double exponential filter with Kalman filter (#29900)
* fix(timesync): replace double exponential filter with time-based Kalman filter

The double exponential filter had per-sample gains and a per-sample skew.
Its dynamics therefore depended on how often the caller exchanged timesync
packets: tuned for MAVLink at 10 Hz, the uXRCE-DDS client at 1 Hz got a
10x slower, underdamped filter (~40 min ringing period). Moreover, the skew
learned during the fast initial sync burst (~70 Hz) was applied per second
afterwards, so it was off by the ratio of the two intervals.

As a result any remote clock correction below the 100 ms reset threshold,
for example from chrony right after the companion boots, kept the estimate
more than 10 ms off the observed offset for 10-20 minutes.

A two-state Kalman filter (offset, skew in us/s) predicts with the actual
time between samples, so its behaviour no longer depends on the sample
rate, and it replaces the sample-count gain schedule. In replays of startup
clock slews and steps of 20-90 ms, the time with more than 10 ms between
observed and estimated offset drops from 11-20 min to under 2 min. The
steady-state estimate noise rises from ~65 to ~130 us RMS at 1 Hz.

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

* refactor(timesync): express the filter state in seconds

Keep the offset in s and the skew in s/s so all tuning constants share
SI units instead of mixing us and s. offset() is the only conversion
back to us for the interface. The estimate is unchanged.

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

* refactor(timesync): document the Kalman filter prediction

Explain where the process noise terms come from and write the
covariance prediction in Horner form. Shorten the tuning comments.

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

* test(timesync): add convergence tests for remote clock corrections

Simulate a drifting remote clock with uXRCE-DDS-like sampling (fast
initial exchange, then 1 Hz) and check steady-state accuracy and the
recovery from steps and ramps, plus the same at a constant 10 Hz.

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

* fix(timesync): add offset process noise to damp clock step response

With process noise only on the skew, the filter settles to a damping
ratio of 1/sqrt(2) regardless of tuning, so a step of the remote clock
overshoots by ~20%. Adding a random walk on the offset raises the
damping to ~0.9. The skew random walk is lowered so the steady-state
noise stays the same.

On a Skynode with a +60 ms companion clock step the overshoot drops
from 12.3 to 9.2 ms and the error is back within 10 ms after 0.4
instead of 1.5 min.

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

* fix(timesync): raise offset process noise to reduce step overshoot

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

* docs(timesync): document the Kalman filter model and Q derivation

Define the state, the continuous-time model and the measurement model,
and show why the discrete process noise Q_d is the exact solution of
the hybrid Kalman filter prediction. The tuning constants and the
comments in the code use the same symbols, so they can be checked
against the linked references.

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

* refactor(timesync): Make test more strict

* refactor(timesync): simplify Kalman update and reset

---------

Signed-off-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
Co-authored-by: Matthias Grob <maetugr@gmail.com>
2026-11-25 10:49:10 +01:00
Jonas Perolini b5cf23cc9f perf(navigator): speed up the contingency geofence check (#30005)
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: jonas <jonspero@me.com>
2026-11-25 10:33:13 +01:00
Beniamino Pozzan 5e9be2a6d5 fix(sensor_airspeed_sim): use vehicle_attitude_groudtruth (#29878)
* fix(sensor_airspeed_sim): use vehicle_attitude_groudtruth

Don't use the EKF estimated attitude.
Use the groundtruth one like with the other inputs:
- local pos
- global pos

Signed-off-by: Beniamino Pozzan <beniamino.pozzan@auterion.com>

* chore(sih): rename SensorAirspeedSim groundtruth subscribers

Signed-off-by: Beniamino Pozzan <beniamino.pozzan@auterion.com>

---------

Signed-off-by: Beniamino Pozzan <beniamino.pozzan@auterion.com>
2026-11-25 10:11:13 +01:00
Jonas Perolini 6ba78c3452 fix(navigator): measure the last Return leg from the end of the detour (#30004)
Around a geofence, the direct Return flies a detour: to the first
corner, along the corners, then from the last corner to the
destination. The time estimate added the legs up to the last corner,
then the straight distance from the vehicle to the destination instead
of the distance from the last corner. For a destination close behind a
wide exclusion zone the estimate was too low, so the distance-aware
return failsafe could trigger too late.

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

Signed-off-by: jonas <jonspero@me.com>
2026-11-25 09:16:19 +01:00
Jonas Perolini c6ba14a448 test(parameters): rename _param_sys_autocfg to _param_sys_autoconfig (#30011)
check_format requires parameter members to be named
_param_<lower case parameter name>. It fails on main since the
DEFINE_PARAMETERS table test added this member.

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

Signed-off-by: jonas <jonspero@me.com>
2026-11-24 17:56:57 -07:00
Jacob Dahl ccd9eae185 refactor(platform): load DEFINE_PARAMETERS members from a table (#29554)
* fix(cmake): link the functional gtest libraries as a group

px4_platform, parameters and uorb_msgs all reference uORB, but uORB is
listed before them, so a test only linked when something earlier
happened to pull in px4_log.o. Inlined param_get() type checks did that
for any test using DEFINE_PARAMETERS; without them PerformanceModel and
StickYaw failed with undefined orb_advertise and orb_publish.

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

* refactor(platform): load DEFINE_PARAMETERS members from a table

Every parameter cost a param_get_mark_used() call in its class
constructor and a param_get() call in updateParamsImpl(), about 12 bytes
each, for roughly 2000 parameters. Each Param now takes one
pointer-sized slot, so the members a DEFINE_PARAMETERS list declares
form an array. A ParamTable member declared right after them holds the
handles and loads them all with one call, in the constructor and on
update. External parameters keep a pointer instead of a reference so
the loader can follow it.

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

* refactor(platform): use param_t for parameter table entries

Each entry is a parameter handle with the storage kind in its top bits,
so it takes the handle's type.

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

* refactor(platform): keep each Param at its natural size

Padding every Param to a pointer-sized slot doubled float and int32
members on 64-bit targets and grew ParamBool from 1 to 4 bytes. The
macro now passes the first parameter's address to the table, and the
loader steps through the members at each kind's own size and alignment.
A table placed before the parameters would instead load through the
external parameters before their pointers are set.

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

* refactor(platform): drop the parameter table end marker

APPLY_ALL leaves a comma after every entry, so the template argument
list needed a closing element, which every class then stored in its
entry array. The entries are now a static array of the class, whose
braced initializer accepts the trailing comma.

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

* refactor(platform): check the parameter layout at compile time

The language leaves padding between members to the compiler, so the
table loader relies on the ABI placing each member at the next address
its alignment allows. Each class's updateParamsImpl() now checks every
parameter's offsetof against where the loader steps, so a compiler that
pads differently fails the build instead of loading into the wrong
members.

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

* docs(platform): describe how DEFINE_PARAMETERS loads parameters

The table loader walks the members of a class from the first parameter's
address, which is not obvious from the macros or the loader alone. A
block above the macros now states the flash cost it removes, what the
macro adds to a class, how the loader steps, and which static_asserts
guard the layout it relies on.

The namespace comment said a Param does not depend on the macro. That
stopped being true when the constructors stopped loading.

Assisted-by: Claude:claude-fable-5-2

* docs(platform): drop the flash figure from the parameter table comment

A measured saving for one board goes stale as parameters are added. The
comment now states what the table replaces the per-parameter calls with.

Assisted-by: Claude:claude-fable-5-2

* fix(platform): build the parameter layout check on GCC before 9

GCC 7 and 8 ignore _Pragma diagnostics inside a macro expansion, so the
offsetof warning in the DEFINE_PARAMETERS layout check stays an error on
the VOXL 2 toolchain. Those compilers now build with
-Wno-invalid-offsetof. The static_assert still runs there.

Assisted-by: Claude:claude-opus-5-5
2026-11-24 17:04:42 -07:00
Jonas PeroliniandSilvan Fuhrer b03d179c3b feat(navigator): add a parameter-based contingency geofence (#29885)
Assisted-by: Claude:claude-fable-5-2

Signed-off-by: jonas <jonspero@me.com>
Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
2026-11-24 23:10:39 +01:00
Mahima Yoga d090301e48 fix(FwModeManager): use terrain altitude in tip-strike logic during landing (#29952) 2026-11-24 12:15:45 +01:00
Vishal KotakandVishal Kotak c726623da2 fix(commander): check the mapped rover sticks before arming (#29899)
* fix(commander): check the mapped rover sticks before arming

Since rovers map their sticks with RO_STICK_MAP, the throttle stick is no
longer always the one that drives them. With RO_STICK_MAP=2 commander
still checked the left vertical stick, so a rover could be armed with
the right stick pushed fully forward.

Run the sticks through the rover stick mapping and deny arming when the
forward stick, or the lateral stick on a mecanum rover, is off center.

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

* fix(commander): check the rover's tank sticks in manual parking

Manual parking on differential and mecanum rovers drives the left and
right wheels with the vertical sticks and ignores RO_STICK_MAP, so the
mapped check could still let the rover arm with a wheel stick pushed.

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

* style(rover): wrap the sticksCommandMotion signature for astyle

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

* fix(commander): check each tank stick on its own in manual parking

In manual parking each vertical stick drives one side of wheels, so averaging them let a rover arm while turning on the spot or with one stick partly pushed.

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

* refactor(rover): rename tank_sticks to tank_style_sticks

Review feedback.

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

---------

Co-authored-by: Vishal Kotak <22182951+vishalkotak@users.noreply.github.com>
2026-11-24 09:32:43 +01:00
DuoYuWang f7030f3772 fix(drivers/bmi055): bound FIFO SPI transfer by buffer size (#29944)
BMI055_Accelerometer clamped samples * sizeof(FIFO::DATA) + 1 to FIFO::SIZE (192) rather than sizeof(buffer) (193), truncating the last byte of the 32nd sample. BMI055_Gyroscope clamped against FIFO::SIZE (600) instead of the 193-byte stack buffer, risking an over-read if a caller ever passed more than 32 samples.


Assisted-by: Antigravity

Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com>
2026-11-23 12:04:58 -07:00
Beniamino Pozzan 5deae0ff24 fix(mavlink): adjust comment for estimator_sensor_fusion_source index (#29470)
Signed-off-by: Beniamino Pozzan <beniamino.pozzan@auterion.com>
2026-11-23 17:34:52 +00:00
Anil Kircaliali 5db5c623a1 fix(logger): use selected device_id to choose sensor in fifo logging (#29751)
* fix(logger): use selected device_id to choose sensor in fifo logging

* fix(logger): keep logger_topics.txt fifo instances and skip profile fifo without a matching selected imu

* docs(logger): describe fifo logging of the selected imu
2026-11-23 14:31:17 +01:00
Roman BapstandBalduin 3d743529c5 fix(tecs): low-pass the throttle energy rate error, not the estimate (#29877)
* fix(tecs): low-pass the throttle energy rate error, not the estimate

The throttle feedback compared an unfiltered total energy rate setpoint
with an estimate low-passed by FW_T_STE_R_TC. On a setpoint change the
lag between the two showed up as a phantom error that the proportional
and integral paths acted on, pushing the throttle beyond what the
feedforward already demanded. Filter the error instead: setpoint and
estimate then see the same lag and only true tracking errors reach the
feedback, while the feedforward keeps acting on the unfiltered setpoint.

The airspeed-less altitude step test no longer needs to disable the
filter: on the step up the phantom error sped the vehicle up by 3 cm/s,
beyond the test's airspeed tolerance, and now it stays within it.

Assisted-by: Claude Fable 5.1
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>

* test(tecs): enable the altitude step again

The throttle filter lag inconsistency introduced some small airspeed
errors. Now after the fix we can enable these cases again.
 - AltitudeStepUp: enable, was completely disabled
 - AltitudeStepUpDefaultTuningPitchOffset: uncomment the low airspeed
   error assertion

* test(tecs): tighten overall tolerance

 - MAX_NUMERICAL_ERR: halve it, most tests improved due to the filter
   lag fix
 - Airspeedless: Allow twice the default tolerance (same as before...)
   as there we don't have feedback constantly reducing the error and it
   instead accumulates.

---------

Signed-off-by: RomanBapst <bapstroman@gmail.com>
Co-authored-by: Balduin <balduin@auterion.com>
2026-11-23 13:08:50 +03:00
Alessandro FerraioliandMatthias Grob 0e9c5ec321 fix(mavlink): publish mission state under the shared-state lock (#29835)
* fix(mavlink): publish mission state under the shared-state lock

All Mavlink instances share one static copy of the active mission.
Writers updated it under _shared_state_mutex but published the mission
topic only after releasing the lock, and check_active_mission() copied
the topic before taking it. An instance could therefore copy the
previous mission while another instance had already stored a new
upload, then roll the shared state back to it. The next geofence/rally
count update republished the rolled-back state and the navigator
dropped the new mission.

Publish while holding the lock and copy the topic under it, so the copy
always matches or is newer than the shared state it is compared with.
update_active_mission() now publishes before persisting the mission
state to dataman, so the lock is not held across the dataman write.

Add a functional test that runs two instances concurrently and checks
that a stored mission is never rolled back to an older upload.

Signed-off-by: Alessandro Ferraioli <alessandro.ferraioli@auterion.com>

* fix(mavlink): persist mission state before publishing it

Publishing the mission before writing DM_KEY_MISSION_STATE lets
navigator act on the new mission before it is persisted. If the new
mission fails the feasibility check, navigator restores the previous
mission and writes DM_KEY_MISSION_STATE itself. If the mavlink write
lands after that, it overwrites the restored state with the infeasible
mission: the vehicle keeps flying the previous mission, but after a
reboot it loads the infeasible one, fails the check again, and the
previous mission is lost.

The window is small because dataman serializes requests, but the order
is not guaranteed, e.g. if the mavlink thread is preempted between the
publish and the write.

Keep the original persist-then-publish order and hold
_shared_state_mutex across both, consistent with
update_geofence_count() and update_safepoint_count(), which already
hold the lock across their dataman write. Other instances'
check_active_mission() and send() now wait for the
DM_KEY_MISSION_STATE write during a mission upload, as they already do
for fence and rally uploads.

---------

Signed-off-by: Alessandro Ferraioli <alessandro.ferraioli@auterion.com>
Co-authored-by: Matthias Grob <maetugr@gmail.com>
2026-11-23 10:54:18 +01:00
Leonardo Cencetti 3ce61ab927 fix(zenoh): retry a failed session or topic setup (#29926)
* fix(zenoh): retry a failed session or topic setup

A failed setup stopped the module for good, e.g. when the session is
lost right after it opened. Clean up and set the session up again
after 5 s instead.

The cleanup also closes the topic mapping that a failed setup leaves
open, so the retry reads the config from its start.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Leonardo Cencetti <cencetti.leonardo@gmail.com>

* fix(zenoh): release the topic resources on a cleanup

Signed-off-by: Leonardo Cencetti <cencetti.leonardo@gmail.com>

---------

Signed-off-by: Leonardo Cencetti <cencetti.leonardo@gmail.com>
2026-11-23 09:30:18 +00:00
Roman BapstandBalduin ff37963842 test(tecs): add closed-loop unit tests for TECSControl (#29875)
* test(tecs): add closed-loop unit tests for TECSControl

Couple TECSControl to a minimal aircraft model built from the energy
model TECS assumes internally: a piecewise linear throttle to total
energy rate map, climb rate from pitch and airspeed, and the remainder
of the energy rate into airspeed. With perfect state knowledge and no
model mismatch any tracking error is the controller's own, so the suite
exposes consistency errors between the pitch and throttle loops that
the unit tests on single updates cannot see.

Only the cases the current controller passes are included: steady
cruise, airspeed steps, a slow altitude step down, plant pitch offset,
gliding, fast descend and airspeed-less cruise. The altitude steps at
the default vertical acceleration, with a speed weight below 1 and
without airspeed fail today and come with the fixes they test.

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

* test(tecs): explain why the airspeed step down is not first order

The step down is not first order because the SEB rate to pitch
conversion ignores the total energy rate: the pitch feedforward climbs
with the kinetic energy the throttle is already removing, and the pitch
integrator takes it out again. The loops interacting is not the cause;
with a consistent conversion the response is first order.

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

* test(tecs): use the current year in the closed-loop test copyright

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

* test(tecs): drop the altitude reference model from the closed-loop test

The closed-loop harness is meant to test TECSControl on its own, but the
altitude setpoint went through TECSAltitudeReferenceModel first, so the
altitude step results also depended on how the reference model shapes
the setpoint. Feed TECSControl the raw altitude setpoint instead.

A raw step drops the throttle to idle at once, so the altitude step only
keeps airspeed exact if the pitch can follow just as fast. In TECSControl
the vertical acceleration limit only rate limits the pitch, so the step
test now disables it, and sizes the step so that the demanded sink rate
stays within FW_T_SINK_MIN, the sink rate flown at idle without speeding
up.

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

* test(tecs): show the airspeed-less altitude step with half the SEB feedforward

Without airspeed the speed weight is 0, so the SEB rate is twice the
potential energy rate, while the pitch feedforward converts it to a climb
angle as if they were equal and asks for twice the climb rate. With the
feedforward gain at 0.5 the vehicle flies the demanded climb rate exactly
and the altitude error decays first order with FW_T_ALT_TC, which the
test checks for a step down and a step up. At the default gain of 1 the
same checks miss by up to 1.8 m.

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

* test(tecs): disable the STE rate filter in the airspeed-less altitude step

The low-pass filter on the total energy rate estimate lags the step, so
the throttle damping briefly overfunds the climb on the step up and the
open loop airspeed rose by 3 cm/s, which the test allowed for with a
looser bound. Disable the filter instead and hold the airspeed to the
numerical tolerance like the other exact cases.

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

* test(tecs): disable vert_accel_limit generally

* test(tecs): count closed-loop simulation steps as an integer

Accumulating the simulation time in float drifts (the second altitude step
of a test landed at 40.0007 s) and the float loop condition could run one
step more than the requested duration. Count steps instead and derive the
time from the step count.

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

* test(tecs): unify error tolerance

Replace various hardcoded tracking tolerances:
 - Add a second general constant for the tolerance of tracking errors
   which do NOT scale down with smaller DT
 - Adjust settling times so all tests reasonably reach this threshold

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

* test(tecs): add a make target to plot the closed-loop test cases

The closed-loop test writes one CSV per test case when TECS_TEST_LOG_DIR
is set, but reading the step responses from numbers is tedious. Add the
plotting script back and a tecs_closed_loop_plots target that runs all
test cases with logging and plots them into
build/px4_sitl_test/tecs_closed_loop/png, also when test cases fail.
It is a separate target so that make tests and CI do not depend on
matplotlib.

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

* test(tecs): rename the closed-loop test to TECSControlClosedLoopTest

The test drives TECSControl, not the outer TECS class, so name it after
the class under test like TECSTest.

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

* test(tecs): clean up logging & variable names

Stop mixing up previous and current steps:
 - _pitch and _throttle hold the last TECS command, which the plant
   applies until the next update (drop the _prev naming)
 - reorder logging, so each row pairs a state with the command
   computed from it:
     - find control input
     - sim stats, csv output
     - advance simulation

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

* docs(test): document the TECS closed-loop test logging and plots

The closed-loop TECS test can log every test case to CSV and plot them
with the tecs_closed_loop_plots target, but neither is discoverable from
the docs. Describe both next to the other make tests options.

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

* test(tecs): standardise step sizes

Use one altitude and one airspeed step size for all step tests, so the
tests are easier to compare:
 - ALT_STEP chosen to not saturate throttle while sinking or climbing
     - Altitude step up test added (disabled, see comment)
 - AIRSPEED_STEP = 1 m/s
     - Only effective change is gliding (previously 2 m/s steps)
 - FastDescend drops the altitude setpoint, which does not affect it, and
   checks the throttle is exactly at its minimum

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

* test(tecs): comment polishing

* test(tecs): tighten bounds for the weird airspeed response

* test(tecs): disable pitch damping

Removes the ringing artifacts. I think pitch damping makes no sense in
this sim, see comment for details.

* test(tecs): Require low errors after integrator

And add another future test (altitude step up currently still gives a
bit too much airspeed error)

---------

Signed-off-by: RomanBapst <bapstroman@gmail.com>
Signed-off-by: Balduin <balduin@auterion.com>
Co-authored-by: Balduin <balduin@auterion.com>
2026-11-23 11:23:31 +03:00
Saibernard YogendranandBalduin 081695e0fb refactor(vtol_att_control): share the transition state machine (#29808)
* refactor(vtol_att_control): move the transition state machine into VtolType

Standard, tiltrotor and tailsitter each kept a private vtol_mode enum and
a 100-line update_vtol_state() that walked the same four-state graph
(hover, transition to FW, transition to MC, FW) and then mapped it onto
the common mode enum. The only type-specific parts were the completion
predicates and a handful of entry side effects, so fixes to the graph
(like the 2016 "restart the front transition instead of jumping to FW
from a back transition" change in c6e4926d4e) reached one type and not
the others.

VtolType::update_vtol_state() now runs the graph on _common_vtol_mode
directly, and the types override only:

- isBackTransitionCompleted(): speed/time (standard, with on-ground),
  tilt and speed/time (tiltrotor), pitch or time (tailsitter). The shared
  speed/time check is isBackTransitionSpeedOrTimeExitConditionMet().
- canSwitchToFixedWingDuringBackTransition(): true for tiltrotor and
  tailsitter to keep their current instant switch, false (restart the
  front transition) for standard.
- onTransitionStart(): tailsitter resets its start-attitude latch,
  tiltrotor resets its phase-2 flag.
- onFrontTransitionCompleted() / onFrontTransitionAborted() /
  onFixedWingSystemFailure(): standard pusher throttle and transition
  pitch latch, tailsitter thrust-bridging timestamp.

The tiltrotor's TRANSITION_FRONT_P2 becomes a private sub-phase of
TRANSITION_TO_FW, entered from update_transition_state() when the common
front-transition check passes and left when the tilt reaches VT_TILT_FW.

Deliberate small deviations from the previous per-type code:

- _trans_finished_ts is set on every switch into FW mode, including the
  tiltrotor's phase-2 completion and the tiltrotor's instant switch from
  a back transition (previously only at the tiltrotor's P1->P2 handoff).
- the standard VTOL set its MC weights every loop in hover and FW mode;
  they are now set in update_mc_state()/update_fw_state(), i.e. on the
  next attitude-setpoint update.
- the standard VTOL zeroed its pusher throttle on every loop while
  fixed_wing_system_failure was set; it now does so once on the switch
  to hover and update_mc_state() takes over as in any hover flight.

Rebased onto the tailsitter and tiltrotor back transition fixes. The
canSwitchToFixedWingDuringBackTransition() bullet above describes the
code before them. The hook now returns false for the tailsitter, which
restarts the front transition like the standard VTOL, and the
VT_TILT_TRANS check for the tiltrotor.

Also rebased onto the change that stops treating a commanded quad-chute
as a fixed-wing failure. The state machine now reads
is_quadchute_active() instead of fixed_wing_system_failure, and
onFixedWingSystemFailure() is now onQuadchute(), called on every update
while a quad-chute holds the vehicle in hover. Each type keeps the
condition its own update_vtol_state() had: the tailsitter sets its
thrust-bridging timestamp only on the switch to hover, and the standard
VTOL zeroes its pusher on the switch and, while the quad-chute is a
detected one, on every update. The onFixedWingSystemFailure() name in
the bullets and the last deviation above describe the code before that
change.

Signed-off-by: Balduin <balduin@auterion.com>
Assisted-by: Claude:claude-fable-5-2
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>

* refactor(vtol_att_control): drop the redundant tailsitter hook override

Since the rebase onto the back transition fixes the tailsitter's
canSwitchToFixedWingDuringBackTransition() returns the base class
default, so drop the override. The tailsitter restarts the front
transition through the shared state machine like the standard VTOL.

Give the tiltrotor check the reason it had in its update_vtol_state()
and remove the blank lines left where the per-type enums were. No
behaviour change.

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

* style(tiltrotor): remove stale comment

This comment was added in 02fda7a0f5 (2015) describing a
`rear_motor_state` enum. The enum has then been moved to a general
`motor_state` in 744f806214 (2018) which has then been completely
removed in ce337a3d80 (2022).

* refactor(vtol_att_control): rename the shared front transition check

For the tiltrotor the shared VtolType::isFrontTransitionCompleted() only
meant that phase 2 of the front transition can start, while
Tiltrotor::isFrontTransitionCompleted() means the rotors have reached
VT_TILT_FW and the vehicle can switch to fixed-wing. Two functions with
the same name answered different questions.

Rename the shared one to isFrontTransitionSpeedOrTimeReached() and make
isFrontTransitionCompleted() pure virtual. The tiltrotor keeps its
override and starts phase 2 from the renamed check. Standard and
tailsitter return the renamed check, which is what they used before.

No functional change. Suggested by Balduin in review.

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

* refactor(vtol_att_control): rename the shared back transition check

Match the name of isFrontTransitionSpeedOrTimeReached. I also find it
clearer to not label it 'ExitConditionMet' because for the tiltrotor the
exit condition is literally not already met, because of the added

* refactor(vtol_att_control): default isFrontTransitionCompleted to the shared check

This way we only have to override it if it is different from the current
default (completed = speed or time reached), i.e. only for tailsitter.

* refactor(vtol_att_control): drop isFrontTransitionCompletedBase

Types now override isFrontTransitionCompleted() directly, mirroring the
back transition: a non-virtual speed/time helper plus one virtual
completion check. The on-ground bypass is spelled out where needed.

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

* refactor(vtol_att_control): test the fixed-wing request positively in the state machine

Slightly more readable than the other version IMO

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

---------

Signed-off-by: Balduin <balduin@auterion.com>
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
Co-authored-by: Balduin <balduin@auterion.com>
2026-11-23 08:42:31 +01:00
Nuno Marques 288b114841 feat(uxrce_dds_client): bridge out-of-tree uORB messages over uXRCE-DDS (#29782)
* feat(uxrce_dds_client): bridge the topics of out-of-tree messages

Out-of-tree uORB messages build into PX4 like any other, but the
bridge reads only dds_topics.yaml, so bridging one means editing that
file and carrying the change through every PX4 update.

When $EXTERNAL_MODULES_LOCATION/msg/dds_topics.yaml exists, the build
passes it to the generator after dds_topics.yaml, and the generator
appends each file's lists to those before it. A topic declared twice
in the same list stops the build, since it would be bridged twice.
A single file, as Zenoh's build passes, yields its lists unchanged.

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

* test(uxrce_dds_client): test the topic generator in the Python checks

The generator runs only inside a firmware build, so a change that
breaks joining topic files, or the check for repeated topics, would
first show up as a broken build. The tests run it on its own: a second
file appends its topics to each list, lists split across files give
the same header as one file, files without topics add nothing, and a
repeated topic stops it. The Python checks job installs empy for the
generator, in the range PX4's requirements.txt gives.

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

* feat(scripts): copy out-of-tree messages into px4_msgs

ROS 2 needs every bridged message in px4_msgs, and copy_to_ros_ws.sh
copies only PX4's own. An optional second argument, the external
modules location, adds the messages of its msg directory, if it has
any. A message with the name of a PX4 message would replace PX4's
definition in px4_msgs, so the script refuses it before copying
anything.

A test in the Python checks runs the script on throwaway workspaces:
PX4's messages alone, a location's messages added, a location without
messages, and the refusals of a PX4 message name and of a location
without a msg directory.

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

* docs(uxrce_dds): document bridging out-of-tree messages

The uXRCE-DDS page covers dds_topics.yaml but not the topics of
out-of-tree messages. Describe their topics file and the copy into
px4_msgs there, and point to it from the External Modules page.

Assisted-by: Claude-Code:claude-opus-5-5
2026-11-22 09:04:15 +00:00
Leonardo Cencetti cd68f944d4 fix(zenoh): honor stop requests while the session is retried (#29925)
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>
2026-11-21 16:05:56 +00:00
Leonardo Cencetti 98e747fa3d fix(zenoh): fail the topic setup when a declaration fails (#29924)
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>
2026-11-21 15:44:20 +00:00
Mathéo Taillandier 2a3719006f feat(commander): when disarmed, do not report ESC offline on battery blocking preflight checks (#29523)
* 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>
2026-11-20 11:28:25 -07:00
Marco HauswirthandMathieu Bresciani 1687722479 fix(ekf2): reset the height on a baro calibration change without a restart (#29922)
* fix(ekf2): reset the height on a baro calibration change without a fusion restart

* Update src/modules/ekf2/EKF/aid_sources/barometer/baro_height_control.cpp

Co-authored-by: Mathieu Bresciani <brescianimathieu@gmail.com>

---------

Co-authored-by: Mathieu Bresciani <brescianimathieu@gmail.com>
2026-11-20 16:56:05 +01:00
Vishal KotakandVishal Kotak 16b1d820c8 test(rover): add unit tests for the rover control helpers (#29836)
* test(rover): add unit tests for the rover control helpers

throttleControl, attitudeControl, speedControl, rateControl and globalToLocalSetpointTriplet drive all three rover modules but had no tests. rateControl was also the only helper without an input check, so a NaN yaw rate reached the PID; it now returns NaN like the others.

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

* test(rover): split rover control tests into single given/when/then cases

Review feedback: tests that set up a scenario should read as
given/when/then, and tests covering several cases should be split so
each failure points at one case.

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

* test(rover): check that NaN inputs leave the controller state untouched

Most NaN cases propagate to a NaN output even without the input check,
so asserting only on the output didn't test the check. Starting from a
known adjusted setpoint and asserting it is unchanged does. Also name
the rateControl clamp tests by sign, since in NED a positive yaw rate
turns right, and use speed_diff_normalized like the callers do.

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

* style(rover): re-indent rateControl test continuation lines for astyle

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

* test(rover): apply given/when/then to the existing rover control tests

Review feedback: use the same scheme for the tests that were already in
the file, so every test checks one case.

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

---------

Co-authored-by: Vishal Kotak <22182951+vishalkotak@users.noreply.github.com>
2026-11-20 11:02:12 +01:00
Balduin e01c2dd44e fix(mavlink): store params read from the receiver thread atomically (#29908)
* 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
2026-11-20 08:44:15 +01:00
Julian Oes 73939d4c36 fix(rc): keep decoder state out of the shared RC buffer (#29847)
All RC decoders share rc_decode_buf. SUMD read its channel count back
from it while receiving a frame, so another decoder writing to the
buffer could move its write index past the end. px4io feeds the same
bytes to DSM, ST24 and SUMD until one locks, and rc_input's protocol
scan resumes decoders after the others have used the buffer.

Keep the SUMD channel count private, and reset ST24 and SUMD when the
rc_input scan switches protocol.

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

Signed-off-by: Julian Oes <julian@oes.ch>
2026-11-19 17:17:19 -07:00
Jacob Dahl 309b338b0b feat(boards/ark/fpv): analog OSD on the external SPI port (#29916)
* fix(atxxxx): fail the probe when the chip doesn't answer

probe() logged a VM0 mismatch but returned the SPI transfer status, so with nothing on the bus the driver started anyway.

* feat(boards/ark/fpv): analog OSD on the external SPI port

OSD_ATXXXX_CFG 1 or 2 starts atxxxx on SPI6 for a MAX7456-compatible OSD such as the ARK OSD. It stays off by default, since many use that port for an external IMU.

* docs(ark_fpv): set up an analog OSD on the SPI or TELEM port

The board can carry an analog OSD on either port, and neither is on by default.
2026-11-19 17:16:47 -07:00
Julian Oes 7b40898cff perf(rc): use lroundf for the S.Bus scaling
The S.Bus scale constants are float, so lround promoted the argument to
double and pulled soft-double code into FPU-less targets like the IO.
lroundf rounds the same float value identically (checked exhaustively over
all encode and decode inputs) and saves 1104 B on the IO.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
2026-11-20 12:08:09 +13:00
Julian Oes a88edf1abe ci(px4io): keep one IO firmware binary per IO board and check it in CI
The px4io firmware was committed as a copy in the extras of each of the 30
boards using it. "make px4io_update" only knew about 15 of them, so the
copies drifted into 5 different versions, and none had been regenerated
since 2024-03 despite changes to px4iofirmware, lib/rc and NuttX.

Keep a single binary per IO board in boards/<vendor>/<io board>/extras and
let the ROMFS pick it via the existing CONFIG_BOARD_IO option, which every
board with the px4io driver already sets (cubepilot boards override it).
This also replaces the outdated per-board copies on boards that were
missed by "make px4io_update".

The IO build is reproducible with a fixed toolchain (verified across
checkout paths and container vs host with the same GCC), so CI can rebuild
it and compare. "make check_px4io" does that, and a new CI job turns a
mismatch into a warning.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
2026-11-20 12:08:09 +13:00
Anil Kircaliali f8e80858ad fix(commander): compare a GNSS home against GNSS while the global pos is invalid (#29911)
* 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
2026-11-19 13:32:12 -07:00
Anil Kircaliali cb02f47b18 fix(logger): don't lower the vehicle_thrust_setpoint rate in the high rate sensors profile (#29912) 2026-11-19 12:18:33 -07:00
Jacob DahlandAndrea Bernasconi d04e5623f6 feat(gnss): compare receivers in sensors, limit divergence in commander (#29604)
* 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>
2026-11-19 11:28:20 -07:00
Marco Hauswirth 829f0f412e feat(sensors): keep calibrating the baro on the GNSS altitude until arming (#29876) 2026-11-19 17:10:35 +01:00
Daniel Buleandră f65fe36aea feat(mavlink): count received messages dropped for a bad CRC (#29766)
Assisted-by: Claude:claude-opus-5-5

Signed-off-by: danielbuleandra <daniel.buleandra@auterion.com>
2026-11-19 12:59:35 +01:00
Mathéo Taillandier e1e1122af5 feat(simulation): enable airspeed sensor failure injection on gazebo too (#29210)
* feat(simulation): enable failure injection on gazebo sensor too

* docs(failure_injection): remove added dot
2026-11-19 12:58:23 +01:00
Jonas Perolini 5729cf1e3d fix(geofence): keep the Return margin along approximated circle edges (#29884)
Return approximates an exclusion circle by an octagon. The octagon was
drawn around the circle and the margin then added to its vertices, so
its edges cleared the circle by only cos(pi/8), about 92 %, of the
margin. Return flies along those edges.

Grow the circle by the margin first and draw the octagon around that,
as the comment above the code already says.

Assisted-by: Claude:claude-fable-5-2
2026-11-19 11:39:57 +01:00
Matthew Charles Vladislav Busel 5c1a57d6d5 feat(simulation): add a differential rover to SIH (#29852)
* 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
2026-11-19 09:22:21 +01:00
Hamish Willee 07af901e7c chore(mavlink): update submodule to latest (#29893)
Assisted-by: Claude:claude-opus-5-5

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
2026-11-19 14:27:01 +11:00
Jacob Dahl 0d9ef5f510 fix(atxxxx): draw at the right address and inside the NTSC screen (#29890)
* fix(atxxxx): write the display memory address low byte unchanged

Above address 255 the low byte was computed as the truncated address minus 0xFF, one more than the address itself. Every character from row 8, column 16 on landed one column right, the last PAL cell was written past the 480-entry display memory, and address 256 was never cleared.

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

* fix(atxxxx): keep the flight mode and flight time on the NTSC screen

NTSC shows 13 rows, so the flight time on row 14 was never visible once NTSC could be selected. Both elements are now placed from the bottom row, which leaves the PAL layout unchanged. The row count now follows the same OSD_ATXXXX_CFG check as the PAL bit, so boards that start the driver with the parameter at 0 get the NTSC layout they now run in.

Assisted-by: Claude:claude-opus-5-5
2026-11-18 17:11:01 -07:00
abhijith 5d9263851e feat(mavlink): let boards set the number of MAVLink instances (#29573)
* 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>
2026-11-19 12:58:56 +13:00
Julian Oes 35223a381e fix(drivers): keep file descriptors on the task that opened them (#29858)
* fix(heater): open and use the PX4IO fd only on the work queue thread

File descriptors on NuttX are per task group. Since the multi-instance
rework (#26325) the PX4IO heater fd was opened in the constructor, i.e.
in the shell task running `heater start`, but used in Run() on
wq:lp_default. There the fd number refers to whatever that task group has
open, so the heater ioctls silently failed (heater never driven on
PX4IO boards) or hit an unrelated file. On a Cube Orange+ this ended in a
hardfault in fat_ioctl() when the number matched an SD card file.

stop() also issued an ioctl from the shell, and the exit path closed the
fd before turning the heater off with it.

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

* fix(cyphal): close the CAN fd on the work queue thread

The CAN socket/device is opened in Run() on wq:uavcan, but was only
closed from the destructor, which runs in the shell calling
`cyphal stop`. File descriptors are per task group on NuttX, so that
close did nothing and the SocketCAN socket stayed bound, keeping
received frames queued in the shared IOB pool. The NuttX CAN device was
never closed at all.

Close the interface in Run()'s exit branch and make close() idempotent.

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

* fix(uavcannode): close the DroneCAN shell pipes on the work queue thread

The shell pipes are created from a service callback on wq:uavcan, but on
`uavcannode stop` they were closed by the destructor in the shell task.
File descriptors are per task group on NuttX, so the work queue ends
stayed open and the spawned shell task never got EOF.

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

* fix(distance_sensor): close serial ports on the work queue thread

CM8JL65, uLanding, LeddarOne, Sony AS-DT1 and Lightware serial open
their UART in Run() on the work queue, but stop() closed it from the
shell calling `<driver> stop`. File descriptors are per task group on
NuttX, so the UART stayed open in the work queue group, leaking it on
every start/stop cycle. stop() also deleted the driver without waiting
for a Run() in progress.

stop() now asks Run() to close the port and waits for it. Error paths
reset the fd so a stale number is not reused, and ports opened in the
shell (LeddarOne init probe, Sony -p mode) are closed there.

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

* fix(uwb_sr150): schedule only after init succeeded

On init failure the instance is deleted in the shell, whose destructor
closes the UART. If Run() had already opened it on the work queue, that
closed an unrelated fd number, as file descriptors are per task group
on NuttX.

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

* fix(sagetech_mxs): schedule only after init succeeded

On init failure the instance is deleted in the shell, whose destructor
closes the serial port. If Run() had already opened it on the work
queue, that closed an unrelated fd number, as file descriptors are per
task group on NuttX.

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

---------

Signed-off-by: Julian Oes <julian@oes.ch>
2026-11-19 12:48:08 +13:00
Jacob Dahl 4395d0bc23 fix(atxxxx): enable the display without forcing PAL (#29889)
enable_screen() ORed 0x48 into VM0, which set the PAL bit whatever OSD_ATXXXX_CFG said, so NTSC was never selected. init_osd() already sets the PAL bit when the parameter asks for it.
2026-11-18 16:47:11 -07:00
Hamish WilleeandRamon Roche bce8453e5b chore(mavlink): update submodule to latest (#29865)
Assisted-by: Claude:claude-opus-5-5

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Co-authored-by: Ramon Roche <mrpollo@gmail.com>
2026-11-19 08:13:49 +11:00
Julian Oes 0c74033da4 fix(hardfault_stream): return after cleanup in the stop path (#29859)
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>
2026-11-18 11:49:37 -07:00