Browse Source

Copter: Add ignore pilot yaw to guided, auto and RTL options

zr-v5.1
Michael du Breuil 4 years ago committed by Randy Mackay
parent
commit
f9b4e81702
  1. 15
      ArduCopter/Parameters.cpp
  2. 4
      ArduCopter/Parameters.h
  3. 15
      ArduCopter/mode.h
  4. 14
      ArduCopter/mode_auto.cpp
  5. 12
      ArduCopter/mode_guided.cpp
  6. 16
      ArduCopter/mode_rtl.cpp

15
ArduCopter/Parameters.cpp

@ -979,8 +979,8 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { @@ -979,8 +979,8 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
#if MODE_AUTO_ENABLED == ENABLED
// @Param: AUTO_OPTIONS
// @DisplayName: Auto mode options
// @Description: A range of options that can be applied to change auto mode behaviour. Allow Arming allows the copter to be armed in Auto. Allow Takeoff Without Raising Throttle allows takeoff without the pilot having to raise the throttle
// @Bitmask: 0:Allow Arming,1:Allow Takeoff Without Raising Throttle
// @Description: A range of options that can be applied to change auto mode behaviour. Allow Arming allows the copter to be armed in Auto. Allow Takeoff Without Raising Throttle allows takeoff without the pilot having to raise the throttle. Ignore pilot yaw overrides the pilot's yaw stick being used while in auto.
// @Bitmask: 0:Allow Arming,1:Allow Takeoff Without Raising Throttle,2:Ignore pilot yaw
// @User: Advanced
AP_GROUPINFO("AUTO_OPTIONS", 40, ParametersG2, auto_options, 0),
#endif
@ -989,7 +989,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { @@ -989,7 +989,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
// @Param: GUID_OPTIONS
// @DisplayName: Guided mode options
// @Description: Options that can be applied to change guided mode behaviour
// @Bitmask: 0:Allow Arming from Transmitter
// @Bitmask: 0:Allow Arming from Transmitter,2:Ignore pilot yaw
// @User: Advanced
AP_GROUPINFO("GUID_OPTIONS", 41, ParametersG2, guided_options, 0),
#endif
@ -1003,6 +1003,15 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { @@ -1003,6 +1003,15 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
// @User: Standard
AP_GROUPINFO("FS_GCS_TIMEOUT", 42, ParametersG2, fs_gcs_timeout, 5),
#if MODE_RTL_ENABLED == ENABLED
// @Param: RTL_OPTIONS
// @DisplayName: RTL mode options
// @Description: Options that can be applied to change RTL mode behaviour
// @Bitmask: 2:Ignore pilot yaw
// @User: Advanced
AP_GROUPINFO("RTL_OPTIONS", 43, ParametersG2, rtl_options, 0),
#endif
AP_GROUPEND
};

4
ArduCopter/Parameters.h

@ -629,6 +629,10 @@ public: @@ -629,6 +629,10 @@ public:
AP_Float fs_gcs_timeout;
#if MODE_RTL_ENABLED == ENABLED
AP_Int32 rtl_options;
#endif
};
extern const AP_Param::Info var_info[];

15
ArduCopter/mode.h

@ -408,8 +408,11 @@ private: @@ -408,8 +408,11 @@ private:
enum class Options : int32_t {
AllowArming = (1 << 0U),
AllowTakeOffWithoutRaisingThrottle = (1 << 1U),
IgnorePilotYaw = (1 << 2U),
};
bool use_pilot_yaw(void) const;
bool start_command(const AP_Mission::Mission_Command& cmd);
bool verify_command(const AP_Mission::Mission_Command& cmd);
void exit_mission();
@ -836,6 +839,8 @@ private: @@ -836,6 +839,8 @@ private:
// enum for GUID_OPTIONS parameter
enum class Options : int32_t {
AllowArmingFromTX = (1U << 0),
// this bit is still available, pilot yaw was mapped to bit 2 for symmetry with auto
IgnorePilotYaw = (1U << 2),
};
void pos_control_start();
@ -847,6 +852,7 @@ private: @@ -847,6 +852,7 @@ private:
void posvel_control_run();
void set_desired_velocity_with_accel_and_fence_limits(const Vector3f& vel_des);
void set_yaw_state(bool use_yaw, float yaw_cd, bool use_yaw_rate, float yaw_rate_cds, bool relative_angle);
bool use_pilot_yaw(void) const;
// controls which controller is run (pos or vel):
GuidedMode guided_mode = Guided_TakeOff;
@ -1125,6 +1131,15 @@ private: @@ -1125,6 +1131,15 @@ private:
uint32_t _loiter_start_time;
bool terrain_following_allowed;
// enum for RTL_OPTIONS parameter
enum class Options : int32_t {
// First pair of bits are still available, pilot yaw was mapped to bit 2 for symmetry with auto
IgnorePilotYaw = (1U << 2),
};
bool use_pilot_yaw(void) const;
};

14
ArduCopter/mode_auto.cpp

@ -385,6 +385,12 @@ void ModeAuto::payload_place_start() @@ -385,6 +385,12 @@ void ModeAuto::payload_place_start()
}
// returns true if pilot's yaw input should be used to adjust vehicle's heading
bool ModeAuto::use_pilot_yaw(void) const
{
return (copter.g2.auto_options.get() & uint32_t(Options::IgnorePilotYaw)) == 0;
}
// start_command - this function will be called when the ap_mission lib wishes to start a new command
bool ModeAuto::start_command(const AP_Mission::Mission_Command& cmd)
{
@ -750,7 +756,7 @@ void ModeAuto::wp_run() @@ -750,7 +756,7 @@ void ModeAuto::wp_run()
{
// process pilot's yaw input
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && use_pilot_yaw()) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (!is_zero(target_yaw_rate)) {
@ -797,7 +803,7 @@ void ModeAuto::spline_run() @@ -797,7 +803,7 @@ void ModeAuto::spline_run()
// process pilot's yaw input
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && use_pilot_yaw()) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (!is_zero(target_yaw_rate)) {
@ -858,7 +864,7 @@ void ModeAuto::circle_run() @@ -858,7 +864,7 @@ void ModeAuto::circle_run()
{
// process pilot's yaw input
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && use_pilot_yaw()) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (!is_zero(target_yaw_rate)) {
@ -904,7 +910,7 @@ void ModeAuto::loiter_run() @@ -904,7 +910,7 @@ void ModeAuto::loiter_run()
// accept pilot input of yaw
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && use_pilot_yaw()) {
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
}

12
ArduCopter/mode_guided.cpp

@ -410,7 +410,7 @@ void ModeGuided::pos_control_run() @@ -410,7 +410,7 @@ void ModeGuided::pos_control_run()
{
// process pilot's yaw input
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && use_pilot_yaw()) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (!is_zero(target_yaw_rate)) {
@ -452,7 +452,7 @@ void ModeGuided::vel_control_run() @@ -452,7 +452,7 @@ void ModeGuided::vel_control_run()
{
// process pilot's yaw input
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && use_pilot_yaw()) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (!is_zero(target_yaw_rate)) {
@ -516,7 +516,7 @@ void ModeGuided::posvel_control_run() @@ -516,7 +516,7 @@ void ModeGuided::posvel_control_run()
// process pilot's yaw input
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && ((copter.g2.auto_options & (uint32_t)Options::IgnorePilotYaw) == 0)) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (!is_zero(target_yaw_rate)) {
@ -699,6 +699,12 @@ void ModeGuided::set_yaw_state(bool use_yaw, float yaw_cd, bool use_yaw_rate, fl @@ -699,6 +699,12 @@ void ModeGuided::set_yaw_state(bool use_yaw, float yaw_cd, bool use_yaw_rate, fl
}
}
// returns true if pilot's yaw input should be used to adjust vehicle's heading
bool ModeGuided::use_pilot_yaw(void) const
{
return (copter.g2.guided_options.get() & uint32_t(Options::IgnorePilotYaw)) == 0;
}
// Guided Limit code
// guided_limit_clear - clear/turn off guided limits

16
ArduCopter/mode_rtl.cpp

@ -163,7 +163,7 @@ void ModeRTL::climb_return_run() @@ -163,7 +163,7 @@ void ModeRTL::climb_return_run()
// process pilot's yaw input
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && use_pilot_yaw()) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (!is_zero(target_yaw_rate)) {
@ -220,7 +220,7 @@ void ModeRTL::loiterathome_run() @@ -220,7 +220,7 @@ void ModeRTL::loiterathome_run()
// process pilot's yaw input
float target_yaw_rate = 0;
if (!copter.failsafe.radio) {
if (!copter.failsafe.radio && use_pilot_yaw()) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (!is_zero(target_yaw_rate)) {
@ -319,8 +319,10 @@ void ModeRTL::descent_run() @@ -319,8 +319,10 @@ void ModeRTL::descent_run()
}
}
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
if (g.land_repositioning || use_pilot_yaw()) {
// get pilot's desired yaw rate
target_yaw_rate = get_pilot_desired_yaw_rate(channel_yaw->get_control_in());
}
}
// set motors to full range
@ -560,4 +562,10 @@ int32_t ModeRTL::wp_bearing() const @@ -560,4 +562,10 @@ int32_t ModeRTL::wp_bearing() const
return wp_nav->get_wp_bearing_to_destination();
}
// returns true if pilot's yaw input should be used to adjust vehicle's heading
bool ModeRTL::use_pilot_yaw(void) const
{
return (copter.g2.rtl_options.get() & uint32_t(Options::IgnorePilotYaw)) == 0;
}
#endif

Loading…
Cancel
Save