mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 00:53:34 +08:00
manual_contol_setpoint: fix mode slot numbering (#12578)
* This fix is necessary because usually uORB structs get initialized with all zeros and then get filled with the fields that are actually in use. * The number 0 for the mode slot was already commanding to switch to the mode in slot one even though for example the joystick input via mavlink does not use this mechanism at all.
This commit is contained in:
committed by
Daniel Agar
parent
5d986f2030
commit
d0f1a551e9
@@ -350,9 +350,8 @@ RCUpdate::rc_poll(const ParameterHandles ¶meter_handles)
|
||||
manual.z = math::constrain(_filter_throttle.apply(manual.z), 0.f, 1.f);
|
||||
|
||||
if (_parameters.rc_map_flightmode > 0) {
|
||||
|
||||
/* the number of valid slots equals the index of the max marker minus one */
|
||||
const int num_slots = manual_control_setpoint_s::MODE_SLOT_MAX;
|
||||
/* number of valid slots */
|
||||
const int num_slots = manual_control_setpoint_s::MODE_SLOT_NUM;
|
||||
|
||||
/* the half width of the range of a slot is the total range
|
||||
* divided by the number of slots, again divided by two
|
||||
@@ -369,10 +368,10 @@ RCUpdate::rc_poll(const ParameterHandles ¶meter_handles)
|
||||
* will take us to the correct final index.
|
||||
*/
|
||||
manual.mode_slot = (((((_rc.channels[_parameters.rc_map_flightmode - 1] - slot_min) * num_slots) + slot_width_half) /
|
||||
(slot_max - slot_min)) + (1.0f / num_slots));
|
||||
(slot_max - slot_min)) + (1.0f / num_slots)) + 1;
|
||||
|
||||
if (manual.mode_slot >= num_slots) {
|
||||
manual.mode_slot = num_slots - 1;
|
||||
if (manual.mode_slot > num_slots) {
|
||||
manual.mode_slot = num_slots;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user