Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RC_Channel: TECS propulsion failure aux func #25644

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions ArduPlane/RC_Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ void RC_Channel_Plane::do_aux_function_flare(AuxSwitchPos ch_flag)
}
}

#if AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
void RC_Channel_Plane::do_aux_function_propulsion_failed(AuxSwitchPos ch_flag)
{
switch(ch_flag) {
case AuxSwitchPos::HIGH:
plane.TECS_controller.set_propulsion_failed_flag(true);
break;
case AuxSwitchPos::MIDDLE:
break;
case AuxSwitchPos::LOW:
plane.TECS_controller.set_propulsion_failed_flag(false);
break;
}
}
#endif

void RC_Channel_Plane::init_aux_function(const RC_Channel::AUX_FUNC ch_option,
const RC_Channel::AuxSwitchPos ch_flag)
Expand Down Expand Up @@ -178,6 +193,9 @@ void RC_Channel_Plane::init_aux_function(const RC_Channel::AUX_FUNC ch_option,
case AUX_FUNC::FW_AUTOTUNE:
case AUX_FUNC::VFWD_THR_OVERRIDE:
case AUX_FUNC::PRECISION_LOITER:
#if AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
case AUX_FUNC::TECS_PROP_FAILED:
#endif
break;

case AUX_FUNC::SOARING:
Expand Down Expand Up @@ -448,6 +466,12 @@ bool RC_Channel_Plane::do_aux_function(const AUX_FUNC ch_option, const AuxSwitch
// handled by lua scripting, just ignore here
break;

#if AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
case AUX_FUNC::TECS_PROP_FAILED:
robertlong13 marked this conversation as resolved.
Show resolved Hide resolved
do_aux_function_propulsion_failed(ch_flag);
break;
#endif

default:
return RC_Channel::do_aux_function(ch_option, ch_flag);
}
Expand Down
4 changes: 4 additions & 0 deletions ArduPlane/RC_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class RC_Channel_Plane : public RC_Channel

void do_aux_function_flare(AuxSwitchPos ch_flag);

#if AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
void do_aux_function_propulsion_failed(AuxSwitchPos ch_flag);
#endif

};

class RC_Channels_Plane : public RC_Channels
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def __init__(self,
Feature('Plane', 'QAUTOTUNE', 'QAUTOTUNE_ENABLED', 'Enable QuadPlane Autotune mode', 0, "QUADPLANE"),
Feature('Plane', 'PLANE_BLACKBOX', 'AP_PLANE_BLACKBOX_LOGGING', 'Enable blackbox logging', 0, None),
Feature('Plane', 'AP_TX_TUNING', 'AP_TUNING_ENABLED', 'Enable TX-based tuning parameter adjustments', 0, None),
Feature('Plane', 'RC_CHANNEL_PROPULSION_FAILED', 'AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED', 'Enable RC channel for manually notifying the TECS of a propulsion failure', 0, None), # NOQA: E501

Feature('RC', 'RC_Protocol', 'AP_RCPROTOCOL_ENABLED', "Enable Serial RC Protocol support", 0, None), # NOQA: E501
Feature('RC', 'RC_CRSF', 'AP_RCPROTOCOL_CRSF_ENABLED', "Enable CRSF RC Protocol", 0, "RC_Protocol"), # NOQA: E501
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/extract_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def __init__(self, filename, nm="arm-none-eabi-nm", strings="strings"):
('QAUTOTUNE_ENABLED', 'ModeQAutotune::_enter',),
('HAL_SOARING_ENABLED', 'SoaringController::var_info',),
('HAL_LANDING_DEEPSTALL_ENABLED', r'AP_Landing_Deepstall::terminate\b',),
('AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED', r'RC_Channel_Plane::do_aux_function_propulsion_failed\b',),

('AP_GRIPPER_ENABLED', r'AP_Gripper::init\b',),
('HAL_SPRAYER_ENABLED', 'AC_Sprayer::AC_Sprayer',),
Expand Down
10 changes: 6 additions & 4 deletions libraries/AP_Scripting/examples/fw_vtol_failsafe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
-- If the aircraft drops below a predetermined minimum altitude, QLAND mode is engaged and the aircraft lands at its current position.
-- If the aircraft arrives within Q_FW_LND_APR_RAD of the return point before dropping below the minimum altitude, it should loiter down to the minimum altitude before switching to QRTL and landing.

-- constants
local RC_OPTION = {TECS_PROP_FAILED=177}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this 178?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, great catch. This was missed in the rebase.

local AuxSwitchPos = {LOW=0, MIDDLE=1, HIGH=2}

-- setup param block for VTOL failsafe params
local PARAM_TABLE_KEY = 77
local PARAM_TABLE_PREFIX = "VTFS_"
Expand Down Expand Up @@ -91,10 +95,8 @@ function trigger_failsafe()
-- RTL_AUTOLAND
param:set('RTL_AUTOLAND', 0)
end
if param:get('TECS_SPDWEIGHT') < 2 then
-- force airspeed priority
param:set('TECS_SPDWEIGHT', 2)
end
-- tell the TECS that propulsion has failed
rc:run_aux_function(RC_OPTION.TECS_PROP_FAILED, AuxSwitchPos.HIGH)
-- trigger an RTL to start bringing the vehicle home
-- it will automatically go to the nearest rally point if set or go to home
-- if no rally point available within the RALLY_LIMIT_KM
Expand Down
2 changes: 2 additions & 0 deletions libraries/RC_Channel/RC_Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ const AP_Param::GroupInfo RC_Channel::var_info[] = {
// @Values{Copter, Rover, Plane, Blimp}: 175:Camera Lens
// @Values{Plane}: 176:Quadplane Fwd Throttle Override enable
// @Values{Copter, Rover, Plane, Blimp}: 177:Mount LRF enable
// @Values{Plane}: 178:Set TECS Propulsion Failed
// @Values{Rover}: 201:Roll
// @Values{Rover}: 202:Pitch
// @Values{Rover}: 207:MainSail
Expand Down Expand Up @@ -773,6 +774,7 @@ const RC_Channel::LookupTable RC_Channel::lookuptable[] = {
{ AUX_FUNC::CAMERA_IMAGE_TRACKING, "Camera Image Tracking"},
{ AUX_FUNC::CAMERA_LENS, "Camera Lens"},
{ AUX_FUNC::MOUNT_LRF_ENABLE, "Mount LRF Enable"},
{ AUX_FUNC::TECS_PROP_FAILED, "TECS Propulsion Failure"},
};

/* lookup the announcement for switch change */
Expand Down
1 change: 1 addition & 0 deletions libraries/RC_Channel/RC_Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class RC_Channel {
CAMERA_LENS = 175, // camera lens selection
VFWD_THR_OVERRIDE = 176, // force enabled VTOL forward throttle method
MOUNT_LRF_ENABLE = 177, // mount LRF enable/disable
TECS_PROP_FAILED = 178, // tell the TECS controller that propulsion has failed


// inputs from 200 will eventually used to replace RCMAP
Expand Down
4 changes: 4 additions & 0 deletions libraries/RC_Channel/RC_Channel_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@
#ifndef AP_RC_CHANNEL_AUX_FUNCTION_STRINGS_ENABLED
#define AP_RC_CHANNEL_AUX_FUNCTION_STRINGS_ENABLED AP_RC_CHANNEL_ENABLED
#endif

#ifndef AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED
#define AP_RC_CHANNEL_PROPULSION_FAILED_ENABLED AP_RC_CHANNEL_ENABLED
#endif
Loading