sensors: ASSISTED switch channel added

This commit is contained in:
Anton Babushkin 2013-07-22 22:37:10 +04:00
parent 963abd66ba
commit 55fd19f281
3 changed files with 28 additions and 11 deletions

View File

@ -167,6 +167,7 @@ PARAM_DEFINE_INT32(RC_MAP_YAW, 4);
PARAM_DEFINE_INT32(RC_MAP_MODE_SW, 5); PARAM_DEFINE_INT32(RC_MAP_MODE_SW, 5);
PARAM_DEFINE_INT32(RC_MAP_RETURN_SW, 6); PARAM_DEFINE_INT32(RC_MAP_RETURN_SW, 6);
PARAM_DEFINE_INT32(RC_MAP_ASSIST_SW, 0);
PARAM_DEFINE_INT32(RC_MAP_MISSIO_SW, 0); PARAM_DEFINE_INT32(RC_MAP_MISSIO_SW, 0);
//PARAM_DEFINE_INT32(RC_MAP_OFFB_SW, 0); //PARAM_DEFINE_INT32(RC_MAP_OFFB_SW, 0);

View File

@ -208,6 +208,7 @@ private:
int rc_map_mode_sw; int rc_map_mode_sw;
int rc_map_return_sw; int rc_map_return_sw;
int rc_map_assisted_sw;
int rc_map_mission_sw; int rc_map_mission_sw;
// int rc_map_offboard_ctrl_mode_sw; // int rc_map_offboard_ctrl_mode_sw;
@ -256,6 +257,7 @@ private:
param_t rc_map_mode_sw; param_t rc_map_mode_sw;
param_t rc_map_return_sw; param_t rc_map_return_sw;
param_t rc_map_assisted_sw;
param_t rc_map_mission_sw; param_t rc_map_mission_sw;
// param_t rc_map_offboard_ctrl_mode_sw; // param_t rc_map_offboard_ctrl_mode_sw;
@ -464,6 +466,7 @@ Sensors::Sensors() :
_parameter_handles.rc_map_flaps = param_find("RC_MAP_FLAPS"); _parameter_handles.rc_map_flaps = param_find("RC_MAP_FLAPS");
/* optional mode switches, not mapped per default */ /* optional mode switches, not mapped per default */
_parameter_handles.rc_map_assisted_sw = param_find("RC_MAP_ASSIST_SW");
_parameter_handles.rc_map_mission_sw = param_find("RC_MAP_MISSIO_SW"); _parameter_handles.rc_map_mission_sw = param_find("RC_MAP_MISSIO_SW");
// _parameter_handles.rc_map_offboard_ctrl_mode_sw = param_find("RC_MAP_OFFB_SW"); // _parameter_handles.rc_map_offboard_ctrl_mode_sw = param_find("RC_MAP_OFFB_SW");
@ -617,6 +620,10 @@ Sensors::parameters_update()
warnx("Failed getting return sw chan index"); warnx("Failed getting return sw chan index");
} }
if (param_get(_parameter_handles.rc_map_assisted_sw, &(_parameters.rc_map_assisted_sw)) != OK) {
warnx("Failed getting assisted sw chan index");
}
if (param_get(_parameter_handles.rc_map_mission_sw, &(_parameters.rc_map_mission_sw)) != OK) { if (param_get(_parameter_handles.rc_map_mission_sw, &(_parameters.rc_map_mission_sw)) != OK) {
warnx("Failed getting mission sw chan index"); warnx("Failed getting mission sw chan index");
} }
@ -673,6 +680,7 @@ Sensors::parameters_update()
_rc.function[MODE] = _parameters.rc_map_mode_sw - 1; _rc.function[MODE] = _parameters.rc_map_mode_sw - 1;
_rc.function[RETURN] = _parameters.rc_map_return_sw - 1; _rc.function[RETURN] = _parameters.rc_map_return_sw - 1;
_rc.function[ASSISTED] = _parameters.rc_map_assisted_sw - 1;
_rc.function[MISSION] = _parameters.rc_map_mission_sw - 1; _rc.function[MISSION] = _parameters.rc_map_mission_sw - 1;
_rc.function[FLAPS] = _parameters.rc_map_flaps - 1; _rc.function[FLAPS] = _parameters.rc_map_flaps - 1;
@ -1142,6 +1150,7 @@ Sensors::ppm_poll()
manual_control.mode_switch = NAN; manual_control.mode_switch = NAN;
manual_control.return_switch = NAN; manual_control.return_switch = NAN;
manual_control.assisted_switch = NAN;
manual_control.mission_switch = NAN; manual_control.mission_switch = NAN;
// manual_control.auto_offboard_input_switch = NAN; // manual_control.auto_offboard_input_switch = NAN;
@ -1249,7 +1258,10 @@ Sensors::ppm_poll()
/* land switch input */ /* land switch input */
manual_control.return_switch = limit_minus_one_to_one(_rc.chan[_rc.function[RETURN]].scaled); manual_control.return_switch = limit_minus_one_to_one(_rc.chan[_rc.function[RETURN]].scaled);
/* land switch input */ /* assisted switch input */
manual_control.assisted_switch = limit_minus_one_to_one(_rc.chan[_rc.function[ASSISTED]].scaled);
/* mission switch input */
manual_control.mission_switch = limit_minus_one_to_one(_rc.chan[_rc.function[MISSION]].scaled); manual_control.mission_switch = limit_minus_one_to_one(_rc.chan[_rc.function[MISSION]].scaled);
/* flaps */ /* flaps */

View File

@ -53,9 +53,12 @@
/** /**
* The number of RC channel inputs supported. * The number of RC channel inputs supported.
* Current (Q1/2013) radios support up to 18 channels, * Current (Q1/2013) radios support up to 18 channels,
* leaving at a sane value of 14. * leaving at a sane value of 15.
* This number can be greater then number of RC channels,
* because single RC channel can be mapped to multiple
* functions, e.g. for various mode switches.
*/ */
#define RC_CHANNELS_MAX 14 #define RC_CHANNELS_MAX 15
/** /**
* This defines the mapping of the RC functions. * This defines the mapping of the RC functions.
@ -70,14 +73,15 @@ enum RC_CHANNELS_FUNCTION
YAW = 3, YAW = 3,
MODE = 4, MODE = 4,
RETURN = 5, RETURN = 5,
MISSION = 6, ASSISTED = 6,
OFFBOARD_MODE = 7, MISSION = 7,
FLAPS = 8, OFFBOARD_MODE = 8,
AUX_1 = 9, FLAPS = 9,
AUX_2 = 10, AUX_1 = 10,
AUX_3 = 11, AUX_2 = 11,
AUX_4 = 12, AUX_3 = 12,
AUX_5 = 13, AUX_4 = 13,
AUX_5 = 14,
RC_CHANNELS_FUNCTION_MAX /**< indicates the number of functions. There can be more functions than RC channels. */ RC_CHANNELS_FUNCTION_MAX /**< indicates the number of functions. There can be more functions than RC channels. */
}; };