mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-22 14:19:57 +08:00
* 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>
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
import math
|
|
|
|
import pytest
|
|
|
|
from autopilot_tester import (
|
|
ACTUATOR_SET_INT_SCALE, INT32_MAX, MAV_CMD_DO_SET_ACTUATOR, MAV_FRAME_MISSION, AutopilotTester)
|
|
|
|
# PWM outputs unused by the SIH quad.
|
|
ACTUATOR5_OUTPUT = 5
|
|
ACTUATOR6_OUTPUT = 6
|
|
|
|
|
|
@pytest.mark.multicopter
|
|
def test_command_int_set_actuator_single_unset_param(tester: AutopilotTester) -> None:
|
|
"""A COMMAND_INT DO_SET_ACTUATOR leaves an actuator unchanged when only its own x/y is unset.
|
|
|
|
Only x and y both unset used to be ignored, so setting just actuator 5 (y = INT32_MAX)
|
|
drove actuator 6 to saturation.
|
|
"""
|
|
tester.wait_until_ready()
|
|
tester.route_actuator_set_to_output(5, ACTUATOR5_OUTPUT)
|
|
tester.route_actuator_set_to_output(6, ACTUATOR6_OUTPUT)
|
|
tester.enable_actuator_output_status()
|
|
tester.arm()
|
|
# Never set, so it outputs its disarmed value.
|
|
actuator6_us = tester.wait_for_actuator_output_value(ACTUATOR6_OUTPUT - 1, 5)
|
|
|
|
actuator5 = 0.5
|
|
tester.send_command_int(MAV_CMD_DO_SET_ACTUATOR, param1=math.nan, param2=math.nan,
|
|
param3=math.nan, param4=math.nan,
|
|
x=round(actuator5 * ACTUATOR_SET_INT_SCALE), y=INT32_MAX, z=0.0,
|
|
frame=MAV_FRAME_MISSION)
|
|
|
|
tester.wait_for_actuator_set_output(ACTUATOR5_OUTPUT, actuator5, 5)
|
|
tester.wait_for_actuator_output(ACTUATOR6_OUTPUT - 1, actuator6_us, 1)
|