Commit Graph

322 Commits

Author SHA1 Message Date
Jonas Perolini
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 Bapst
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
Farhang
14186cf74f [Tests] [CI] fix flaky altitude SITL test (#26106)
* test: increase altitude tolerance to fix flaky test

Altitude tolerance increased from 0.1f to 0.15f to handle simulation
timing variations. Test was failing at 0.201m with 0.2m tolerance.

* test: increase altitude tolerance further to 0.3m

* ci: re-add branch trigger for SITL tests

* Revert "ci: re-add branch trigger for SITL tests"

This reverts commit e5e4c9637b.
2025-12-13 09:13:23 -09:00
Julian Oes
1de6001163 mavsdk_tests: bump MAVSDK version to v3.11.2 (#26024)
This should hopefully fix the annoying segfaults on destruction that we
have been seeing.
2025-12-01 13:30:08 -08:00
Julian Oes
ff06a206d1 mavsdk_tests: bump version to 3.11.1
This should now include the figure eight messages.
2025-11-20 23:23:40 -09:00
Julian Oes
46ed71fa5b mavsdk_tests: figure eight is in common now 2025-11-20 23:23:40 -09:00
Hamish Willee
7d509d832a Update to latest mavlink that includes support for WIP warnings (#25804)
* Update to latest mavlink that includes support for WIP warnings

* mavsdk_tests: pass build for now

We need this until the figure eight stuff has moved to common.

---------

Co-authored-by: Julian Oes <julian@oes.ch>
2025-10-29 12:43:10 +11:00
Beat Küng
3d1cace7b7 test: add google fuzztest to unit test build
From https://github.com/google/fuzztest.
This will now also add gtest (via cmake FetchContent)

And requires newer cmake (container updates):
CMake 3.19 or higher is required.  You are running version 3.16.3
2025-07-11 10:39:28 +02:00
mahima-yoga
ee953640ee MAVSDK: bump version to 3.7.0 2025-07-09 07:43:20 +12:00
Julian Oes
bfbd9bfe27 mavsdk_test: fix mission timeout check
We shouldn't adjust for lockstep speedup twice.
2025-06-30 09:20:44 -07:00
Julian Oes
d03b1171f9 mavsdk_tests: fix mission finished state
This is an attempt to use MAVSDK's is_mission_finished APIs instead.
2025-06-30 09:20:44 -07:00
Julian Oes
4126dde11f mavsdk_tests: bump to v3.4.0
This should fix some of the lockups and segfaults we see.
2025-05-19 07:37:02 -07:00
Julian Oes
d4be5d3ff0 mavsdk_tests: add events to log 2025-05-19 07:37:02 -07:00
Julian Oes
1f65cc46b9 mavsdk_tests: bump MAVSDK to v3.3.4 2025-05-19 07:37:02 -07:00
Julian Oes
56eb9bcc18 mavsdk_tests: workaround race condition
PX4 needs a bit of time to process an uploaded mission before it is
ready to accept the mission mode.

Therefore, we need to wait a bit.

Alternatively, we could wait on the mission progress arriving properly,
but this sleep is simple enough for now.
2025-05-19 07:37:02 -07:00
Julian Oes
e19d245355 mavsdk_tests: remove hacks for rally points
We can now just use MAVSDK to upload rally points.
2025-05-19 07:37:02 -07:00
Julian Oes
66deae172d mavsdk_tests: update to MAVSDK 3.0.0 2025-05-19 07:37:02 -07:00
GuillaumeLaine
ba35ca461c ci: add external navigation integration tests 2025-04-04 09:12:53 +02:00
Beat Küng
0e4c794674 ros_tests: change filter to use all tests
The name is being changed in https://github.com/Auterion/px4-ros2-interface-lib/pull/8
2025-04-04 09:12:53 +02:00
Beat Küng
3d6056411f integration tests: add --force-color & set in CI
github actions supports color output, but does not report as a tty.
See https://github.com/actions/runner/issues/241.
2025-04-04 09:12:53 +02:00
Beat Küng
a954ec4d55 test: add ros integration test runner script & config 2025-04-04 09:12:53 +02:00
Beat Küng
7c14a63855 refactor mavsdk_tests: move code into separate classes & extract mavsdk-specifics
Allows it to be reused for other integration tests, like ros.
2025-04-04 09:12:53 +02:00
Beat Küng
d78af5436e mavsdk_tests: highlight px4 errors & reset color on gazebo output 2025-04-04 09:12:53 +02:00
Beat Küng
45285a57ad fix mavsdk_tests: add ',' to test_filter config 2025-04-04 09:12:53 +02:00
Beat Küng
bbcd153e94 sitl: add generic way to override params via ENV variables 2025-04-04 09:12:53 +02:00
Jacob Dahl
4c0a63f679 mavsdk_tests: add multicopter alt hold test (#24396)
* mavsdk_tests: add multicopter alt hold test

* fix test filter

* increase altitude tolerance to 10m as a test

* reduce to 1m tolerance

* increase to 5m tolerance

* increase to 2m tolerance

* reduce back to 1m

* delay 60 seconds

* fix log upload

* fix ulog upload path

* make altitude tolerance in tester.wait_until_altitude configurable

* fix lambda

* default arg in declaration

* tighten up tolerance
2025-03-21 16:21:10 -06:00
Balduin
c0100ed4e7 mavsdk tests: use tester sleep_for function
the previously used std::this_thread::sleep_for is with respect to host
system time which is different from autopilot time if:

 - speed factor != 1
 - something runs slower than realtime regardless of speed factor
 - debugging or otherwise interrupting PX4 control code

tester.sleep_for (which already existed) correctly sleeps w.r.t.
px4/simulation time.
2025-03-18 10:25:38 +01:00
Matthias Grob
ed9111ec49 Remove obstacle avoidance test with Gazebo classic and ROS 1 2025-02-18 14:33:16 +01:00
Silvan Fuhrer
58d3e1ea8e test: in VTOL integration test use VTOL_LAND (#24261)
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2025-01-28 11:22:51 +01:00
Daniel Agar
7288d16855 mavsdk_tests set nice levels for px4/gzclient/mavsdk_tests 2024-11-20 14:45:11 -05:00
Daniel Agar
635e162a0c test/mavsdk_tests: continue sending manual control between steps in fly_forward_in_posctl()/fly_forward_in_altctl() 2024-11-20 09:36:06 -08:00
Jacob Dahl
ed3cac9122 tests: increase timeout for armable check 2024-11-05 21:13:10 -05:00
Ramon Roche
16c77be7c0 tests: loosen radius of vtol rtl landing pos check 2024-08-26 14:05:17 -04:00
Matthias Grob
f2bca92221 Fix duplicate newlines at the end of files 2024-07-19 14:33:36 +02:00
Silvan Fuhrer
0379048ad2 mavsdk_tests: increase acceptance radius for position check on offboard landing
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2024-05-29 20:46:26 -04:00
Silvan Fuhrer
97191bd60f autopilot_tester: for mission end timeout check take speed factor into account
And increase the (simulation time) timeouts.

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2024-04-23 16:37:31 +02:00
Silvan Fuhrer
818e318334 autopilot_tester: reduce mission distance for wind world
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2024-04-23 16:37:31 +02:00
Silvan Fuhrer
59232c27ae autopilot_tester: use normal VTOL mission for airspeed blockage test
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
2024-04-23 16:37:31 +02:00
Daniel Agar
78bbb66568 delete SYS_MC_EST_GROUP
- introduce per module parameters (EKF2_EN, LPE_EN, ATT_EN)
 - add basic checks to prevent EKF2 + LPE running simultaneously
2024-04-15 16:06:08 -04:00
Matthias Grob
4e3bd4f196 MAVSDK tests: shorten Position, Altitude control flights
We get more than 5 meter away much quicker.
2024-02-22 15:29:13 +01:00
Matthias Grob
0cc4b41a51 MAVSDK test: Fix fly_forward_in_altctl() timing 2024-02-22 15:29:13 +01:00
Matthias Grob
f602228048 MAVSDK test: increase offboard position threshold
This is a workaround to hotfix CI but the root cause is #22792
(MAVSDK test failing after EKF change, accelerometer simulation issues not learned anymore?)
2024-02-22 15:29:13 +01:00
PerFrivik
9b122adae4 Fix fly_forward_in_posctl() timing 2024-02-22 15:29:13 +01:00