Commit Graph

29259 Commits

Author SHA1 Message Date
Balduin 2be4dd2744 refactor(simulation): remove srand(1234) calls
to be determined if this breaks anything substantial as hinted at in the
comment in BlockRandGauss.hpp (comment from 2013, only moved once since):

// XXX currently in nuttx if you seed to 0, rand breaks
2026-04-15 12:06:35 +02:00
Balduin d516b3cf9c refactor(simulation): extract generate_wgn into shared noise library
Seven simulation modules (sensor_{airspeed,mag,agp,baro,gps}_sim,
gz_bridge, simulator_sih) each carried a byte-identical copy of
generate_wgn() -- a Marsaglia polar method white Gaussian noise sampler
originally copy-pasted from BlockRandGauss.hpp. Four of them also
duplicated a noiseGauss3f() helper.

Consolidate both into a new header-only library src/lib/noise/ exposing
math::generate_wgn() and math::noiseGauss3f().

Also add math::generate_wgn_boxmuller() (basic Box-Muller) for callers
who need stateless / thread-safe / constant-time sampling; doc-comment
explains when to prefer each. This was previously only in a comment.

BlockRandGauss::update() now uses math::generate_wgn(), so the entire
tree has exactly one copy of the algorithm.

srand(1234) seeds in SensorBaroSim and Sih are preserved at the caller
-- seeding the process-global rand() is the caller's responsibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 11:55:27 +02:00
Jonas Perolini 83f2b96954 fix(navigator): goToNextPositionItem skip loops when required (#26993) 2026-04-15 09:40:13 +10:00
Jacob Dahl 6bc3e17bd4 fix(dshot): retry offline serial telemetry channels when disarmed (#27085)
Once a serial telem channel hit 10 consecutive timeouts it was added
to a skip mask and never polled again. Channels that came online late
(e.g. ESC power-cycled after the autopilot boots) stayed permanently
offline, and with both serial and bdshot enabled the motor was
reported offline overall because the combined health check requires
both sources.

Periodically clear the skip mask while disarmed so recovered channels
get another chance. If still broken they are re-skipped after the
normal timeout threshold. Disarmed-only to avoid timeout blips on
healthy channels during flight.
2026-04-14 12:18:12 -08:00
ttechnick 5b87d3f628 feat(simulation): Disable sensor calibration in HIL 2026-04-14 17:07:11 +02:00
Shara e05f699bb2 fix(gz_bridge): add gimbal kconfig guard(#24991)
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-04-13 08:48:24 -08:00
Jonas Eschmann abc756bf34 fix(mavlink): Allowing custom modes to request offboard setpoints via the external mode registration (#26949)
* forwarding offboard setpoints in modes using the external mode registration

* requesting offboard setpoint in RAPTOR

* adding old message versions

* bumping vehicle status

* adding message translations

* updating reference to versioned old message on previous translations
2026-04-13 09:06:11 -07:00
gguidone 4c1078c699 test(failure_detector): add unit tests for altitude loss detection 2026-04-13 14:23:51 +02:00
gguidone 2a0a4ac3e2 feat(commander): uncommanded altitude loss detection with parachute failsafe
Detects when a rotary-wing vehicle drops more than FD_ALT_LOSS metres
below a NED-z reference while altitude control is active,
and immediately triggers flight termination (parachute deployment).

Detection (FailureDetector):
- FD_ALT_LOSS: drop threshold in metres (0 = disabled, default)
- FD_ALT_LOSS_T: hysteresis time
- Guards: rotary-wing only, altitude control active, z_valid, setpoint
  fresh (<1 s). Manual, Acro and FW/VTOL-FW modes are excluded.
- Ratcheting reference: initialises to lpos.z on first sample below
  setpoint, preventing false triggers on new waypoints

Failsafe action (commander):
- New fd_alt_loss flag in FailsafeFlags.msg
- COM_ALT_LOSS_ACT: -1=Disabled (default), 0=Terminate
- Terminate fires immediately, cannot be overridden, and never clears
  until disarm (parachute deployment is irreversible)
2026-04-13 14:23:51 +02:00
Ramon Roche 62b3c9a063 fix(mavlink)!: align signing with MAVLink spec and fix performance regression (#26894)
* fix(mavlink): align signing with MAVLink spec and fix performance regression

Remove the non-standard MAV_SIGN_CFG parameter and align the signing
implementation with the MAVLink specification.

Key changes:
- Remove MAV_SIGN_CFG parameter that conflicted with GCS implementations
- Only enable signing when a valid key is present on the SD card
- Accept SETUP_SIGNING on any link, not just USB
- Reject SETUP_SIGNING while the vehicle is armed
- Allow disabling signing via signed all-zero key SETUP_SIGNING message
- Propagate key changes to all mavlink instances
- Zero CPU/bandwidth overhead when signing is not active

Fixes #26893

Signed-off-by: Ramon Roche <mrpollo@gmail.com>

* Signing minor subedit

---------

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-04-12 18:18:57 -08:00
Balduin c970a822a0 refactor(battery_simulator): clean up param SIM_BAT_ENABLE (#26823)
* refactor(battery_simulator): remove SIM_BAT_ENABLE

disable instead with SIM_BAT_DRAIN <= 0

* fix(battery_simulator): disable battery sim only if SIM_BAT_DRAIN strictly < 0

* fix(battery_simulator): disable if 0, adjust limit to 0

* fix(battery_simulator): remove constraining again

now that SIM_BAT_DRAIN=0 means the module is not started we are safe
from division by zero again (param compare has a tolerance of 1e-7)

* fix(battery_simulator): constrain param to min of 1

to avoid division by zero.

This reverts commit 6380c4fdee.

* fix(battery_simulator): remove arbitrary param max

* fix(battery_simulator): reword long param description

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>

* fix(battery_simulator): reword short param description

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>

---------

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
2026-04-12 16:20:46 -08:00
Eurus b9699d3009 fix(ekf2): fix observation_variance unit mismatch in comparison (#27044) 2026-04-12 15:59:50 -08:00
Silvan 557f693246 fix(battery): copy vehicle status states at central place to avoid logic not executed due to previous read
Signed-off-by: Silvan <silvan@auterion.com>
2026-04-10 15:17:45 -06:00
丁勇 ca96106f7d style(PID): remove unnecessary semicolons and ensure proper formatting (#27049) 2026-04-10 14:16:32 -07:00
murata,katsutoshi fc53da51fa refactor(bmp388): refactor variable declaration and initialization
Co-authored-by: Jacob Dahl <dahl.jakejacob@gmail.com>
2026-04-09 15:38:17 -08:00
Ramon Roche 3c5574c051 feat(sih): add propeller model with advance ratio (#26720)
---------

Signed-off-by: romain-chiap <romain.chiap@gmail.com>
Signed-off-by: Ramon Roche <mrpollo@gmail.com>
Co-authored-by: romain-chiap <romain.chiap@gmail.com>
2026-04-08 15:57:17 -07:00
Onur Özkan aaace556cd refactor(offboarding-check): report specific failures (#26938)
Build all targets / Scan for Board Targets (push) Has been cancelled
Build all targets / Build [${{ matrix.runner }}][${{ matrix.group }}] (push) Has been cancelled
Build all targets / Upload Artifacts (push) Has been cancelled
Checks / build (NO_NINJA_BUILD=1 px4_fmu-v5_default) (push) Has been cancelled
Checks / build (NO_NINJA_BUILD=1 px4_sitl_default) (push) Has been cancelled
Checks / build (check_format) (push) Has been cancelled
Checks / build (check_newlines) (push) Has been cancelled
Checks / build (module_documentation) (push) Has been cancelled
Checks / build (px4_fmu-v2_default stack_check) (push) Has been cancelled
Checks / build (px4_sitl_allyes) (push) Has been cancelled
Checks / build (shellcheck_all) (push) Has been cancelled
Checks / build (tests) (push) Has been cancelled
Checks / build (tests_coverage) (push) Has been cancelled
Checks / build (validate_module_configs) (push) Has been cancelled
Static Analysis / Clang-Tidy (push) Has been cancelled
MacOS build / build (px4_fmu-v5_default) (push) Has been cancelled
MacOS build / build (px4_sitl) (push) Has been cancelled
Ubuntu environment build / Build and Test (ubuntu:22.04) (push) Has been cancelled
Ubuntu environment build / Build and Test (ubuntu:24.04) (push) Has been cancelled
Container build / Set Tags and Variables (push) Has been cancelled
Container build / Build Container (amd64) (push) Has been cancelled
Container build / Build Container (arm64) (push) Has been cancelled
Container build / Deploy To Registry (push) Has been cancelled
Docs - Orchestrator / T1: Detect Changes (push) Has been cancelled
Docs - Orchestrator / T2: PR Metadata (push) Has been cancelled
Docs - Orchestrator / T2: Metadata Sync (push) Has been cancelled
Docs - Orchestrator / T2: Link Check (push) Has been cancelled
Docs - Orchestrator / T3: Build Site (push) Has been cancelled
Docs - Orchestrator / T4: Deploy (push) Has been cancelled
Docs - Crowdin - Upload Guide sources (en) / upload-to-crowdin (push) Has been cancelled
EKF Update Change Indicator / unit_tests (push) Has been cancelled
Failsafe Simulator Build / build (failsafe_web) (push) Has been cancelled
FLASH usage analysis / Analyzing px4_fmu-v5x (push) Has been cancelled
FLASH usage analysis / Analyzing px4_fmu-v6x (push) Has been cancelled
FLASH usage analysis / Publish Results (push) Has been cancelled
ITCM check / Checking nxp_mr-tropic (push) Has been cancelled
ITCM check / Checking nxp_tropic-community (push) Has been cancelled
ITCM check / Checking px4_fmu-v5x (push) Has been cancelled
ITCM check / Checking px4_fmu-v6xrt (push) Has been cancelled
MAVROS Mission Tests / build (push) Has been cancelled
MAVROS Offboard Tests / build (push) Has been cancelled
Nuttx Target with extra env config / build (px4_fmu-v5_default) (push) Has been cancelled
Python CI Checks / build (push) Has been cancelled
ROS Integration Tests / build (push) Has been cancelled
ROS Translation Node Tests / Build and test (map[ros_version:humble ubuntu:jammy]) (push) Has been cancelled
ROS Translation Node Tests / Build and test (map[ros_version:jazzy ubuntu:noble]) (push) Has been cancelled
SITL Tests / Testing PX4 iris (push) Has been cancelled
Handle stale issues and PRs / stale (push) Has been cancelled
Fuzzing / Fuzzing (push) Has been cancelled
* offboard: report specific failures

Figuring out offboard failures is quite difficult because the user currently
gets a single, very generic error message that does not identify the actual
missing requirement.

This change aims to improve the user experience by:

- moving offboard failure reporting into OffboardChecks, where the exact cause is known
- reporting specific arming failures for missing local position, local velocity and attitude estimates
- keeping the generic offboard signal error only as a fallback for true signal-loss cases
- removing the duplicate offboard check from ModeChecks (as already invoked by HealthAndArmingChecks)

Signed-off-by: Onur Özkan <work@onurozkan.dev>

* offboard: handle attitude mode in offboard check

Signed-off-by: Onur Özkan <work@onurozkan.dev>

---------

Signed-off-by: Onur Özkan <work@onurozkan.dev>
2026-04-08 08:23:20 -08:00
Claudio Chies 70e31870af feat(params): update max values for various parameters (#27002) 2026-04-08 08:07:47 -08:00
Eric Katzfey 4917b17116 feat(voxl2): Added i2cdetect system command to voxl2-slpi build. Needed to implement the required i2c API for it.
Also, changed the printf into PX4_INFO so the output can be seen for Qurt platforms.
2026-04-08 08:52:25 -07:00
ttechnick 35cbbc1967 fix(fw_attitude_control): use euler angles to construct stabilized setpoint 2026-04-08 15:05:41 +02:00
Onur Özkan 823f033abe refactor(mavlink): extract offboard control mode filling in mavlink receiver
Extract the repeated `offboard_control_mode_s` population logic into a shared
`fill_offboard_control_mode()` helper in MavlinkReceiver and, similar to
`fill_thrust()`, reuse it in both local and global position target handlers.

Reduces the code duplication without changing any behavior.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
2026-04-07 13:04:51 -08:00
Nick c592af7e8e fix(parameters): show board_rot in show-for-airframe (#26989) 2026-04-07 11:48:52 -08:00
Onur Özkan cf517f50d8 docs(control-allocator): clarify torque-triggered setpoint handling
Clarify the unclear intention of how torque and thrust are handled.

Signed-off-by: Onur Özkan <work@onurozkan.dev>
2026-04-07 11:08:09 -08:00
Niklas Hauser 9e0cd2fcf3 Fix mtd command for very small partition sizes of just 32B 2026-04-07 13:42:12 +02:00
Anil Kircaliali 83c41dcf87 refactor(navigator): remove unused parameters from computeReturnAltitude (#26969)
* Remove unused parameters from function signature and make the parameter accessors consistent

* Update the caller function signature

* Update src/modules/navigator/rtl.cpp

---------

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
2026-04-04 11:45:22 -08:00
Jacob Dahl 047fddbcd8 fix(sensors): fix baro publish rate limiter aliasing (#26967)
Use timestamp_sample instead of time_now_us for the rate limiter check
to sync to the sensor clock rather than the wall clock.

Switch from direct timestamp assignment to epoch-advance
(_last_publication_timestamp += interval_us) with a catch-up guard to
prevent aliasing artifacts when the sensor sample rate is close to the
configured publication rate.
2026-04-04 00:02:21 -08:00
Hamish Willee 6f18fa39e8 fix: template_module update to best practise 2026-04-03 21:14:55 -06:00
Pavel Guzenfeld 348a558a15 fix(navigator): correct mission resume waypoint with camera triggering
getPreviousPositionItems() already decrements the start index
internally before searching. The call in on_activation() at line 227
passed _inactivation_index - 1, causing a double-decrement that made
the vehicle resume at waypoint n-2 instead of n-1.

All other call sites (rtl_mission_fast_reverse.cpp:81,
rtl_mission_fast_reverse.cpp:133, mission_base.cpp:1149) pass the
index directly without pre-decrementing.

The bug has been present since commit 007ed11bbe (June 2023).

Closes #26795

Signed-off-by: Pavel Guzenfeld <pavelgu@gmail.com>
2026-04-03 21:10:11 -06:00
Silvan 6597c4680c feat(battery): enable use of BAT_n_I_OVERWRITE for all battery estimation sources
Signed-off-by: Silvan <silvan@auterion.com>
2026-04-03 20:57:05 -06:00
Jacob Dahl 04134dccab fix(uavcan): use node-published timestamps for CAN sensor bridges (#26945)
The FC-side DroneCAN sensor bridges (accel, gyro, rangefinder) used
hrt_absolute_time() in the receive callback as timestamp_sample,
adding ~3-16ms of systematic CAN transport delay.

For messages with a uavcan.Timestamp field, the cannode can publish
the actual sample time via UAVCAN GlobalTimeSync. The RawIMU publisher
already did this for IMU data; apply the same pattern to the range
sensor publisher, and update all three FC bridges to prefer the
message timestamp with a fallback to hrt_absolute_time() for nodes
that don't set it.
2026-04-03 13:08:24 -08:00
Baardrw 115f205cbc docs(gz_bridge): magnetometer device address documentation (#26940)
* fix: added comment explaining why dev id address can only be 3 or 4

* fix: change link to point to main px4 repo

* fix: typo

* formatted

* chore: formatting
2026-04-03 10:31:29 -08:00
Jacob Dahl 9b6e7cb800 fix(ekf2): allow optical flow to start when range finder is height reference (#26960)
When EKF2_HGT_REF=2 (range sensor) with no GPS, optical flow could
never start. The starting condition required isTerrainEstimateValid()
or isHorizontalAidingActive(), but terrain is never "estimated" when
range is the height reference (ground is the datum, terrain state is
fixed at 0), and there's no horizontal aiding without GPS.

HAGL is directly known from the range measurement in this case, so
optical flow has everything it needs to fuse. Add the range height
reference check to the optical flow starting conditions.

Fixes: https://github.com/PX4/PX4-Autopilot/issues/25248
2026-04-02 15:30:24 -08:00
Ramon Roche 1079c57fd0 build(packaging): add PX4 SITL .deb packages
Add cmake/cpack infrastructure for building .deb packages from
px4_sitl_sih and px4_sitl_default targets. Includes install rules,
package scripts, Gazebo wrapper, and CI workflow.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-04-02 15:03:04 -06:00
Marco Hauswirth c8a1a38147 style(ekf2): minor style fixes 2026-04-02 16:20:19 +02:00
Marco Hauswirth 4caee55a76 submodule(mavlink): update to latest mavlink/main to include ESTIMATOR_SENSOR_FUSION_STATUS, MAV_CMD_ESTIMATOR_SENSOR_ENABLE 2026-04-02 16:20:19 +02:00
Marco Hauswirth fffc1b5d04 test(ekf2): sync EkfWrapper with FusionControl enabled flags
EkfWrapper now holds a FusionControl pointer and enables all sensors
by default. Sensor-specific enable methods also set fc.enabled = true.
2026-04-02 16:20:19 +02:00
Marco Hauswirth 6a7e39aa64 feat(mavlink): ESTIMATOR_SENSOR_FUSION_STATUS stream
Add MAVLink stream that maps EstimatorFusionControl uORB message to
ESTIMATOR_SENSOR_FUSION_STATUS, exposing per-sensor intended/active
bitmasks to the GCS.
2026-04-02 16:20:19 +02:00
Marco Hauswirth 6306c78f79 feat(ekf2): EKF2_SENS_EN param, SensEnBit enum, MAVLink fusion command
Add EKF2_SENS_EN bitmask parameter (replaces EKF2_EN_BOOT) with
per-sensor enable bits. initFusionControl reads SENS_EN while disarmed.
handleSensorFusionCommand sets FusionSensor.enabled via
VEHICLE_CMD_ESTIMATOR_SENSOR_ENABLE. syncSensEnParam writes back to
param on disarm. Update EstimatorFusionControl.msg to bool
intended/active fields. Update VehicleCommand.msg FUSION_SOURCE enum.
2026-04-02 16:20:19 +02:00
Marco Hauswirth b9a1c429b3 refactor(ekf2): FusionSensor available/enabled/intended() data model
Split FusionSensor into available (CTRL param != disabled) and enabled
(runtime-toggleable). intended() = enabled && available. EKF core aid
sources now set available themselves and use intended() or _params
directly for CTRL-level checks. Remove drag/imu from FusionControl,
add aspd/rngbcn. Add AGP sourceFusingBitmask() for active-status.
2026-04-02 16:20:19 +02:00
Marco Hauswirth 0dd1640a54 feat(ekf2): enable fusion-ctrl toggle over mavlink cmd, CTRL param act only as reference 2026-04-02 16:20:19 +02:00
Nick 76eca4b7a4 feat(actuators): Control Flaps from AUX channel (#26913)
* feat(rc): flaps via AUX channel

* docs(actuators): add flaps and spoilers from RC

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>

* docs(actuators): Update docs/en/payloads/generic_actuator_control.md

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>

* docs(actuators): move flaps setup docs

---------

Co-authored-by: Silvan Fuhrer <silvan@auterion.com>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
2026-04-02 11:48:44 +02:00
alexcekay 56c69f4c07 fix(mavftp): don't use cache for other sys/comp ids 2026-04-02 11:20:23 +02:00
ttechnick 935a21d05c fix(fw_attitude_control): correct turn coordination 2026-04-02 09:28:44 +02:00
ttechnick d2e3668ad9 fix(fw_attitude_controller): fix typo 2026-04-02 09:28:44 +02:00
Marco Hauswirth 93955bd313 chore(gazebo): update gazebo-classic submodule, remove ranging-beacon from constrained-flash-boards 2026-04-01 15:01:31 +02:00
Marco Hauswirth 65c96fb2bf feat(simulation): add ranging beacon simulation in SIH 2026-04-01 15:01:31 +02:00
Marco Hauswirth f4c820c7e1 feat(ekf2): add ranging beacon fusion support
- Add Symforce-derivation
- No altitude correction
- EKF2 replay
- New params
2026-04-01 15:01:31 +02:00
Marco Hauswirth c260794122 feat(mavlink): add ranging beacon parser and uORB message 2026-04-01 15:01:31 +02:00
Onur Özkan 7d392394dd fix(build): add kconfig support for fortified toolchains 2026-03-31 22:23:50 -08:00
Jacob Dahl a09c76d30d fix(mpl3115a2): correct timestamp_sample to integration midpoint
The MPL3115A2 ADC conversion at OSR 2 (ratio 4) takes ~18ms. The
driver polls until the conversion completes, so the read time is at
the end of the integration window. Correct timestamp_sample to the
midpoint by subtracting CONVERSION_TIME / 2.
2026-03-31 16:37:12 -08:00