mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 15:08:16 +08:00
dshot: add 3D capability
This commit is contained in:
@@ -530,11 +530,27 @@ bool DShot::updateOutputs(bool stop_motors, uint16_t outputs[MAX_ACTUATORS],
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < (int)num_outputs; i++) {
|
for (int i = 0; i < (int)num_outputs; i++) {
|
||||||
if (outputs[i] == DSHOT_DISARM_VALUE) {
|
|
||||||
|
uint16_t output = outputs[i];
|
||||||
|
|
||||||
|
// DShot 3D splits the throttle ranges in two.
|
||||||
|
// 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 (_param_dshot_3d_enable.get()) {
|
||||||
|
if (output >= _param_dshot_3d_dead_l.get() && output <= _param_dshot_3d_dead_h.get()) {
|
||||||
|
output = DSHOT_DISARM_VALUE;
|
||||||
|
|
||||||
|
} else if (output < 1000 && output > 0) { //Todo: allow actuator 0 or dshot 48 to be used
|
||||||
|
output = 999 - output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (output == DSHOT_DISARM_VALUE) {
|
||||||
up_dshot_motor_command(i, DShot_cmd_motor_stop, i == requested_telemetry_index);
|
up_dshot_motor_command(i, DShot_cmd_motor_stop, i == requested_telemetry_index);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
up_dshot_motor_data_set(i, math::min(outputs[i], static_cast<uint16_t>(DSHOT_MAX_THROTTLE)),
|
up_dshot_motor_data_set(i, math::min(output, static_cast<uint16_t>(DSHOT_MAX_THROTTLE)),
|
||||||
i == requested_telemetry_index);
|
i == requested_telemetry_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,6 +231,9 @@ private:
|
|||||||
DEFINE_PARAMETERS(
|
DEFINE_PARAMETERS(
|
||||||
(ParamInt<px4::params::DSHOT_CONFIG>) _param_dshot_config,
|
(ParamInt<px4::params::DSHOT_CONFIG>) _param_dshot_config,
|
||||||
(ParamFloat<px4::params::DSHOT_MIN>) _param_dshot_min,
|
(ParamFloat<px4::params::DSHOT_MIN>) _param_dshot_min,
|
||||||
|
(ParamBool<px4::params::DSHOT_3D_ENABLE>) _param_dshot_3d_enable,
|
||||||
|
(ParamInt<px4::params::DSHOT_3D_DEAD_H>) _param_dshot_3d_dead_h,
|
||||||
|
(ParamInt<px4::params::DSHOT_3D_DEAD_L>) _param_dshot_3d_dead_l,
|
||||||
(ParamInt<px4::params::MOT_POLE_COUNT>) _param_mot_pole_count
|
(ParamInt<px4::params::MOT_POLE_COUNT>) _param_mot_pole_count
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -40,6 +40,37 @@ parameters:
|
|||||||
decimal: 2
|
decimal: 2
|
||||||
increment: 0.01
|
increment: 0.01
|
||||||
default: 0.055
|
default: 0.055
|
||||||
|
DSHOT_3D_ENABLE:
|
||||||
|
description:
|
||||||
|
short: Allows for 3d mode when using DShot and suitable mixer
|
||||||
|
long: |
|
||||||
|
WARNING: ESC must be configured for 3D mode, and DSHOT_MIN set to 0.
|
||||||
|
This splits the throttle ranges in two.
|
||||||
|
Direction 1) 48 is the slowest, 1047 is the fastest.
|
||||||
|
Direction 2) 1049 is the slowest, 2047 is the fastest.
|
||||||
|
When mixer outputs 1000 or value inside DSHOT 3D deadband, DShot 0 is sent.
|
||||||
|
type: boolean
|
||||||
|
default: 0
|
||||||
|
DSHOT_3D_DEAD_H:
|
||||||
|
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.
|
||||||
|
This value is with respect to the mixer_module range (0-1999), not the DSHOT values.
|
||||||
|
type: int32
|
||||||
|
min: 1000
|
||||||
|
max: 1999
|
||||||
|
default: 1000
|
||||||
|
DSHOT_3D_DEAD_L:
|
||||||
|
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.
|
||||||
|
This value is with respect to the mixer_module range (0-1999), not the DSHOT values.
|
||||||
|
type: int32
|
||||||
|
min: 0
|
||||||
|
max: 1000
|
||||||
|
default: 1000
|
||||||
MOT_POLE_COUNT: # only used by dshot so far, so keep it under the dshot group
|
MOT_POLE_COUNT: # only used by dshot so far, so keep it under the dshot group
|
||||||
description:
|
description:
|
||||||
short: Number of magnetic poles of the motors
|
short: Number of magnetic poles of the motors
|
||||||
@@ -51,4 +82,3 @@ parameters:
|
|||||||
Typical motors for 5 inch props have 14 poles.
|
Typical motors for 5 inch props have 14 poles.
|
||||||
type: int32
|
type: int32
|
||||||
default: 14
|
default: 14
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user