The cap (#29009) kept the pitch from diving to accelerate above trim
airspeed when the throttle could not deliver. With the pitch conversion
fixed, pitch and throttle are consistent: an airspeed step decays with
FW_T_TAS_TC and the altitude holds whenever the throttle delivers, above
trim as well, so the cap only matters once the throttle saturates. It
then overrides the speed weight, which is the parameter meant to split
such a shortfall between height and airspeed.
The cap also made the pitch see a different kinetic setpoint than the
throttle, switching with the sign of the airspeed error when cruising
above trim. That asymmetry needed its own fix for the kinetic estimate
and leaks airspeed noise into the loops once the throttle no longer
provides all of an airspeed correction.
Remove the cap, the kinetic estimate removal between trim and the
setpoint, the tas_trim parameter and their tests and docs.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
The speed weight tests only checked the airspeed response against its
time constant; their altitude steps only checked that the altitude
converges, not that the error decays at FW_T_ALT_TC. Disturb altitude,
airspeed and both in steady cruise and require each error to decay with its
own time constant for every speed weight, now including 0.
Also check that a total energy rate shortfall the throttle does not remove
is split between altitude and airspeed as the speed weight says, using a
plant energy rate offset unknown to TECS.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
At speed weight 2 the pitch flies airspeed only and its climb angle follows
from the total energy rate. With the setpoint's rate it pitched towards the
altitude demand, which a glider has no throttle to deliver, so it held the
airspeed only once the integrator had given the demand up. With no throttle
range (FW_THR_MAX = FW_THR_MIN, also a gliding waypoint) the pitch now takes
the minimum total energy rate, the glide, as fast descend and underspeed
already do.
Limited to speed weight 2: below it the throttle range also closes at the
end of the landing flare, where the pitch keeps flying the height rate
setpoint.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
Parameterized test names contain '/', so TECS_TEST_LOG_DIR pointed fopen
at a missing subdirectory and the TECSControlClosedLoopWeightTest cases
wrote nothing. Flatten the name, create the log directory if needed and
report a file that cannot be opened.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
With the pitch and throttle consistent, the speed weight only sets which
error the pitch feedback weights: an airspeed error decays with
FW_T_TAS_TC and an altitude error with FW_T_ALT_TC, without coupling,
for any speed weight and any combination of the two time constants. The
existing steps only covered the default time constants.
Check airspeed steps against a first-order response with the altitude
held, and altitude steps with the airspeed held, for speed weights 0.5,
1 and 1.8 with airspeed time constants below, equal to and above the
altitude one.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
The step down test required the airspeed error to drop by 70% within one
FW_T_TAS_TC, while a first-order response only reaches 63% (1 - 1/e), and
its later bounds were far looser than the actual response. Its comment
also assumed pitch and throttle interact, but with the speed weighted
SEB rate -> pitch conversion the pitch and throttle decouple airspeed
from altitude.
Check the error against step * exp(-t / FW_T_TAS_TC) and the altitude
against numerical precision, like the step up test.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
Fast descend and underspeed raise the speed weight towards 2, where the
climb angle (SEB rate + 2 STE rate) / (2 g V) follows from the total
energy rate alone. The pitch took it from the setpoint, which carries
the altitude demand, while fast descend holds the throttle at its
minimum. In underspeed the throttle is ramped to its maximum, but the
pitch must not rely on it either: the engine may have failed, the
throttle is still slewing up, and near stall the excess power is below
the one FW_T_CLMB_MAX states at trim.
Assume the minimum total energy rate, gliding, in both. If the throttle
does deliver in underspeed, the airspeed recovers faster.
Fixes FastDescend.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
The pitch balances the weighted energy rate
SEB rate = (2 - w) SPE rate - w SKE rate, and with the throttle flying
the total energy rate this is 2 g V gamma - w STE rate. The climb angle
is therefore gamma = (SEB rate + w STE rate) / (2 g V); the conversion
added the total energy rate with a factor of 1, which is only right at
speed weight 1. At other weights the feedforward climb angle was
(3 - w) / 2 times the demanded one and airspeed steps moved the pitch by
(1 - w) / 2 times the airspeed rate over g: 1.5 times the climb angle
without airspeed (w = 0), 0.6 times at w = 1.8.
Take the total energy rate from the pitch's own energy rate pair rather
than the throttle's setpoint. Between trim and the airspeed setpoint the
pitch's airspeed setpoint is capped, and the throttle's acceleration
demand there would otherwise pitch the vehicle up.
The pitch now flies the demanded climb angle at every speed weight, and
the weight only sets how its feedback weights altitude against airspeed
errors. Add the closed-loop tests this fixes:
AltitudeStepUpLowSpeedWeight, AltitudeStepDownLowSpeedWeight,
AirspeedlessAltitudeStepUp and AirspeedlessAltitudeStepDown.
At speed weight 2 the climb angle depends entirely on the total energy
rate the throttle delivers, so with a failed throttle the pitch flies
the altitude demand. Disable GlideSpeedWeightTwoAirspeedStep, which
glides with a failed throttle at speed weight 2, until the pitch assumes
gliding there.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
AlphaFilter keeps a non-finite sample in its state for good. A single
non-finite setpoint or measurement, e.g. the non-finite setpoint when
exiting offboard velocity mode (#25906), therefore left the throttle
non-finite until TECS was reinitialised. Since the throttle low-passes
its energy rate error instead of the estimate, this also happens for a
non-finite setpoint.
Only take finite samples into the energy rate error filter and hold its
state otherwise, seed it with a finite value on initialisation, and hold
the last throttle on a non-finite throttle demand.
The existing tests only checked that the pitch stays finite, which its
fallback guarantees. The new test checks that pitch and throttle return
to those of a controller that never saw the bad frame.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
The pitch converts its balance rate setpoint together with the total
energy rate to the potential energy rate it flies,
(SEB rate + STE rate) / (2 g V). Only the full feedforward gives that
potential energy rate; any other gain mixes in a share of the total
energy rate. Feed the setpoint forward in full and remove the parameter.
No airframe sets it.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
The pitch loop now converts its balance rate error to a climb angle with
1 / (2 g V) instead of 1 / (g V) (see "fix(tecs): correct SEB rate ->
pitch conversion"), so FW_T_PTCH_DAMP and FW_T_I_GAIN_PIT act at half
their previous strength. Double their defaults (0.1 -> 0.2) and the
values of the X-Plane airframes that set them, so the effective pitch
loop gains stay as tuned.
Custom values of FW_T_PTCH_DAMP and FW_T_I_GAIN_PIT need doubling too.
They are not translated on import: a saved parameter file does not say
which firmware wrote it, so scaling on import would compound on every
boot.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: RomanBapst <bapstroman@gmail.com>
The pitch loop divided its energy balance rate correction by g V to get
a climb angle. But the climb angle sets the potential energy rate and
the throttle the total, so the balance rate is
SEB rate = 2 g V gamma - STE rate
and the climb angle that realises a balance rate is
gamma = (SEB rate + STE rate) / (2 g V). Mapping the balance rate alone
flew it as a potential energy rate instead: at speed weight 1 an
airspeed demand was flown by the throttle and once more by the pitch as
a dive, halving the effective airspeed time constant and moving the
altitude on every airspeed step.
Replace _climbAngleToSebRate with _sebRateToClimbAngle, which takes the
total energy rate setpoint, and use it for the pitch output and, with a
zero total energy rate, for the integrator input, which is a balance
rate increment at unchanged throttle.
Behaviour change at default tuning: the airspeed response slows to the
FW_T_TAS_TC the parameter states, airspeed steps no longer move the
altitude, and the damping and integrator terms act at half their
previous strength.
Assisted-by: Claude:claude-fable-5-1
* 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>
* 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>
* 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>
* 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>
* 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>
* 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
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>
The v1.18 notes opened with a single line pointing at v1.17. The new
introduction describes what the release changes for operators and
integrators, and the new section explains how to fly, simulate, build
and integrate with v1.18, including the published containers, which the
notes never mentioned.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
A host tool can then reach a device on a TELEM or GPS port through the FPV's USB, such as an ARK OSD on TELEM1 taking a firmware update, without unplugging it.
* 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>
* 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>
* 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
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>
* 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.
Built with "make px4io_update" from a clean tree in
ghcr.io/px4/px4-dev:v1.17.0-rc2.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
With NuttX 12.12 the IO firmware has only 424 B of free heap left out of
the F100's 8 KB, down from about 1.8 KB with the same sources on the
previous NuttX.
Each task group now embeds its three std streams with a 64 B buffer each,
once statically for the kernel thread group and once on the heap for the
IO task. Nothing on the IO uses stdio streams (syslog is disabled), so
drop the buffers. The IO also never uses signals, so don't preallocate
signal actions.
This frees 528 B of static RAM plus 192 B of heap: free_memory_bytes in
"px4io status" goes from 424 to 1144 on a Cube Orange+.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
Picks up the shared CRC-8 table and px4io_protocol library from main.
43708 B to 43700 B (cubepilot: 43488 B to 43480 B). Built with
"make px4io_update" in ghcr.io/px4/px4-dev:v1.17.0-rc2.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
Picks up the libc float and lroundf savings: 48692 B to 43708 B
(cubepilot: 48468 B to 43488 B). Built with "make px4io_update" in
ghcr.io/px4/px4-dev:v1.17.0-rc2.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
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>
The NuttX 12.12 upgrade enabled CONFIG_LIBC_FLOATINGPOINT on the IO
boards, where it is off by default (no FPU, DEFAULT_SMALL). Nothing on the
IO formats floats, and dropping it saves 3880 B of IO flash, which also
ends up in the ROMFS of every FMU that carries the IO firmware.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
A board that still carries its own px4io binary in extras/ collided with
the one added via CONFIG_BOARD_IO and failed CMake generate with a
duplicate custom rule error. Several open board PRs add one, so fail
configure with a message naming the file to delete instead.
check_px4io copied the build output over the committed binaries, which
leaves changed binaries behind when run with a different toolchain. Compare
with cmp instead. The CI job now only runs check_px4io, which already
builds both IO boards, instead of building them twice.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
First regeneration since 2024-03. Picks up the lib/rc fixes (ST24 bounds,
S.Bus clamping, GHST/CRSF changes), the NuttX 12.12 upgrade and the
px4iofirmware changes since then. Built with "make px4io_update" in
ghcr.io/px4/px4-dev:v1.17.0-rc2.
The binary grows from 40160 to 48692 bytes (cubepilot: 39940 to 48468),
still within the IO flash.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
A passing job with a warning annotation is easy to miss, which defeats the
purpose of the check. Fail the job so stale IO firmware gets regenerated in
the PR that changes its dependencies.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
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>
* 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>
Returning from a QuRT task bypasses px4_task_exit(), while normal module
shutdown does not call px4_task_join(). Repeated starts and stops therefore
leak task descriptors and eventually exhaust the 24-slot task table.
Route task returns through px4_task_exit() and reap exiting threads before
spawning another task. Keep each slot reserved until pthread_join()
completes, serialize competing joiners without holding the task mutex
across the join, and reject cancellation of tasks waiting on these joins.
Use monotonically increasing task handles so a late join, delete, or signal
cannot act on a replacement task after its table slot has been reused.
Ported from modalai/px4-firmware commit
1fe92691127df29e72af05f99d462c62428d3994 without code changes.
Assisted-by: Codex
Signed-off-by: Eric Katzfey <eric.katzfey@modalai.com>
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