2 Commits
Author SHA1 Message Date
Mahima Yoga 8e7b370cde fix(mavlink): accept INT32_MIN as "param not used" in mission item validation (#28079)
Build all targets / Scan for Board Targets (push) Canceled after 0s
Checks / Gate Checks [check_format] (push) Canceled after 0s
Checks / Gate Checks [check_newlines] (push) Canceled after 0s
Checks / Gate Checks [module_documentation] (push) Canceled after 0s
Checks / Gate Checks [shellcheck_all] (push) Canceled after 0s
Checks / Gate Checks [validate_module_configs] (push) Canceled after 0s
Checks / Unit Tests (push) Canceled after 0s
MacOS build / build (push) Canceled after 0s
Ubuntu environment build / Build and Test (ubuntu:22.04) (push) Canceled after 0s
Ubuntu environment build / Build and Test (ubuntu:24.04) (push) Canceled after 0s
Container build / Set Tags and Variables (push) Canceled after 0s
Docs - Orchestrator / T1: Detect Changes (push) Canceled after 0s
Docs - Orchestrator / T2: Metadata Sync (push) Canceled after 0s
Failsafe Simulator Build / build (failsafe_web) (push) Canceled after 0s
FLASH usage analysis / Analyzing px4_fmu-v5x (push) Canceled after 0s
FLASH usage analysis / Analyzing px4_fmu-v6x (push) Canceled after 0s
ITCM check / Checking nxp_mr-tropic (push) Canceled after 0s
ITCM check / Checking nxp_tropic-community (push) Canceled after 0s
ITCM check / Checking px4_fmu-v5x (push) Canceled after 0s
ITCM check / Checking px4_fmu-v6xrt (push) Canceled after 0s
Python CI Checks / build (push) Canceled after 0s
ROS Integration Tests / build (push) Canceled after 0s
ROS Translation Node Tests / Build and test [humble] (push) Canceled after 0s
ROS Translation Node Tests / Build and test [jazzy] (push) Canceled after 0s
SITL Tests / Testing PX4 quadx (push) Canceled after 0s
SITL Tests / Testing PX4 standard_vtol (push) Canceled after 0s
Build all targets / Seed [${{ matrix.chip_family }}] (push) Canceled after 0s
Build all targets / Build [${{ matrix.runner }}][${{ matrix.group }}] (push) Canceled after 0s
Build all targets / Upload Artifacts (push) Canceled after 0s
Container build / Build Container (amd64) (push) Canceled after 0s
Container build / Build Container (arm64) (push) Canceled after 0s
Container build / Deploy To Registry (push) Canceled after 0s
Docs - Orchestrator / T2: PR Metadata (push) Canceled after 0s
Docs - Orchestrator / T2: Link Check (push) Canceled after 0s
Docs - Orchestrator / T3: Build Site (push) Canceled after 0s
Docs - Orchestrator / T4: Deploy (push) Canceled after 0s
FLASH usage analysis / Publish Results (push) Canceled after 0s
Static Analysis / Clang-Tidy (push) Canceled after 0s
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
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