mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
added transition switch
This commit is contained in:
parent
302719527a
commit
499d362b8b
@ -51,4 +51,5 @@ uint8 loiter_switch # loiter 2 position switch (optional): _MISSION_, LOITER
|
||||
uint8 acro_switch # acro 2 position switch (optional): _MANUAL_, ACRO
|
||||
uint8 offboard_switch # offboard 2 position switch (optional): _NORMAL_, OFFBOARD
|
||||
uint8 kill_switch # throttle kill: _NORMAL_, KILL
|
||||
uint8 transition_switch # VTOL transition switch: _HOVER, FORWARD_FLIGHT
|
||||
int8 mode_slot # the slot a specific model selector is in
|
||||
|
||||
@ -20,11 +20,12 @@ uint8 RC_CHANNELS_FUNCTION_PARAM_2=17
|
||||
uint8 RC_CHANNELS_FUNCTION_PARAM_3_5=18
|
||||
uint8 RC_CHANNELS_FUNCTION_RATTITUDE=19
|
||||
uint8 RC_CHANNELS_FUNCTION_KILLSWITCH=20
|
||||
uint8 RC_CHANNELS_FUNCTION_TRANSITION=21
|
||||
|
||||
uint64 timestamp_last_valid # Timestamp of last valid RC signal
|
||||
float32[18] channels # Scaled to -1..1 (throttle: 0..1)
|
||||
uint8 channel_count # Number of valid channels
|
||||
int8[21] function # Functions mapping
|
||||
int8[22] function # Functions mapping
|
||||
uint8 rssi # Receive signal strength indicator (0-100)
|
||||
bool signal_lost # Control signal lost, should be checked together with topic timeout
|
||||
uint32 frame_drop_count # Number of dropped frames
|
||||
|
||||
@ -2516,6 +2516,34 @@ PARAM_DEFINE_INT32(RC_MAP_KILL_SW, 0);
|
||||
*/
|
||||
PARAM_DEFINE_INT32(RC_MAP_FLAPS, 0);
|
||||
|
||||
/**
|
||||
* VTOL transition switch channel mapping
|
||||
*
|
||||
* @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_TRANS_SW, 0);
|
||||
|
||||
/**
|
||||
* AUX1 Passthrough RC Channel
|
||||
*
|
||||
@ -2930,6 +2958,24 @@ PARAM_DEFINE_FLOAT(RC_OFFB_TH, 0.5f);
|
||||
*/
|
||||
PARAM_DEFINE_FLOAT(RC_KILLSWITCH_TH, 0.25f);
|
||||
|
||||
/**
|
||||
* Threshold for the VTOL transition 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_TRANS_TH, 0.25f);
|
||||
|
||||
/**
|
||||
* PWM input channel that provides RSSI.
|
||||
*
|
||||
|
||||
@ -305,6 +305,7 @@ private:
|
||||
int rc_map_acro_sw;
|
||||
int rc_map_offboard_sw;
|
||||
int rc_map_kill_sw;
|
||||
int rc_map_trans_sw;
|
||||
|
||||
int rc_map_flaps;
|
||||
|
||||
@ -328,6 +329,7 @@ private:
|
||||
float rc_acro_th;
|
||||
float rc_offboard_th;
|
||||
float rc_killswitch_th;
|
||||
float rc_trans_th;
|
||||
bool rc_assist_inv;
|
||||
bool rc_auto_inv;
|
||||
bool rc_rattitude_inv;
|
||||
@ -337,6 +339,7 @@ private:
|
||||
bool rc_acro_inv;
|
||||
bool rc_offboard_inv;
|
||||
bool rc_killswitch_inv;
|
||||
bool rc_trans_inv;
|
||||
|
||||
float battery_voltage_scaling;
|
||||
float battery_current_scaling;
|
||||
@ -375,6 +378,7 @@ private:
|
||||
param_t rc_map_acro_sw;
|
||||
param_t rc_map_offboard_sw;
|
||||
param_t rc_map_kill_sw;
|
||||
param_t rc_map_trans_sw;
|
||||
|
||||
param_t rc_map_flaps;
|
||||
|
||||
@ -402,6 +406,7 @@ private:
|
||||
param_t rc_acro_th;
|
||||
param_t rc_offboard_th;
|
||||
param_t rc_killswitch_th;
|
||||
param_t rc_trans_th;
|
||||
|
||||
param_t battery_voltage_scaling;
|
||||
param_t battery_current_scaling;
|
||||
@ -650,6 +655,7 @@ Sensors::Sensors() :
|
||||
_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_trans_sw = param_find("RC_MAP_TRANS_SW");
|
||||
|
||||
_parameter_handles.rc_map_aux1 = param_find("RC_MAP_AUX1");
|
||||
_parameter_handles.rc_map_aux2 = param_find("RC_MAP_AUX2");
|
||||
@ -678,6 +684,8 @@ Sensors::Sensors() :
|
||||
_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_trans_th = param_find("RC_TRANS_TH");
|
||||
|
||||
|
||||
/* Differential pressure offset */
|
||||
_parameter_handles.diff_pres_offset_pa = param_find("SENS_DPRES_OFF");
|
||||
@ -850,6 +858,10 @@ Sensors::parameters_update()
|
||||
PX4_WARN("%s", paramerr);
|
||||
}
|
||||
|
||||
if (param_get(_parameter_handles.rc_map_trans_sw, &(_parameters.rc_map_trans_sw)) != OK) {
|
||||
warnx("%s", paramerr);
|
||||
}
|
||||
|
||||
if (param_get(_parameter_handles.rc_map_flaps, &(_parameters.rc_map_flaps)) != OK) {
|
||||
PX4_WARN("%s", paramerr);
|
||||
}
|
||||
@ -894,6 +906,9 @@ Sensors::parameters_update()
|
||||
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_trans_th, &(_parameters.rc_trans_th));
|
||||
_parameters.rc_trans_inv = (_parameters.rc_trans_th < 0);
|
||||
_parameters.rc_trans_th = fabs(_parameters.rc_trans_th);
|
||||
|
||||
/* update RC function mappings */
|
||||
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_THROTTLE] = _parameters.rc_map_throttle - 1;
|
||||
@ -909,6 +924,7 @@ Sensors::parameters_update()
|
||||
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_ACRO] = _parameters.rc_map_acro_sw - 1;
|
||||
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_OFFBOARD] = _parameters.rc_map_offboard_sw - 1;
|
||||
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_KILLSWITCH] = _parameters.rc_map_kill_sw - 1;
|
||||
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_TRANSITION] = _parameters.rc_map_trans_sw - 1;
|
||||
|
||||
_rc.function[rc_channels_s::RC_CHANNELS_FUNCTION_FLAPS] = _parameters.rc_map_flaps - 1;
|
||||
|
||||
@ -2112,6 +2128,8 @@ Sensors::rc_poll()
|
||||
_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.transition_switch = get_rc_sw2pos_position(rc_channels_s::RC_CHANNELS_FUNCTION_TRANSITION,
|
||||
_parameters.rc_trans_th, _parameters.rc_trans_inv);
|
||||
|
||||
/* publish manual_control_setpoint topic */
|
||||
if (_manual_control_pub != nullptr) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user