mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-22 14:24:21 +08:00
fix(dshot): 3D mode deadzone disarm + inclusive deadband (#26685)
* fix(dshot): send motor stop for 3D mode deadzone instead of min throttle In DShot 3D mode, convert_output_to_3d_scaling() returns DSHOT_DISARM_VALUE (0) for deadzone inputs. But up_dshot_motor_data_set() adds the MIN_throttle offset (+48), causing motors to spin at minimum throttle instead of stopping. Check the result of calculate_output_value() for DSHOT_DISARM_VALUE and send an explicit motor stop command, bypassing the +48 offset. * fix(dshot): make 3D deadband inclusive on both ends Change the 3D deadband check from [L, H) to [L, H] so that setting DSHOT_3D_DEAD_L equal to DSHOT_3D_DEAD_H (both default to 1000) produces a single-point deadband at that value, matching the natural reading of "between L and H" in the param description. Clarify the DSHOT_3D_DEAD_L/H param descriptions to state the range is inclusive and note the L=H default behavior.
This commit is contained in:
@@ -368,7 +368,15 @@ void DShot::update_motor_outputs(uint16_t outputs[MAX_ACTUATORS], int num_output
|
||||
up_dshot_motor_command(i, DSHOT_CMD_MOTOR_STOP, set_telemetry_bit);
|
||||
|
||||
} else {
|
||||
up_dshot_motor_data_set(i, calculate_output_value(outputs[i], i), set_telemetry_bit);
|
||||
uint16_t output = calculate_output_value(outputs[i], i);
|
||||
|
||||
// 3D deadzone: send motor stop to avoid MIN_throttle offset in up_dshot_motor_data_set
|
||||
if (output == DSHOT_DISARM_VALUE) {
|
||||
up_dshot_motor_command(i, DSHOT_CMD_MOTOR_STOP, set_telemetry_bit);
|
||||
|
||||
} else {
|
||||
up_dshot_motor_data_set(i, output, set_telemetry_bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -749,7 +757,7 @@ uint16_t DShot::convert_output_to_3d_scaling(uint16_t output)
|
||||
// This is in terms of DShot values, code below is in terms of actuator_output
|
||||
// Direction 1) 48 is the slowest, 1047 is the fastest.
|
||||
// Direction 2) 1049 is the slowest, 2047 is the fastest.
|
||||
if (output >= _3d_dead_l && output < _3d_dead_h) {
|
||||
if (output >= _3d_dead_l && output <= _3d_dead_h) {
|
||||
return DSHOT_DISARM_VALUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ parameters:
|
||||
description:
|
||||
short: DSHOT 3D deadband high
|
||||
long: |
|
||||
When the actuator_output is between DSHOT_3D_DEAD_L and DSHOT_3D_DEAD_H, motor will not spin.
|
||||
When the actuator_output is in the inclusive range [DSHOT_3D_DEAD_L, DSHOT_3D_DEAD_H], the motor will not spin.
|
||||
Setting DSHOT_3D_DEAD_L equal to DSHOT_3D_DEAD_H (e.g. the default 1000) produces a single-point deadband at that value.
|
||||
This value is with respect to the mixer_module range (0-1999), not the DSHOT values.
|
||||
type: int32
|
||||
min: 1000
|
||||
@@ -66,7 +67,8 @@ parameters:
|
||||
description:
|
||||
short: DSHOT 3D deadband low
|
||||
long: |
|
||||
When the actuator_output is between DSHOT_3D_DEAD_L and DSHOT_3D_DEAD_H, motor will not spin.
|
||||
When the actuator_output is in the inclusive range [DSHOT_3D_DEAD_L, DSHOT_3D_DEAD_H], the motor will not spin.
|
||||
Setting DSHOT_3D_DEAD_L equal to DSHOT_3D_DEAD_H (e.g. the default 1000) produces a single-point deadband at that value.
|
||||
This value is with respect to the mixer_module range (0-1999), not the DSHOT values.
|
||||
type: int32
|
||||
min: 0
|
||||
|
||||
Reference in New Issue
Block a user