|
|
|
@ -298,6 +298,8 @@ private:
@@ -298,6 +298,8 @@ private:
|
|
|
|
|
|
|
|
|
|
int rc_map_param[rc_parameter_map_s::RC_PARAM_MAP_NCHAN]; |
|
|
|
|
|
|
|
|
|
int rc_map_flightmode; |
|
|
|
|
|
|
|
|
|
int32_t rc_fails_thr; |
|
|
|
|
float rc_assist_th; |
|
|
|
|
float rc_auto_th; |
|
|
|
@ -364,6 +366,8 @@ private:
@@ -364,6 +366,8 @@ private:
|
|
|
|
|
_parameters struct are not existing |
|
|
|
|
because these parameters are never read. */ |
|
|
|
|
|
|
|
|
|
param_t rc_map_flightmode; |
|
|
|
|
|
|
|
|
|
param_t rc_fails_thr; |
|
|
|
|
param_t rc_assist_th; |
|
|
|
|
param_t rc_auto_th; |
|
|
|
@ -600,6 +604,8 @@ Sensors::Sensors() :
@@ -600,6 +604,8 @@ Sensors::Sensors() :
|
|
|
|
|
_parameter_handles.rc_map_param[i] = param_find(name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_parameter_handles.rc_map_flightmode = param_find("RC_MAP_FLTMODE"); |
|
|
|
|
|
|
|
|
|
/* RC thresholds */ |
|
|
|
|
_parameter_handles.rc_fails_thr = param_find("RC_FAILS_THR"); |
|
|
|
|
_parameter_handles.rc_assist_th = param_find("RC_ASSIST_TH"); |
|
|
|
@ -790,6 +796,8 @@ Sensors::parameters_update()
@@ -790,6 +796,8 @@ Sensors::parameters_update()
|
|
|
|
|
param_get(_parameter_handles.rc_map_param[i], &(_parameters.rc_map_param[i])); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
param_get(_parameter_handles.rc_map_flightmode, &(_parameters.rc_map_flightmode)); |
|
|
|
|
|
|
|
|
|
param_get(_parameter_handles.rc_fails_thr, &(_parameters.rc_fails_thr)); |
|
|
|
|
param_get(_parameter_handles.rc_assist_th, &(_parameters.rc_assist_th)); |
|
|
|
|
_parameters.rc_assist_inv = (_parameters.rc_assist_th < 0); |
|
|
|
@ -1870,8 +1878,7 @@ Sensors::rc_poll()
@@ -1870,8 +1878,7 @@ Sensors::rc_poll()
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!signal_lost) { |
|
|
|
|
struct manual_control_setpoint_s manual; |
|
|
|
|
memset(&manual, 0 , sizeof(manual)); |
|
|
|
|
struct manual_control_setpoint_s manual = {}; |
|
|
|
|
|
|
|
|
|
/* fill values in manual_control_setpoint topic only if signal is valid */ |
|
|
|
|
manual.timestamp = rc_input.timestamp_last_signal; |
|
|
|
@ -1888,24 +1895,34 @@ Sensors::rc_poll()
@@ -1888,24 +1895,34 @@ Sensors::rc_poll()
|
|
|
|
|
manual.aux4 = get_rc_value(rc_channels_s::RC_CHANNELS_FUNCTION_AUX_4, -1.0, 1.0); |
|
|
|
|
manual.aux5 = get_rc_value(rc_channels_s::RC_CHANNELS_FUNCTION_AUX_5, -1.0, 1.0); |
|
|
|
|
|
|
|
|
|
/* mode switches */ |
|
|
|
|
manual.mode_switch = get_rc_sw3pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_MODE, _parameters.rc_auto_th, |
|
|
|
|
_parameters.rc_auto_inv, _parameters.rc_assist_th, _parameters.rc_assist_inv); |
|
|
|
|
manual.rattitude_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_RATTITUDE, |
|
|
|
|
_parameters.rc_rattitude_th, |
|
|
|
|
_parameters.rc_rattitude_inv); |
|
|
|
|
manual.posctl_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_POSCTL, _parameters.rc_posctl_th, |
|
|
|
|
_parameters.rc_posctl_inv); |
|
|
|
|
manual.return_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_RETURN, _parameters.rc_return_th, |
|
|
|
|
_parameters.rc_return_inv); |
|
|
|
|
manual.loiter_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_LOITER, _parameters.rc_loiter_th, |
|
|
|
|
_parameters.rc_loiter_inv); |
|
|
|
|
manual.acro_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_ACRO, _parameters.rc_acro_th, |
|
|
|
|
_parameters.rc_acro_inv); |
|
|
|
|
manual.offboard_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_OFFBOARD, |
|
|
|
|
_parameters.rc_offboard_th, _parameters.rc_offboard_inv); |
|
|
|
|
manual.kill_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_KILLSWITCH, |
|
|
|
|
_parameters.rc_killswitch_th, _parameters.rc_killswitch_inv); |
|
|
|
|
if (_parameters.rc_map_flightmode > 0) { |
|
|
|
|
|
|
|
|
|
const unsigned slot_min = 1000; |
|
|
|
|
const unsigned slot_max = 2000; |
|
|
|
|
const unsigned num_slots = 6; |
|
|
|
|
|
|
|
|
|
manual.mode_slot = ((_rc.channels[_parameters.rc_map_flightmode - 1] - slot_min) * num_slots) / (slot_max - slot_min); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
/* mode switches */ |
|
|
|
|
manual.mode_switch = get_rc_sw3pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_MODE, _parameters.rc_auto_th, |
|
|
|
|
_parameters.rc_auto_inv, _parameters.rc_assist_th, _parameters.rc_assist_inv); |
|
|
|
|
manual.rattitude_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_RATTITUDE, |
|
|
|
|
_parameters.rc_rattitude_th, |
|
|
|
|
_parameters.rc_rattitude_inv); |
|
|
|
|
manual.posctl_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_POSCTL, _parameters.rc_posctl_th, |
|
|
|
|
_parameters.rc_posctl_inv); |
|
|
|
|
manual.return_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_RETURN, _parameters.rc_return_th, |
|
|
|
|
_parameters.rc_return_inv); |
|
|
|
|
manual.loiter_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_LOITER, _parameters.rc_loiter_th, |
|
|
|
|
_parameters.rc_loiter_inv); |
|
|
|
|
manual.acro_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_ACRO, _parameters.rc_acro_th, |
|
|
|
|
_parameters.rc_acro_inv); |
|
|
|
|
manual.offboard_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_OFFBOARD, |
|
|
|
|
_parameters.rc_offboard_th, _parameters.rc_offboard_inv); |
|
|
|
|
manual.kill_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_KILLSWITCH, |
|
|
|
|
_parameters.rc_killswitch_th, _parameters.rc_killswitch_inv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* publish manual_control_setpoint topic */ |
|
|
|
|
if (_manual_control_pub != nullptr) { |
|
|
|
|