mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 05:33:33 +08:00
added an rc switch for arming and disarming with the option to use it as a button
This commit is contained in:
committed by
Lorenz Meier
parent
537f72073d
commit
aa984edd90
@@ -90,6 +90,7 @@ int initialize_parameter_handles(ParameterHandles ¶meter_handles)
|
||||
parameter_handles.rc_map_acro_sw = param_find("RC_MAP_ACRO_SW");
|
||||
parameter_handles.rc_map_offboard_sw = param_find("RC_MAP_OFFB_SW");
|
||||
parameter_handles.rc_map_kill_sw = param_find("RC_MAP_KILL_SW");
|
||||
parameter_handles.rc_map_arm_sw = param_find("RC_MAP_ARM_SW");
|
||||
parameter_handles.rc_map_trans_sw = param_find("RC_MAP_TRANS_SW");
|
||||
parameter_handles.rc_map_gear_sw = param_find("RC_MAP_GEAR_SW");
|
||||
|
||||
@@ -120,6 +121,7 @@ int initialize_parameter_handles(ParameterHandles ¶meter_handles)
|
||||
parameter_handles.rc_acro_th = param_find("RC_ACRO_TH");
|
||||
parameter_handles.rc_offboard_th = param_find("RC_OFFB_TH");
|
||||
parameter_handles.rc_killswitch_th = param_find("RC_KILLSWITCH_TH");
|
||||
parameter_handles.rc_armswitch_th = param_find("RC_ARMSWITCH_TH");
|
||||
parameter_handles.rc_trans_th = param_find("RC_TRANS_TH");
|
||||
parameter_handles.rc_gear_th = param_find("RC_GEAR_TH");
|
||||
|
||||
@@ -313,6 +315,10 @@ int update_parameters(const ParameterHandles ¶meter_handles, Parameters &par
|
||||
PX4_WARN("%s", paramerr);
|
||||
}
|
||||
|
||||
if (param_get(parameter_handles.rc_map_arm_sw, &(parameters.rc_map_arm_sw)) != OK) {
|
||||
PX4_WARN("%s", paramerr);
|
||||
}
|
||||
|
||||
if (param_get(parameter_handles.rc_map_trans_sw, &(parameters.rc_map_trans_sw)) != OK) {
|
||||
PX4_WARN("%s", paramerr);
|
||||
}
|
||||
@@ -365,6 +371,9 @@ int update_parameters(const ParameterHandles ¶meter_handles, Parameters &par
|
||||
param_get(parameter_handles.rc_killswitch_th, &(parameters.rc_killswitch_th));
|
||||
parameters.rc_killswitch_inv = (parameters.rc_killswitch_th < 0);
|
||||
parameters.rc_killswitch_th = fabs(parameters.rc_killswitch_th);
|
||||
param_get(parameter_handles.rc_armswitch_th, &(parameters.rc_armswitch_th));
|
||||
parameters.rc_armswitch_inv = (parameters.rc_armswitch_th < 0);
|
||||
parameters.rc_armswitch_th = fabs(parameters.rc_armswitch_th);
|
||||
param_get(parameter_handles.rc_trans_th, &(parameters.rc_trans_th));
|
||||
parameters.rc_trans_inv = (parameters.rc_trans_th < 0);
|
||||
parameters.rc_trans_th = fabs(parameters.rc_trans_th);
|
||||
|
||||
@@ -83,6 +83,7 @@ struct Parameters {
|
||||
int rc_map_acro_sw;
|
||||
int rc_map_offboard_sw;
|
||||
int rc_map_kill_sw;
|
||||
int rc_map_arm_sw;
|
||||
int rc_map_trans_sw;
|
||||
int rc_map_gear_sw;
|
||||
|
||||
@@ -108,6 +109,7 @@ struct Parameters {
|
||||
float rc_acro_th;
|
||||
float rc_offboard_th;
|
||||
float rc_killswitch_th;
|
||||
float rc_armswitch_th;
|
||||
float rc_trans_th;
|
||||
float rc_gear_th;
|
||||
bool rc_assist_inv;
|
||||
@@ -119,6 +121,7 @@ struct Parameters {
|
||||
bool rc_acro_inv;
|
||||
bool rc_offboard_inv;
|
||||
bool rc_killswitch_inv;
|
||||
bool rc_armswitch_inv;
|
||||
bool rc_trans_inv;
|
||||
bool rc_gear_inv;
|
||||
|
||||
@@ -159,6 +162,7 @@ struct ParameterHandles {
|
||||
param_t rc_map_acro_sw;
|
||||
param_t rc_map_offboard_sw;
|
||||
param_t rc_map_kill_sw;
|
||||
param_t rc_map_arm_sw;
|
||||
param_t rc_map_trans_sw;
|
||||
param_t rc_map_gear_sw;
|
||||
|
||||
@@ -188,6 +192,7 @@ struct ParameterHandles {
|
||||
param_t rc_acro_th;
|
||||
param_t rc_offboard_th;
|
||||
param_t rc_killswitch_th;
|
||||
param_t rc_armswitch_th;
|
||||
param_t rc_trans_th;
|
||||
param_t rc_gear_th;
|
||||
|
||||
|
||||
@@ -414,6 +414,8 @@ RCUpdate::rc_poll(const ParameterHandles ¶meter_handles)
|
||||
_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);
|
||||
manual.arm_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_KILLSWITCH,
|
||||
_parameters.rc_armswitch_th, _parameters.rc_armswitch_inv);
|
||||
manual.transition_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_TRANSITION,
|
||||
_parameters.rc_trans_th, _parameters.rc_trans_inv);
|
||||
manual.gear_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_GEAR,
|
||||
|
||||
@@ -2488,6 +2488,34 @@ PARAM_DEFINE_INT32(RC_MAP_OFFB_SW, 0);
|
||||
*/
|
||||
PARAM_DEFINE_INT32(RC_MAP_KILL_SW, 0);
|
||||
|
||||
/**
|
||||
* Arm switch channel
|
||||
*
|
||||
* @min 0
|
||||
* @max 18
|
||||
* @group Radio Switches
|
||||
* @value 0 Unassigned
|
||||
* @value 1 Channel 1
|
||||
* @value 2 Channel 2
|
||||
* @value 3 Channel 3
|
||||
* @value 4 Channel 4
|
||||
* @value 5 Channel 5
|
||||
* @value 6 Channel 6
|
||||
* @value 7 Channel 7
|
||||
* @value 8 Channel 8
|
||||
* @value 9 Channel 9
|
||||
* @value 10 Channel 10
|
||||
* @value 11 Channel 11
|
||||
* @value 12 Channel 12
|
||||
* @value 13 Channel 13
|
||||
* @value 14 Channel 14
|
||||
* @value 15 Channel 15
|
||||
* @value 16 Channel 16
|
||||
* @value 17 Channel 17
|
||||
* @value 18 Channel 18
|
||||
*/
|
||||
PARAM_DEFINE_INT32(RC_MAP_ARM_SW, 0);
|
||||
|
||||
/**
|
||||
* Flaps channel
|
||||
*
|
||||
@@ -2985,6 +3013,24 @@ PARAM_DEFINE_FLOAT(RC_OFFB_TH, 0.5f);
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(RC_KILLSWITCH_TH, 0.25f);
|
||||
|
||||
/**
|
||||
* Threshold for the arm switch
|
||||
*
|
||||
* 0-1 indicate where in the full channel range the threshold sits
|
||||
* 0 : min
|
||||
* 1 : max
|
||||
* sign indicates polarity of comparison
|
||||
* positive : true when channel>th
|
||||
* negative : true when channel<th
|
||||
*
|
||||
* @min -1
|
||||
* @max 1
|
||||
* @group Radio Switches
|
||||
*
|
||||
*
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(RC_ARMSWITCH_TH, 0.25f);
|
||||
|
||||
/**
|
||||
* Threshold for the VTOL transition switch
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user