Commit Graph
363 Commits
Author SHA1 Message Date
Hamish WilleeandJulian Oes 4d755a614f fix(mavlink): Make MAV_CMD_SET_ACTUATOR scale properly in missions (#27336)
* fix(mavlink): scale DO_SET_ACTUATOR params 5/6 in mission items

MISSION_ITEM_INT carries params 5/6 in the int32 x/y fields, so the actuator
5 and 6 values (-1..1) only arrived as -1, 0 or 1, and an unset (INT32_MAX)
value drove the actuator to saturation instead of leaving it unchanged.

Scale them by 1e7 like COMMAND_INT does, map unset to NaN, and encode them
the same way on download.

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Signed-off-by: Julian Oes <julian@oes.ch>
Assisted-by: Claude:claude-opus-5-5

* docs(navigator): list all supported mission commands

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>

* fix(mavlink): keep ARM_DISARM and AUTOTUNE params on global-frame download

A global-frame mission item zeroes param1-4 before filling in the
command-specific ones, and COMPONENT_ARM_DISARM and DO_AUTOTUNE_ENABLE
had no case there. An uploaded "arm" (param1 = 1) therefore downloaded
as "disarm" (param1 = 0).

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

* fix(mavlink): ignore unset COMMAND_INT x and y individually

COMMAND_INT x/y were only treated as unset when both were INT32_MAX. A
DO_SET_ACTUATOR setting only actuator 5 (y = INT32_MAX) therefore set
actuator 6 to 214.7, saturating it, instead of leaving it unchanged.

Map each of x and y to NaN on its own when unset, which also covers
INT32_MIN from a NaN converted to int.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Julian Oes <julian@oes.ch>
Co-authored-by: Julian Oes <julian@oes.ch>
2026-11-17 10:45:39 +13:00
Andrea BernasconiandHamish Willee db94ca49db feat(failure_injection): add wrong, garbage and drift IMU failures (#29601)
* feat(failure_injection): add wrong, garbage and drift injection for gyro and accel

Corrupt the addressed IMU's samples on all three axes: wrong adds a
constant bias (SYS_FAIL_{G,A}_BIAS), garbage uniform noise within
+-SYS_FAIL_{G,A}_NOISE and drift a bias growing by SYS_FAIL_{G,A}_DRIFT
per second since injection. Applied to both the plain and FIFO driver paths.

* refactor(failure_injection): handle IMU failures in process_imu()

Mirror process_gnss(): resolve the mode once, run the generic Off / Stuck
first and only then apply the Wrong / Garbage / Drift offset, so the Stuck
cache keeps the uncorrupted sample and a later Stuck never replays a
drifted one. Drop the second process() on the integrated FIFO report, which
cached the already-corrupted report. The offset is still computed before
Off so drift_start is reset while the sensor is off.

* docs(failure_injection): align IMU failure docs with code

The Syntax section did not list drift and described garbage as
uninitialised-memory output, while gyro/accel garbage adds bounded noise
to the real measurement. Also match the new parameter descriptions to
the wording of the existing SYS_FAIL_* parameters.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Hamish Willee <hamishwillee@gmail.com>

* fix(failure_injection): add drift RC mode and clarify bias param text

* refactor(drivers): Drop extra comment

* test(mavsdk_tests): add SITL test for IMU failure injection

Fly the SIH quad through gyro and accel bias, noise and drift with the
default SYS_FAIL_{G,A}_* magnitudes and check it holds altitude.

Holding altitude alone also passes when the injection never reaches the
sensor data, so the test also checks that the IMU noise level jumps
while noise is injected and returns once cleared. Bias and drift are
not checked in the data: the rate controller and the estimator react
to them and partly hide them in flight.

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

* test(mavsdk_tests): inject IMU failures through MAVSDK 4.2.0

MAVSDK-Python 4.2.0 adds FailureType.DRIFT (mavlink/MAVSDK#3211), so the
IMU failure test no longer needs to send a raw MAV_CMD_INJECT_FAILURE
with its own copies of the unit and type values. Use the tester's
inject_failure() like the motor failure tests, and bump the mavsdk pin
so the new type is available.

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

---------

Signed-off-by: Hamish Willee <hamishwillee@gmail.com>
Signed-off-by: Andrea Bernasconi <andrea.bernasconi@auterion.com>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
2026-11-13 11:24:05 +01:00
Jacob Dahl e192036345 fix(commander): ack calibration cancels once and stop promptly (#29514)
* feat(simulator_sih): add orient command to pose the vehicle for calibration

Accel and mag calibration need the vehicle held still on each side and
rotated, which SIH could not do, so neither could be tested in
simulation. `simulator_sih orient` sets the attitude kinematically,
keeping the IMU and the simulated mag consistent with it, and `orient
all` runs every side in turn so a calibration started from a GCS
completes on its own.

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

* fix(commander): hand a calibration cancel to the running calibration

A cancel got TEMPORARILY_REJECTED from Commander and ACCEPTED from the
calibration, in either order. The calibration polled for it with a
fresh vehicle_command subscription that only saw the newest command,
filtered it by a per-side start time, and did not poll while waiting
for the vehicle to be still or while measuring a side. Baro and level
calibration never polled. A cancel could be lost or take until the
vehicle was held still.

Commander now hands the cancel to the running calibration, which acks
it once when it stops, or rejects it if it ends without stopping.
Every calibration loop checks for it, and accel calibration no longer
reports a failure after a cancel.

Fixes #29424

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

* test(mavsdk_tests): run accel and mag calibration and cancels on SIH

Covers a full accel and mag calibration, and a cancel in each place it
used to be missed or delayed, checking it gets exactly one ack.

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

* perf(simulator_sih): build the orient command for SITL only

Commander denies sensor calibration when SIH runs on flight controller
hardware, so orient was about 1.8 KB of unusable code on every NuttX
board that builds SIH.

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

* fix(commander): open calibration cancels before the worker thread starts

Commander handles one command per loop and the worker thread runs at
low priority, so a cancel queued right behind the start could be
rejected before the worker opened it, and the calibration kept running.

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

* fix(commander): stop reporting a cancelled gyro calibration as failed

A cancel broke out of the retry loop into the failure report, as accel
calibration did before.

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

* test(mavsdk_tests): cover gyro cancel and remove two calibration races

A retried start is rejected once the calibration runs, and that late
ack could be counted against the cancel, so the start is sent once.
The baro cancel landed 1 s into a 3 s calibration, about 200 ms of
host time at speed factor 10; it is now sent right after the start.

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

* style(mavsdk_tests): wrap the calibration start assert for flake8

The 104-character line failed the Python CI checks.

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

* fix(commander): require param7 zero for a calibration cancel

An ESC calibration (param7 = 1) or baro temperature calibration
(param7 = 3) sent while a calibration ran matched the cancel test. It
stopped the running calibration and was acked ACCEPTED, though the
requested calibration never started. `commander calibrate esc` did the
same.

Assisted-by: Claude:claude-fable-5-2
2026-11-11 14:38:01 -07:00
440179383a feat(SIH): Added optical flow sensor continues on #28270 (#29676)
* feat(sih): model the distance sensor range limits, quality and noise

The simulated distance sensor reported a noise free reading with no signal
quality, and saturated only against the upper range limit. Readings below the
minimum range were passed through unchanged, which is not what a range finder
does.

Report the raw saturated value with a zero quality outside of the measurement
range, derate the quality over the last 20% of the range, and add configurable
Gaussian noise (SIH_DISTSNSR_NOI). The quality is decided on the true distance
so that a measurement sitting at a range limit does not flicker in and out of
validity.

The sensor is now enabled with SIH_DISTSNSR_EN instead of by an out of band
value of the override parameter, and the ground distance computation moves into
a helper.

* feat(sih): add optical flow simulation

Simulate a downward facing optical flow sensor in SIH so that flow aided
navigation can be exercised without a rendered camera image. The flow rate is
the sum of the body rates and of the ground relative velocity scaled by the
distance to the ground, integrated over one publication interval and published
on sensor_optical_flow with configurable rate (SIH_OF_RATE) and noise
(SIH_OF_NOISE).

The sensor reports the integrated flow only: the flow module completes the
sample with the vehicle gyro and the downward facing distance sensor, which
therefore has to be enabled as well. Quality drops to zero above
SIH_OF_H_MAX or when the flow rate exceeds what the sensor can correlate.

The topic is advertised before the simulated clock starts, because the sensors
module brings up its flow pipeline on the first appearance of the topic, and
publishing during startup deadlocks the lockstep clock this thread advances.

Add the quadx_flow and standard_vtol_flow models with matching airframes:
SYS_AUTOSTART 10046 flies the multicopter on flow only with no GNSS, 10047
fuses the flow next to GNSS on a VTOL.

* prune configs

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* more config cleanup

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* added EKF2_HGT_REF to vtol flow config

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* feat(simulation): added tests for optical flow for both quadx and stanard vtol
modes and enable them in CI

- for the test we monitor error on ground truth position and velocity

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* feat(docs): document addition of optical flow in SIH

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* fix(mavsdk_tests): unsubscribe flow ground truth comparison on destruction

The ground truth comparison callbacks capture `this` and touch members of
AutopilotTesterFlow. If a REQUIRE fails between start and stop, the tester
is destroyed during unwinding while the subscriptions are still active,
so a callback could run on the destroyed mutex and sample buffers.

Make stop idempotent and call it from the destructor, and stop any running
comparison before starting a new one.

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

* tests for python

* fix(mavsdk_tests): start the VTOL flow loiter already on its radius

The loiter was centered on the vehicle's position right after the
transition, so it started at the center and had to fly straight out to the commanded
radius before the lateral guidance curved onto the track.

Assisted-by: Claude:claude-sonnet-5

* fix(mavsdk_tests): resend the flow test EKF origin until it is taken

The SITL startup script starts ekf2 after MAVLink. When MAVSDK connected
first, the single SET_GPS_GLOBAL_ORIGIN was published before ekf2 existed
and MAVSDK's RUN_PREARM_CHECKS followed it. Ekf2 then subscribed, saw
only the newest vehicle command and never got an origin. The Coverage
build starts slowly enough to hit this every time.

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

* ci(sitl_tests): run the VTOL flow test without coverage

As a Coverage job it built with coverage on every PR and uploaded the
sitl-vtol flag from PRs, which replaced main's carried-forward VTOL
coverage with the flow-only flight. The quadx_flow entry also sat
between the Coverage comment and the standard_vtol entry it describes.

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

* fix(mavsdk_tests): sum the flow test heading sweep with its sign

Adding up the absolute heading changes counted yaw oscillation toward the
360 degrees, so the wait could end before a full orbit was flown.

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

* refactor(airframes): keep only the non-default params in the SIH flow airframes

SIH_OF_H_MAX, SIH_DISTSNSR_EN and EKF2_OF_CTRL were set to their defaults
and SENS_EN_GPSSIM is already set by the quadx base airframe. The quadx
forced EKF2_RNG_CTRL to 2 while the VTOL used the conditional default for
no stated reason, so both now use the default.

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

* docs(sim_sih): mark the SIH flow airframes as new in PX4 v2.0

release/1.18 has branched, so these airframes first ship in v2.0, not
v1.17.

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

---------

Signed-off-by: RomanBapst <bapstroman@gmail.com>
Co-authored-by: RomanBapst <bapstroman@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-11-09 11:13:16 -07:00
Matthias Grob abda07efe4 fix(navigator): use yaw acceptance timeout by default
MIS_YAW_TMT defaults to 10s, counted from when the heading is commanded, so a multicopter with low yaw authority continues instead of getting stuck.
Forced heading in a mission still fails the mission.
VTOLs only wait for forced headings.
2026-11-05 16:54:27 +01:00
Beniamino Pozzan e64bad47d4 test(ros): run the ROS integration tests over Zenoh
The runner could only drive tests through uXRCE-DDS. Add --middleware
zenoh: it manages the rmw_zenohd router instead of the Agent and
selects Zenoh in both PX4 and the test binary through the environment.
The router is restarted between tests because every SITL instance
announces the same node GUID, so stale liveliness tokens would let the
next test see the FMU before it is up.

config-sih-zenoh.json limits the Zenoh run to the mode tests: Zenoh
does not synchronize timestamps with ROS yet, so EKF2 rejects the
position interface inputs.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Beniamino Pozzan <beniamino.pozzan@gmail.com>
2026-11-04 15:51:34 +00:00
Ban Siesta (Bot) 787e1d81ee test(mavsdk_tests): bump MAVSDK to 4.1.0 and drop the unsubscribe workaround (#29447)
MAVSDK-Python 4.1.0 keeps the callback trampoline alive until the C
unsubscribe has returned (mavlink/MAVSDK#3165), so the tester no longer
needs to hold retired subscription entries until it is closed. Call the
plugins' unsubscribe_*() directly again.
2026-10-28 02:47:08 +13:00
Julian Oes 1c7a07a411 test(mavsdk_tests): rewrite the integration tests in Python (#29332)
* build(mavsdk_tests): stop building the C++ integration tests

The integration tests are moving to the native MAVSDK Python package, so
the C++ test binary and its pinned libmavsdk-dev package are no longer
needed. The C++ sources stay in the tree as a reference until all tests
are ported.

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

* test(mavsdk_tests): run the integration tests with MAVSDK Python

The MAVSDK pip package is now a native binding of the C++ library, so
the tests can be written in Python without a C++ build or a matching
libmavsdk-dev package, and the version is pinned in requirements.txt.

The existing runner keeps starting PX4 for each case; only the test
executable changes to pytest. Cases are pytest node IDs and the Catch2
tags become pytest markers.

The tester is a port of the C++ AutopilotTester core. Checks done in
telemetry callbacks are collected and fail the test at teardown, since
MAVSDK Python swallows exceptions raised in callbacks.

The first ported test is takeoff and hold position.

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

* test(mavsdk_tests): port the multicopter tests to Python

Ports missions, offboard, manual flight, failsafes, failure injection,
RTL with rally points and geofence avoidance, home yaw and parameter FTP.
The tester gains the raw mission, manual control, failure, FTP and
MavlinkDirect helpers these need, plus an RTL subclass for rally points
and the geofence breach monitor.

The failsafe tests are parametrized over the height source instead of
being duplicated.

The parameter FTP download test now waits for the baro GNSS calibration
before comparing, since the offset it writes could otherwise change
between the PARAM_VALUE and the FTP download.

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

* test(mavsdk_tests): port the VTOL and control allocation tests to Python

Ports the VTOL missions, the VTOL return tests, figure eight, loiter
reposition, airspeed failure, the SIH XVert transition and the
gazebo-classic control allocation tests.

The loiter and figure-eight testers are merged into one loiter tester
that sends its commands as COMMAND_INT through MavlinkDirect. NaN fields
are sent as JSON null, since NaN is not valid JSON and MAVSDK reads null
as NaN.

Timeouts that were host time in C++ (approaches, figure eight) are now
sim time with values that fit the speed factors used in CI.

The gazebo runner can now take the world from the config, since pytest
node IDs no longer carry "(name.world)".

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

* test(mavsdk_tests): settle the hover before injecting motor failures

The altitude and speed waits both pass while the vehicle is still
slowing down at the top of the climb, so the altitude reference for the
failure was taken mid-climb. At 30x speed the following overshoot was
just over the 1 m tolerance.

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

* test(mavsdk_tests): port the follow-me tests to Python

The C++ follow-me tests were never built: they were disabled pending a
MAVSDK change that has long since been merged, and the RC adjustment
test did not even compile. They now run with the other multicopter
tests.

Running them for the first time showed a few test bugs: target
locations were sent before follow-me was active, manual control was
dropped after 20 s, and the angle check ignored the rate limit from
FLW_TGT_MAX_VEL. The RC checks now measure the change from right before
each stick input.

The follow distance adjusts at about 40% of the nominal speed, since
PX4 only grows the setpoint while the drone is within 1 m of it. The
test accepts that for now.

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

* test(mavsdk_tests): remove the C++ integration tests

All tests now run with MAVSDK Python, so the C++ tests, the tester
classes and the bundled Catch2 are no longer needed.

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

* build(setup): install the integration test requirements

The MAVSDK and pytest pins move to Tools/setup/test-requirements.txt,
which the setup scripts and the dev container now install, so the
integration tests work after the normal environment setup. The mavsdk
pin allows 4.0.x patch releases only.

The file lives in Tools/setup because that is the dev container's build
context. Container builds that stage only requirements.txt skip it.

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

* docs(test_and_ci): describe the Python MAVSDK integration tests

Covers the setup, running test cases by pytest ID, running a test
against a PX4 instance started by hand, and writing tests with the
testers and fixtures. Drops the Catch2 notes and the outdated list of
test cases.

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

* refactor(packaging): port the SIH container mission test to MAVSDK v4

Since v4, the mavsdk package is the native binding with a different API,
so the script failed to import with the version the setup scripts now
install. It now uses the synchronous API.

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

* test(mavsdk_tests): work around MAVSDK-Python unsubscribe crash

Up to MAVSDK-Python 4.0.6, unsubscribe_*() releases the callback
trampoline before the C unsubscribe returns, so a callback that is
running or waiting for the GIL can jump into freed memory. This crashed
the hex test in CI. Keep the subscription entries until the tester is
closed, until the pin includes the fix.

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

* test(mavsdk_tests): retry the param FTP comparison until values settle

Waiting for CAL_BARO0_OFF to change does not work everywhere: at the
CI home location the baro already matches GNSS and the calibration
writes an offset of 0. Instead, compare the PARAM_VALUE and FTP
downloads and retry a few times while parameters still settle.

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

* test(mavsdk_tests): port the vision target tests to Python

Port the precision landing tests from #29265: the pad is simulated with
TARGET_RELATIVE and TARGET_ABSOLUTE sent through MavlinkDirect, and the
estimate is checked from LANDING_TARGET.

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

* test(mavsdk_tests): fail when a filter or case selects nothing

A config filter that matched no test, for example because of a typo,
ran zero cases and passed. Also, --case used fnmatch, which reads the
brackets of parametrized test IDs as a character class, so such a test
could not be selected by its ID. Treat brackets literally and fail when
nothing is selected.

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

* test(mavsdk_tests): check the COMMAND_ACK of sent commands

Commands sent through MavlinkDirect were sent once and the ACK was
ignored, so a dropped or denied command only showed up later as an
unrelated timeout. Retry until acked like MAVSDK does, and check the
result.

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

* test(mavsdk_tests): check the condition once more on poll timeout

Also make the comment of check_rtl_approaches say that it can't fail.

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

* test(mavsdk_tests): disable baro auto-calibration in the param FTP test

Port #29359 to the Python test: the baro GNSS calibration can save a
new CAL_BARO0_OFF between the PARAM_VALUE and FTP downloads. Disable it
instead of retrying the comparison.

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

---------

Signed-off-by: Julian Oes <julian@oes.ch>
2026-10-26 08:50:51 -06:00
Julian Oes babc54c6b2 test(mavsdk_tests): disable baro auto-calibration in the param FTP test (#29359)
The test compares a PARAM_VALUE download against a packed FTP download
taken shortly after. With SENS_BAR_AUTOCAL enabled, the baro GNSS
calibration can save a new CAL_BARO0_OFF between the two, which makes the
comparison fail even though both downloads are correct.

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

Signed-off-by: Julian Oes <julian@oes.ch>
2026-10-20 16:31:03 -06:00
Jonas Peroliniandjonas 4380dabaae test(mavsdk): Add integration tests for the vision target estimator (#29265)
Co-authored-by: jonas <jonas.perolini@rigi.tech>
2026-10-20 00:13:22 +02:00
Benjamin Cabé b680955efd fix(mavsdk_tests): capture loiter monitor state by value (#29246)
The loiter tester's telemetry callbacks captured the caller's arguments
and locals by reference. With the pinned MAVSDK 3.17.2, a callback
already queued still runs after unsubscribe returns, so it can read the
stack of a function that has returned: the occasional "120 <= 0.0" and
"440 <= 150.0" failures of the VTOL loiter tests, always a single failed
assertion, are such late callbacks.

Capture the arguments by value, and share the promise and its flag with
the callback.

Assisted-by: Claude:claude-opus-5-5
2026-10-19 11:20:18 +13:00
Balduin 317a681cae fix(airspeed_selector): do not invalidate a sensor on the cycle it is detected (#29214)
* fix(airspeed_selector): do not invalidate a sensor on the cycle it is detected

A sensor that starts publishing after the selector's init (e.g. the SITL
airspeed sim, which waits for a global position) was flagged stale on the
first cycle after detection: its last-update timestamp was still zero, so
the 1 s missing-data timeout fired before a single sample was read. With
ASPD_FS_T_START at its default of -1 the validator never recovers, the
selected source stays DISABLED and preflight reports "Airspeed invalid".

Seed the timestamp when a new sensor index is detected so the timeout
counts from detection. Also silence the DISABLED-to-sensor transition
message, which otherwise reports a spurious "healthy, start using again".

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

* fix(airspeed_selector): only silence reporting when new sensor added

* fix(airspeed_selector): remove newly dead line

 - this time is always set check_for_connected_airspeed_sensors
 - there it depends on:
     - primary index set - otherwise nothing really happens
     - i >= _number_of_airspeed_sensors: always true on init

* test(mavsdk_tests): give the VTOL return with approaches 180 s to disarm

The flight from the end of the approach check to disarm takes about 155 s
of autopilot time, over the 150 s budget. The test only passed because
poll_condition_with_timeout checks elapsed time once per 15 s of autopilot
time and usually landed a check before the budget ran out; when the
lockstep sim ran slightly faster than the speed factor the disarm fell
inside a poll sleep and the test timed out at 158 s.

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

---------

Signed-off-by: Balduin <balduin@auterion.com>
2026-10-14 13:20:58 +02:00
Balduin 406d3139b2 fix(mavsdk_tests): remove colon from test names
When these tests fail, the "Upload failed logs" step then also fails
becaue:

    Error: The path for one of the files in artifact is not valid: [...] Contains the following character:  Colon :
    Invalid characters include:  Double quote ", Colon :, Less than <, Greater than >, Vertical bar |, Asterisk *, Question mark ?, Carriage return \r, Line feed \n

Here is an example of such a run (the original failure was just
flakiness and disappeared after rerunning...):
https://github.com/PX4/PX4-Autopilot/actions/runs/37432563224/job/112166606308
2026-10-06 01:35:29 -07:00
Julian Oes e6db1b3a14 fix(various): issues found running SITL tests with sanitizers (#28943)
* test(mavsdk): fail test cases on sanitizer reports

The runner only looked at the mavsdk_tests exit code, so ASan, TSan and
UBSan reports from px4 ended up in the logs without failing anything.
Scan the output of all processes for sanitizer report markers and fail
the test case if any appear, including leak reports printed at exit.

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

* fix(mavlink): allow more boot time when sim speed factor is set

In lockstep SITL the boot timeout is measured in sim time, but the
remainder of rcS after mavlink start runs in real time. At high speed
factors (e.g. 30x in mavsdk_tests) the 20 s sim-time timeout expires
before rcS reaches "mavlink boot_complete", triggering a spurious
error. Use 40 s when PX4_SIM_SPEED_FACTOR is set.

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

* fix(mavlink): don't share vehicle_status subscription across threads

send_autopilot_capabilities() (also called from the receiver thread on
REQUEST_MESSAGE) and the SETUP_SIGNING armed check (receiver thread)
used the same _vehicle_status_sub as handleStatus() on the main thread.
Besides being a data race flagged by TSan, advancing the subscription's
generation from another thread can make handleStatus() miss a
vehicle_status update. Use local subscriptions for those two callers.

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

* fix(gyro_fft): do initial sensor selection on the work queue

init() ran SensorSelectionUpdate() on the shell thread, which registers
the gyro callback before setting _selected_sensor_device_id, _gyro_fifo
and the gap perf counter. A gyro sample can then start Run() on the
work queue while those are still being written, which TSan flagged.
Schedule Run() instead and let it do the first selection.

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

* fix(logger): copy events into an aligned struct before access

The event was copied into _msg_buffer at an offset that isn't aligned
for event_s and then accessed through an event_s pointer, which is
undefined behaviour (flagged by UBSan) even for single-byte fields.
Copy into a local event_s, adjust it there and memcpy it into the
buffer. The bytes written to the log are unchanged.

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

* fix(manual_control): don't convert negative kill gesture time to unsigned

MAN_KILL_GEST_T is negative by default to disable the gesture, which
made the hysteresis time a negative float converted to hrt_abstime,
undefined behaviour flagged by UBSan. Clamp to 0; the gesture is only
evaluated when the parameter is positive.

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

* fix(mavlink): define mavlink_channel_t with all 6 channels

The library's mavlink_channel_t ends at MAVLINK_COMM_3, and channels 4
and 5 were created by casting out-of-range values to the enum, which
UBSan flags. Use the library's HAVE_MAVLINK_CHANNEL_T hook to define
the enum with all channels when MAVLINK_COMM_NUM_BUFFERS is 6.

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

* fix(mavlink): clamp DISTANCE_SENSOR fields to their integer ranges

A slightly negative range reading (seen with SIH near the ground) was
converted to the uint16_t distance field, which is undefined behaviour
flagged by UBSan. Clamp distances and covariance to their field ranges.

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

* fix(sensors): skip baro GNSS offset without baro samples

With no baro samples accumulated, the average pressure was 0/0 = NaN.
A NaN delta altitude poisons the offset low-pass filter, so the baro
GNSS autocal could silently never complete. Skip the run instead, and
leave the GNSS sample for the next one. Flagged by UBSan.

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

* fix(mavlink): don't divide by zero rate without variable rate streams

Without variable rate streams the bandwidth multiplier was a division by
zero, and the resulting inf was only clamped away later. There is
nothing to scale in that case, so use 1. Flagged by UBSan.

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

* fix(gyro_fft): skip peak interpolation for a zero or flat spectrum

Quinn's estimator divides by the peak bin magnitude and by 1 - ap and
1 - am, which are zero for a zero or flat spectrum (e.g. noise-free SIH
gyro data). Return NAN, the existing no-estimate value, instead.
Flagged by UBSan.

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

* fix(logger): don't compute write rate before time has passed

Right after a log file is opened the elapsed time is zero, so the write
rate was a division by zero. Report 0 until time has passed. Flagged by
UBSan.

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

* fix(battery): check cell voltage before computing scale

Check the filtered cell voltage before dividing by it rather than
relying on the NaN/inf result of the division. Flagged by UBSan.

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

* fix(perf): report 0 rms for a single event

With one event the rms was computed as 0/0. Flagged by UBSan.

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

* fix(matrix): only normalize axis for non-zero axis-angle rotations

The axis was normalized before checking for a zero angle, dividing by a
zero norm (e.g. SIH with no rotation). The result was already unused in
that case. Flagged by UBSan.

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

* fix(mathlib): return infinite cutoff for unconfigured AlphaFilter

A time constant of zero means no filtering; return an infinite cutoff
frequency explicitly instead of dividing by zero. Flagged by UBSan.

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

---------

Signed-off-by: Julian Oes <julian@oes.ch>
2026-10-02 10:39:54 -06:00
Andrea Bernasconi b38dcb1f6c fix(navigator): use "Return" instead of "RTL" in user-facing text (#28543) 2026-09-26 12:40:56 +10:00
Claudio ChiesandClaudio Chies 651b8687b8 feat(failure_injection): selectable detected/un-detected motor failure via SYS_FAIL_MOT_OFF (#28210)
* feat(failure-injection): implement motor failure injection with soft and hard modes

* feat(failure-injection): update motor failure injection descriptions and behaviors for annunciated and un-annunciated modes

* feat(failure-injection): update motor failure injection terminology to detected and undetected modes

* feat(failure-injection): refine motor failure injection handling for detected and undetected modes

* fix(boards): remove FailureInjector::update() from itcm_functions

FailureInjector was replaced by the shared failure_injection library, so
the symbol no longer exists and the ITCM check fails on the boards that
still list it. Its successor failure_injection::Config::update() is an
inline no-op unless MODULES_FAILURE_INJECTION_MANAGER is enabled, which
none of these boards do, so there is no replacement symbol to map.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Claudio-Chies <61051109+Claudio-Chies@users.noreply.github.com>

---------

Signed-off-by: Claudio-Chies <61051109+Claudio-Chies@users.noreply.github.com>
Co-authored-by: Claudio Chies <chiesc@chies.com>
2026-09-16 10:10:18 +02:00
Ramon Roche b28ba0eedb ci(ros2): test PR firmware in the ROS development container
Build each PR firmware and matching ROS workspace from source against the digest-pinned Jazzy toolchain. Run the interface library unit and SIH integration suites without reusing stale firmware or generated messages.

Assisted-by: Copilot:gpt-6-astra
2026-09-10 16:07:58 -07:00
Jacob Dahl dcfce4343a feat(mavlink): serve and accept packed parameters as @PARAM/param.pck (#28435)
* feat(mavlink): serve packed parameters as @PARAM/param.pck

QGC already downloads ArduPilot parameters as a packed FTP file, which
is much more reliable on lossy SiK links than the PARAM_VALUE firehose.
Serve the same format from PX4 so a hash miss can use that path.

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

* fix(mavlink): serialize the full message when resending a cached FTP reply

_last_reply caches only the header, PayloadHeader and four data bytes,
but the resend path handed that 19-byte array to the serializer as a
complete mavlink_file_transfer_protocol_t, which reads 254 bytes and
transmits whatever follows the cache. The decoded request is dead once
the resend decision is made, so expand the cache into it instead of
adding another message to the receiver thread's stack. Clear the unused
payload before caching so a resent NAK matches the original.

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

* test(mavsdk_tests): download parameters via MAVLink FTP

Fetch @PARAM/param.pck through MAVSDK's burst download on SIH and check
every entry against the PARAM_VALUE stream, so the packed format and the
FTP server's session, size and EOF handling stay covered by the SITL
tests that QGC and MAVSDK both rely on.

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

* fix(mavlink): cache FTP Open ACKs whose size LSB is 5

_reply skipped the compact cache whenever data[0] was kErrNoSessionsAvailable. On a NAK that is the error code; on an Open ACK it is the file size LSB. A lost Open ACK for param.pck of that length was retried as a second Open and failed.

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

* feat(tools): download packed parameters over MAVFTP

Host-side check of @PARAM/param.pck against the PARAM_VALUE stream.

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

* fix(mavlink): pad so a defaulted value does not straddle an FTP block

pack() kept the last 4 bytes of an entry in one chunk. With withdefaults those bytes are the default, so the value can still split. QGC always requests defaults; a hole-fill then retries one chunk with a live param_get().

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

* fix(mavlink): snapshot param.pck at open so a param_set cannot corrupt it

Pack the used set once into a heap buffer. Reads memcpy that snapshot, so a value change during the download cannot shift later entries or splice two generations across a retried FTP block.

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

* fix(mavlink): freeze param.pck membership instead of snapshotting the file

Keep which parameters appear and whether each includes a default in bitsets (~1 KB). Pack values live. Layout cannot shift mid-download; a retried block cannot splice a number.

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

* style(mavlink): format MavlinkFtpParamTest.cpp

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

* refactor(mavlink): keep FTP work buffers as members

@PARAM/param.pck is a connect-time path, not the rare path the lazy new[] was for. send() could free the buffers after 2 s of no request while a burst was still running. Fold them into the instance (495 B) and always idle-close the session at 30 s.

A new Open takes over the single session so a lost Terminate on a slow link does not NAK until that close.

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

* fix(tools): make mavftp_param.py reliable on a radio link

pymavlink applied FTP timings after ResetSessions, wrote param.pck?withdefaults=1 into cwd, and bumped the session id on Open retry (PX4 only ACKs session 0). Set radio timings at construction, pin session 0, retry a missed Open, and treat a complete decode as success.

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

* feat(mavlink): accept packed parameter FTP uploads

CreateFile/Write/Terminate of @PARAM/param.pck applies the ArduPilot
packed stream so a GCS can bulk-load without a PARAM_SET round trip per
value. Unknown and read-only names are skipped; Terminate NAKs a
truncated file or the with-defaults magic.

* test(mavsdk_tests): upload MPC_XY_P via packed param FTP

Pin the SIH upload case to a known float instead of whatever
get_all_params() returns first.

---------

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-09-08 20:16:14 -06:00
Roman Bapst 338592cb98 fix(simulation): fix test filter for loiter tests (#28271)
The fixed wing loiter tests were not running because the test filter did not match.

Also the test was failing because the altitude threshold when to stop checking the "established on loiter" criteria was lower than the fixed wing altitude acceptance radius, so the test was always failing.
2026-09-04 16:42:06 +02:00
Saibernard 290f56d6a8 fix(navigator): keep a VTOL in multicopter mode through mission RTL (#28399)
* fix(navigator): preserve VTOL mode in direct mission RTL

Remove the unconditional multicopter-to-fixed-wing transition from direct mission-land RTL so the return uses the VTOL mode active when RTL starts. This allows an MC-mode vehicle to proceed through the mission landing sequence instead of becoming stuck after an unnecessary forward transition.

Add module-level and MAVSDK SITL regressions covering an airborne multicopter-mode VTOL with a planned mission landing.

Refs #27817

Refs #24323

Assisted-by: Codex:gpt-5
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>

* fix(navigator): drop the fixed wing transition from the fast RTL modes too

The fast and the reverse mission RTL carried the same request for a
transition to fixed wing as the direct mission land RTL. The VTOL
attitude controller rejects that command during RTL, so a VTOL in
multicopter mode waited on it forever instead of flying the mission.
Remove both. A VTOL in multicopter mode now flies the mission RTL as a
multicopter, the same as direct RTL does. Reported in #24323.

Two unit tests pin the active item to a waypoint for a VTOL in
multicopter mode, and two MAVSDK cases fly it on the standard VTOL in
SIH: the mission landing and the reverse mission both stay in
multicopter mode to touchdown, within 5 m of the land item and of home.

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

---------

Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
2026-09-03 13:04:25 -06:00
Anil Kircaliali c5e1372058 feat(rtl): add RTL_TYPE 6 prioritizing home over rally points with battery reachability check (#26968)
Return home if the estimated flight time to home fits within the
remaining battery time; otherwise return to the closest rally point.
If the battery time estimate is unavailable, return to the closest
safe point (home or rally).
2026-08-14 10:39:42 -06:00
James Botwina 47ce421a88 fix(simulator_sih): restore xvert front transition (#28090)
* fix(simulator_sih): correct tailsitter pitot axis

Signed-off-by: jbotwina <jimbotwina16@gmail.com>

* fix(airframes/10042): tune xvert transition

Signed-off-by: jbotwina <jimbotwina16@gmail.com>

* test(mavsdk_tests): cover xvert transition

Signed-off-by: jbotwina <jimbotwina16@gmail.com>

* fix(airframes/10042): disable airspeed scaling

Signed-off-by: jbotwina <jimbotwina16@gmail.com>

---------

Signed-off-by: jbotwina <jimbotwina16@gmail.com>
2026-07-29 13:01:51 -06:00
Roman Bapst 9467506bff fix(navigator): resolve DO_JUMP set as current mission item (#28063)
* test(mavsdk): add multicopter DO_JUMP set-current regression test

Add an integration test for an external MISSION_SET_CURRENT that targets a
DO_JUMP item mid-mission - the scenario that used to strand the vehicle on an
invalid IDLE setpoint (fixed in the following navigator commit).

The test flies a multicopter mission containing a DO_JUMP that loops back to an
earlier waypoint, commands the current item to the DO_JUMP index while airborne,
and checks that the mission still resolves the jump, runs to completion, lands
and disarms within the timeout.

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* fix(navigator): resolve DO_JUMP when loading the current mission item

An external MISSION_SET_CURRENT sets the current sequence verbatim, with no
jump resolution. If it points directly at a DO_JUMP item, the navigator loaded
that jump as the current mission item. A DO_JUMP carries no position, so
setActiveMissionItems() never overwrote the current setpoint left behind by
reset_triplets() - an invalid IDLE setpoint. The vehicle then loitered in place
at altitude indefinitely, never resolving the jump and never completing the
mission (observed in a real flight).

Resolve the jump when loading the current item: follow it to its target without
consuming a repetition (a set-current is an out-of-band action, not a normal
traversal). For an already-resolved, non-jump current item this is a no-op, so
normal mission traversal is unaffected.

Also harden two related paths:
- getNonJumpItem() now reports failure instead of returning a still-unresolved
  DO_JUMP when it runs out of iterations (jump loop or a chain longer than
  MAX_JUMP_ITERATION), which would otherwise be loaded as the current item.
- treat a DO_JUMP as reached/completed in the mission block as a safety net, so
  the navigator advances rather than hanging should one ever reach that point.

Signed-off-by: RomanBapst <bapstroman@gmail.com>

---------

Signed-off-by: RomanBapst <bapstroman@gmail.com>
2026-07-28 14:21:32 +03:00
Mahima Yoga 8e7b370cde fix(mavlink): accept INT32_MIN as "param not used" in mission item validation (#28079)
QGC leaves unused float params as NaN and converts them into the int32
x/y fields of MISSION_ITEM_INT, which comes out as INT32_MIN. This made
PX4 reject any mission with camera items (set mode, take photo/video,
stop photo/video) with INVALID_PARAM5. Treat INT32_MIN as "param not
used", the same as INT32_MAX.

Signed-off-by: mahima-yoga <mahima@auterion.com>
2026-07-24 11:51:58 -06:00
Julian Oes a6e6ebfe95 chore(mavsdk_tests): bump library version (#27996)
This includes quite a few bugfixes.
2026-07-22 20:04:53 +12:00
Jacob Dahl a617a1433c fix(mavsdk_tests): stabilize takeoff-and-hold altitude check
wait_until_altitude() returns on the first touch of the target band while
the vehicle is still climbing, so start_checking_altitude() latched the hold
reference mid-climb. The normal takeoff overshoot (~0.24 m) and slow VTOL
settle then exceeded the 0.15 m tolerance and the standard_vtol job failed
intermittently.

Wait for the overshoot to damp before capturing the reference, and restore
the 0.2 m tolerance established in #26106 (a later SIH rewrite had tightened
it back to 0.15 m). Steady-state hover holds to ~0.05 m, so the check stays
sensitive to real altitude-hold failures.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-07-22 16:17:17 +12:00
Jacob Dahl 73ca0e2137 fix(mavsdk_tests): don't wait for Land mode on mission GPS loss (#28017)
Since #27918 a blind descend reports the distinct Descend flight mode
instead of masquerading as Land. MAVSDK v3.17.1 has no Descend mode, so
wait_for_flight_mode(Land) timed out and SITL failed on main.

Losing GPS in SIH removes all horizontal position aiding, so the vehicle
always blind-descends after the mission GPS loss; a controlled Land is
never entered. The test already waits for the automatic disarm after
landing, which is the meaningful check.

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-07-21 19:13:05 -06:00
Claudio Chies 282c969687 fix(commander): capture home orientation on ground independent of local position (#27946) 2026-07-21 11:49:06 -07:00
Julian Oes 0f78cd65a0 test(mavsdk): retry arming to tolerate transient is_armable flicker
wait_until_ready() polls MAVSDK's is_armable, but a known hysteresis gap
(and estimator heading-reference flicker at startup) means the flag can
read armable while PX4 then denies the arm command with 'no heading
reference'. This made arm() fail intermittently. Retry the arm command
until the autopilot accepts it, so the transient is absorbed while real
failures still time out.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-17 10:51:42 -05:00
Julian Oes ac14e4a93e test(mavsdk): raise RTL disarm timeout to 150s to match siblings
The four older VTOL RTL tests waited only 120s for disarm while running
the same climb-to-550m-and-land missions as the other RTL tests, which
already use 150s. 'RTL direct Mission Land' occasionally tipped just
over 120s of sim time (observed 123.76s), failing wait_until_disarmed.
Align all of them to 150s for margin.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-17 10:51:42 -05:00
Julian Oes 9976825d80 test(mavsdk): loosen takeoff altitude reach tolerance to 0.1m
The 0.01m (1cm) tolerance was not reachable within the 15s sim-time
window for the standard_vtol, causing the takeoff-and-hold test to time
out. Use 0.1m, which still verifies altitude hold but is physically
achievable, and stays below the 0.15m hold-monitoring tolerance.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-17 10:51:42 -05:00
Julian Oes 8e9ab68f11 test(mavsdk): retry offboard start to beat MAVSDK setpoint watchdog
MAVSDK's OffboardImpl::process_heartbeat() resets the setpoint state to
NotActive when a heartbeat without offboard mode arrives more than 3 s
after _last_started. _last_started is only ever written by start(), so
before the first start() it is epoch zero and the guard is always true:
any heartbeat that slips in between set_*() and start() makes start()
fail with NoSetpointSet.

At speed factor 30 PX4's 1 Hz (sim time) heartbeat arrives every ~33 ms
of wall time, which made 'Offboard attitude control' fail roughly one
run in three. Re-send the setpoint and retry start() in a small loop at
both offboard start sites. Failed 1/3 before, 16/16 after.

This is arguably a MAVSDK bug (_last_started should be initialized when
setpoint streaming begins); a retry keeps the tests robust either way.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-17 10:51:42 -05:00
Julian Oes ac8f3df583 refactor(mavsdk_tests): use sim time directly for execute_mission timeout
poll_condition_with_timeout polls the autopilot's monotonic time, which is
already simulation time. The previous code divided a sim-time budget by the
speed factor to compute a wall-clock timeout, but this is unnecessary and
adds a dependency on the speed-factor query.
2026-07-17 10:51:42 -05:00
Ramon Roche 9a446cce0c fix(mavsdk_tests): use simulation time for sleeps in basics test
Replace std::this_thread::sleep_for() with tester.sleep_for() to use
simulation-aware sleep that accounts for speed factor under lockstep.
2026-07-17 10:51:42 -05:00
Ramon Roche d5cfc0fd97 fix(mavsdk_tests): use simulation time for timeouts
Replace 5 functions that used std::future::wait_for() (wall-clock time)
with poll_condition_with_timeout() (simulation time). This prevents
timeouts from expiring prematurely when running at high speed factors
under lockstep.

Affected functions:
- wait_until_altitude()
- wait_for_landed_state()
- wait_for_flight_mode()
- start_and_wait_for_mission_sequence()
- wait_until_speed_lower_than()

Also remove debug printf statements from start_checking_altitude().
2026-07-17 10:51:42 -05:00
Julian Oes 991f8d40af test(mavsdk): clear unused params in land-start VTOL plan
The DO_LAND_START item carried loiter params (heading required, radius,
and a stray 1 in param3) hand-copied from the adjacent LOITER_TO_ALT
item, and LOITER_TO_ALT itself had param3 set, which the spec defines
as empty. PX4's mission item param validation now rejects such items.

Signed-off-by: Julian Oes <julian@oes.ch>
2026-07-17 10:51:42 -05:00
Julian Oes 18dc9a2665 fix(mavsdk_tests): bump MAVSDK version 2026-07-17 10:51:42 -05:00
Julian Oes ec982625b6 test(ros): add new model_prefix 2026-07-17 10:51:42 -05:00
Julian Oes eaaf6f676a test(mavsdk): leave tests backwards compatible but enable SIH
This reverts some of the changes to keep runners of classic Gazebo in
there but leave it optional, so we can still use it if required.
2026-07-17 10:51:42 -05:00
Matthias Grob cf8a65c5dd test(mavsdk): switch tests to SIH simulator 2026-07-17 10:51:42 -05:00
Roman Bapst ee7134681d fix(navigator): keep established loiter on RTL/Hold and let each mode own its triplet reset (#27836)
* fix(navigator): remove generic reset of navigator triplets on mode change

- make each navigation mode decide if it needs the reset and what data it
wants to capture before the reset
- fix RTL climbing so that it remains on an established loiter when RTL
is being activated -> avoids weird trajectories and potential geofence breaches

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* feat(mavsdk_tests): added various integration tests for loitering behavior:

- make sure RTL climb remains on established loiter
- make sure new loiter at current location is set when HOLD is engaged while
vehicle is transiting to another loiter
- make sure altitude is locked to current altitude when vehicle is currently
flying an established loiter but is transiting to a higher altitude
- make sure vehicle resets from figure of 8 to a loiter when HOLD is engaged
while vehicle is established on a figure of 8

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* navigator: improve wording

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* rtl_mission_direct_land: avoid loitering on a previously set figure of 8

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* fix(navigator): harden geofence position checks and preserve loiter on breach

The GF_SOURCE_GPS path previously gated the breach check on the global
position timestamp even though it evaluated the fence against raw GPS
coordinates. Validate each source against the data it actually uses:
the fused global position on freshness (<1s), and raw GPS on freshness
(<2s) plus a valid fix.

For the LOITER breach action, only issue the reposition when the fused
global position is valid, since the setpoint is flown on that estimate,
and source all reposition coordinates from it. When the vehicle is
already established on a circular (orbit) loiter, keep that loiter's
center instead of re-centering on the current position to avoid a jump.

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* fixup

Signed-off-by: RomanBapst <bapstroman@gmail.com>

* make methods const

Signed-off-by: RomanBapst <bapstroman@gmail.com>

---------

Signed-off-by: RomanBapst <bapstroman@gmail.com>
2026-07-16 18:07:04 +03:00
5ea3cf8cb9 feat(navigator): extend detect and avoid module to follow regulatory standards such as ASTM F3442 (#26815)
* feat(navigator): extend detect and avoid module to follow regulatory standards such as ASTM F3442

* docs(docs): minor subedit

* refactor(navigator): reduce flash by grouping notif into same events

* docs(daa): Improve docs readability with ::: details blocks

* fix(navigator): single event when on ground with conflict

* refactor(boards): increase flash length from 4M - 128k to 5M - 128k

* rework(general): define DAA standard at build with new CONFIG_NAVIGATOR_ADSB_F3442

* clean(navigator): minor changes to clean the PR

* feat(boards): add CONFIG_NAVIGATOR_ADSB_FAKE_TRAFFIC in visionTargetEstStatic.px4board

* rework(daa): reduce amount of abstractions and minor cleaning

* refactor(boards): allyes revert flash length to 4M-128K

* refactor(boards): allyes increase flash length to 5M-128K

* rework(daa): rework event notifications to improve clarity

* docs(docs): move details inside of ::: details block

* docs(docs): run npx prettier

* refactor(daa): avoid void mutator functions

* docs(docs): Improve Python helper to decode daa unique id

* rework(daa): move encoded id handling to the adsb lib and refactor on_active

* refactor(daa): naming and zero init

* fix(daa): move dataman dep from daa level to unit test level

* refactor(daa): define common daa_input and rework process_transponder_report

* fix(daa): remove stale todo

* refactor(daa): rename crosstrack_based_daa to crosstrack_standard

* refactor(daa): rename F34_ params to DAA_

* docs(docs): revert changes to autogenerated docs

* docs(docs): Add Detect And Avoid in index.md

* refactor(daa): update message on init failed

* refactor(daa): only publish most_urgent conflict once in on_active()

* refactor(daa): move conflict buffer handling in the adsb lib

* refactor(daa): move notifications into new class ConflictNotifier and only notify once per cycle

* refactor(daa): uninit _cycle_changes to store into .bss (and save flash)

* docs(docs): remove unused image link

* refactor(daa): move automated action policy to the adsb lib

* refactor(daa): move self detection into adsb lib as DaaTrafficFilter

* refactor(daa): minor changes in unit tests

* refactor(daa): merge DaaTrafficFilter and DaaEncoding

* fix(daa): fix CI by removing navigator from the DAA deps

* refactor(daa): reduce stack size

* fix(daa): advertise _fake_traffic_pub in constructor

* refactor(daa): Comments only,  simplify and reduce comments

* fix(daa): brief comment missing end star

* Disable CONFIG_NAVIGATOR_ADSB in ark_fpv_default board

* docs(docs): General clarifications and remove the 1.18 badge

* refactor(daa): cleaning

* refactor(daa): minor cleaning

* refactor(adsb): simplify conflict tracker assuming push_back cannot fail

* build(cmake): cleaner fix to protect regex alternations

* refactor(daa): Crosstrack, remove unit test requiring finite yaw (yaw not used by standard)

* refactor(daa): minor cleaning and fix callsign to uint64

---------

Co-authored-by: jonas <jonas.perolini@rigi.tech>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
2026-07-13 16:14:42 -06:00
Roman BapstandBalduin 40e61d2429 feat(navigator): Geofence Aware RTL (#27145)
Plan RTL paths that route around geofence boundaries — both inclusion
and exclusion zones — instead of flying straight through them and
breaching. The planner builds a visibility graph over the margin-inflated
geofence polygons and circles and runs Dijkstra to find the shortest
legal return path, falling back to a straight line to the destination
when no valid path exists.

Highlights:
- New reusable libraries: src/lib/dijkstra (generic shortest path) and
  src/lib/geofence (fixed-point geometry, polygon inflation, bitangent
  visibility); the RTL planner lives in navigator/RTLPlanner.
- Visibility graph keeps only bitangent edges and skips edges that poke
  into a forbidden region, greatly reducing edge-cost computation.
- Corner splitting is limited to sharp convex corners.
- Geometry validation: reject self-intersecting polygons and vertices
  outside the fixed-point range; centimeter fixed-point scaling keeps
  orientation tests exact and avoids drift at large distances.
- Failure handling: a Status enum replaces silent bool returns, and
  failures (unbuildable fence, planner capacity overflow, dataman load
  errors, NaN waypoints, destinations that breach the fence) are
  surfaced to the operator via MAVLink warnings/criticals; the planner
  falls back to a straight-line RTL.
- Destination updates are centralized in RTL::setRtlTypeAndDestination;
  the path is replanned only when the destination or geometry changes.
- VTOLs always use the fixed-wing margin (FW loiter radius).
- kMaxNodes is exposed as a Kconfig option (default 100); the feature is
  disabled on flash-constrained boards (FMUv4 and older, various F4/F7).
- Tests: unit tests for the Dijkstra lib, geofence geometry utils, and
  the avoidance planner, plus a MAVSDK SITL test flying an RTL through a
  geofence.
- Documentation: new "Geofence Awareness" section in the RTL docs.

Co-authored-by: Balduin <balduin@auterion.com>
2026-07-09 15:08:27 +03:00
Julian Oes ccd444726e test: add TSan suppressions for Gazebo sim transport
Running SITL with the Gazebo bridge under ThreadSanitizer reports many data races
inside libzmq and gz-transport (and the GZBridge glue) - third-party simulation
transport that is not in the flight path or the SIH-based CI and that we cannot
fix. Add a suppressions file so the TSan signal stays usable for finding real
races. Use via TSAN_OPTIONS="suppressions=test/sitl_tsan.supp".
2026-07-02 08:42:49 -07:00
Julian Oes 344c5c356e fix(build): disable fuzztest when building with TSAN
fuzztest's coverage instrumentation is incompatible with Thread
Sanitizer. Add px4_setup_gtest_without_fuzztest() macro to
cmake/px4_add_gtest.cmake that fetches GTest standalone and stubs out
fuzztest cmake functions. Guard all fuzztest-specific code on
TARGET fuzztest::fuzztest so it compiles cleanly without fuzztest.
2026-07-02 08:42:49 -07:00
bvrtoverfitprimes cd900a8973 fix(mavlink): reject unsupported params in commands and missions (#27541)
* fix(mavlink): reject unsupported params in commands and missions

PX4 accepted any non-NaN value in params it does not use for a given
MAV_CMD, silently storing or ignoring them. This made it impossible for
a GCS to detect that a mission item or command was malformed, and risked
unexpected behaviour if the param meaning is assigned in a future update.

Add mavlink_command_params.h: a header-only sorted lookup table mapping
each supported MAV_CMD to uint8 bitmasks (one for mission items, one for
commands) indicating which of params 1-4 are valid.  check_params() does
a binary search and returns the 1-based index of the first offending
param, or 0 if all unsupported params are unset.

A param is considered unset when it is NaN (the MAVLink standard) or 0.0
(the conventional GCS default for unused float fields).  Any other value
in an unsupported slot is rejected:

- Mission uploads (MISSION_ITEM / MISSION_ITEM_INT): NACK with
  MAV_MISSION_INVALID_PARAMn for the offending param index.
- Commands (COMMAND_LONG / COMMAND_INT): ACK with MAV_RESULT_DENIED.

Validation is placed at the MAVLink ingress boundary
(parse_mavlink_mission_item and handle_message_command_both) before any
downstream processing, keeping Commander and Navigator unmodified.

The table covers all 45 MAV_CMDs handled by PX4's mission and command
parsers.  The static_assert enforces sort order at compile time.

Fixes #27483

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): split mission/command p5-7 masks, fix int_mode branch, add vehicle overrides

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): fix 142-char lines and Python CI type/style errors

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): pack p5-7 bits into mission/command byte, fix astyle/type-limits/mypy

* fix(mavlink): range-for over VehicleParamOverrides, fix mypy ignore code

* fix(mavlink): wire check_params_for_vehicle, add int variant, drop non-vehicle check_params

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): suppress clang unused-function on check_params_*_for_vehicle

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): rename local vs to avoid shadow in handle_message_command_both

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): cache vehicle_type_bitmask as member, update on vehicle_status change

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): use named VEHICLE_TYPE_* consts, fix masks, drop WARN spam, fix int_mode cast

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): normalize INT32_MAX to 0 for MAV_FRAME_MISSION p5/p6 in int_mode

For MAV_FRAME_MISSION items, x/y are generic p5/p6 params (not lat/lon),
so GCS tools send 0 for unused params — not INT32_MAX. Using
check_params_int_for_vehicle here caused int_param_is_unset(0)=false,
which rejected valid DO_LAND_START and similar items with x=y=0.

Fix by normalizing INT32_MAX to 0.0f before calling check_params_for_vehicle,
so both the MISSION_ITEM_INT sentinel and the conventional float zero are
treated as unset. This restores acceptance of zero-param items like
DO_LAND_START while still correctly rejecting items that carry non-zero,
non-sentinel values in unsupported param slots.

Signed-off-by: Himaghna <pen314paper@gmail.com>

* fix(mavlink): address review feedback on VTOL masks, NaN sentinel, dead enum, and RTL test frame

* fix(mavlink): move param validation test out of mavsdk_tests, rename header to .hpp

* fix(mavlink): dedupe param-scan loop shared by check_params_for_vehicle variants

---------

Signed-off-by: Himaghna <pen314paper@gmail.com>
2026-07-02 10:11:56 +12:00
Ramon Roche 92fa89d7d7 ci(mavros): remove MAVROS integration test suite
Coverage overlaps with mavsdk_tests on iris (mission + offboard
posctl); MAVROS plugin behavior belongs to the MAVROS project.
Drops the workflow, .test launchers, rostest_px4_run.sh, and the
integrationtests/ python helpers.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-05-14 10:40:14 -07:00
Ramon Roche 6baef6ba88 ci(ros_integration_tests): restart XRCE-DDS Agent between tests
Restart the Micro-XRCE-DDS Agent before each integration test so DDS
graph state from a previous PX4 instance does not leak into the next
test.

The MicroXRCEAgent is started once per session, but PX4 reboots between
tests. The Agent retains writer entries from the previous PX4, so when
the new PX4 reconnects, count_publishers() in px4-ros2-interface-lib's
waitForFMU returns >0 immediately against a stale entry. Phase 1
(discovery) returns instantly, then Phase 2 (heartbeat) times out
waiting for a message on a subscription matched to a dead writer.

This is why ModesTest.denyArming (first test) passes while every later
ModesTest fails with "timeout while waiting for FMU heartbeat".

Adds an optional pre_test_hook on test_runner.Tester so ROS-specific
lifecycle stays out of the shared test_runner. The workflow stops
starting the Agent externally; ros_test_runner.py owns the lifecycle.

Refs #27328

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-05-13 10:16:39 -07:00
Onur Özkan 0d18be5049 fix(scripts): replace hardcoded /bin/bash shebangs
Several helper scripts assumes bash is available at /bin/bash. That breaks on systems
such as NixOS, where bash is resolved from PATH instead of a fixed /bin location and
causes failures like `bad interpreter` during `make format`, e.g., on my host machine:

```sh
$ make format

/PX4-Autopilot/Tools/astyle/check_code_style.sh: /PX4-Autopilot/Tools/astyle/fix_code_style.sh: /bin/bash: bad interpreter: No such file or directory
```

This change switches these entrypoints to `#!/usr/bin/env bash` so they locate bash properly.

No functional changes intended.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
2026-04-01 12:25:28 -08:00
Marco Hauswirth 7297364484 fix ros-test-config for multi-APG 2026-02-20 17:43:45 +01:00