mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-02 10:23:25 +08:00
Copter: use an enumeration for WP_YAW_BEHAVIOR
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Barker
co-authored by
Claude Sonnet 4.6
parent
7369c7ef91
commit
1133cdab3f
@@ -422,6 +422,7 @@ private:
|
||||
using FS_GCS_Action = Parameters::FS_GCS_Action;
|
||||
using FS_THR_Action = Parameters::FS_THR_Action;
|
||||
using FS_EKF_Action = Parameters::FS_EKF_Action;
|
||||
using WPYawBehavior = Parameters::WPYawBehavior;
|
||||
|
||||
// dead reckoning state
|
||||
struct {
|
||||
|
||||
@@ -119,7 +119,7 @@ const AP_Param::Info Copter::var_info[] = {
|
||||
// @Description: Determines how the autopilot controls the yaw during missions and RTL
|
||||
// @Values: 0:Never change yaw, 1:Face next waypoint, 2:Face next waypoint except RTL, 3:Face along GPS course
|
||||
// @User: Standard
|
||||
GSCALAR(wp_yaw_behavior, "WP_YAW_BEHAVIOR", WP_YAW_BEHAVIOR_DEFAULT),
|
||||
GSCALAR(wp_yaw_behavior, "WP_YAW_BEHAVIOR", static_cast<float>(WP_YAW_BEHAVIOR_DEFAULT)),
|
||||
|
||||
// @Param: FS_THR_ENABLE
|
||||
// @DisplayName: Throttle Failsafe Enable
|
||||
|
||||
@@ -419,7 +419,15 @@ public:
|
||||
|
||||
AP_Int8 super_simple;
|
||||
|
||||
AP_Int8 wp_yaw_behavior; // controls how the autopilot controls yaw during missions
|
||||
// Yaw behaviours during missions (WP_YAW_BEHAVIOR parameter)
|
||||
enum class WPYawBehavior {
|
||||
NONE = 0,
|
||||
LOOK_AT_NEXT_WP = 1,
|
||||
LOOK_AT_NEXT_WP_EXCEPT_RTL = 2,
|
||||
LOOK_AHEAD = 3,
|
||||
};
|
||||
|
||||
AP_Enum<WPYawBehavior> wp_yaw_behavior; // controls how the autopilot controls yaw during missions
|
||||
|
||||
#if MODE_POSHOLD_ENABLED
|
||||
AP_Int16 poshold_brake_rate_degs; // PosHold flight mode's rotation rate during braking in deg/sec
|
||||
|
||||
@@ -35,22 +35,22 @@ void Mode::AutoYaw::set_mode_to_default(bool rtl)
|
||||
// set rtl parameter to true if this is during an RTL
|
||||
Mode::AutoYaw::Mode Mode::AutoYaw::default_mode(bool rtl) const
|
||||
{
|
||||
switch (copter.g.wp_yaw_behavior) {
|
||||
switch ((Copter::WPYawBehavior)copter.g.wp_yaw_behavior) {
|
||||
|
||||
case WP_YAW_BEHAVIOR_NONE:
|
||||
case Copter::WPYawBehavior::NONE:
|
||||
return Mode::HOLD;
|
||||
|
||||
case WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP_EXCEPT_RTL:
|
||||
case Copter::WPYawBehavior::LOOK_AT_NEXT_WP_EXCEPT_RTL:
|
||||
if (rtl) {
|
||||
return Mode::HOLD;
|
||||
} else {
|
||||
return Mode::LOOK_AT_NEXT_WP;
|
||||
}
|
||||
|
||||
case WP_YAW_BEHAVIOR_LOOK_AHEAD:
|
||||
case Copter::WPYawBehavior::LOOK_AHEAD:
|
||||
return Mode::LOOK_AHEAD;
|
||||
|
||||
case WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP:
|
||||
case Copter::WPYawBehavior::LOOK_AT_NEXT_WP:
|
||||
default:
|
||||
return Mode::LOOK_AT_NEXT_WP;
|
||||
}
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@
|
||||
// TradHeli defaults
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
# define RC_FAST_SPEED 125
|
||||
# define WP_YAW_BEHAVIOR_DEFAULT WP_YAW_BEHAVIOR_LOOK_AHEAD
|
||||
# define WP_YAW_BEHAVIOR_DEFAULT WPYawBehavior::LOOK_AHEAD
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -452,7 +452,7 @@
|
||||
|
||||
// AUTO Mode
|
||||
#ifndef WP_YAW_BEHAVIOR_DEFAULT
|
||||
# define WP_YAW_BEHAVIOR_DEFAULT WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP_EXCEPT_RTL
|
||||
# define WP_YAW_BEHAVIOR_DEFAULT WPYawBehavior::LOOK_AT_NEXT_WP_EXCEPT_RTL
|
||||
#endif
|
||||
|
||||
#ifndef YAW_LOOK_AHEAD_MIN_SPEED_MS
|
||||
|
||||
@@ -54,13 +54,6 @@ enum tuning_func {
|
||||
TUNING_WP_SPEED_MS = 61, // maximum speed to next waypoint in m/s
|
||||
};
|
||||
|
||||
// Yaw behaviours during missions - possible values for WP_YAW_BEHAVIOR parameter
|
||||
#define WP_YAW_BEHAVIOR_NONE 0 // auto pilot will never control yaw during missions or rtl (except for DO_CONDITIONAL_YAW command received)
|
||||
#define WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP 1 // auto pilot will face next waypoint or home during rtl
|
||||
#define WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP_EXCEPT_RTL 2 // auto pilot will face next waypoint except when doing RTL at which time it will stay in it's last
|
||||
#define WP_YAW_BEHAVIOR_LOOK_AHEAD 3 // auto pilot will look ahead during missions and rtl (primarily meant for traditional helicopters)
|
||||
|
||||
|
||||
// Airmode
|
||||
enum class AirMode {
|
||||
AIRMODE_NONE,
|
||||
|
||||
@@ -478,7 +478,7 @@ bool ModeAuto::wp_start(const Location& dest_loc)
|
||||
|
||||
// initialise yaw
|
||||
// To-Do: reset the yaw only when the previous navigation command is not a WP. this would allow removing the special check for ROI
|
||||
if (auto_yaw.mode() != AutoYaw::Mode::ROI && !(auto_yaw.mode() == AutoYaw::Mode::FIXED && copter.g.wp_yaw_behavior == WP_YAW_BEHAVIOR_NONE)) {
|
||||
if (auto_yaw.mode() != AutoYaw::Mode::ROI && !(auto_yaw.mode() == AutoYaw::Mode::FIXED && copter.g.wp_yaw_behavior == Copter::WPYawBehavior::NONE)) {
|
||||
auto_yaw.set_mode_to_default(false);
|
||||
}
|
||||
|
||||
@@ -1851,7 +1851,7 @@ void ModeAuto::do_spline_wp(const AP_Mission::Mission_Command& cmd)
|
||||
|
||||
// initialise yaw
|
||||
// To-Do: reset the yaw only when the previous navigation command is not a WP. this would allow removing the special check for ROI
|
||||
if (auto_yaw.mode() != AutoYaw::Mode::ROI && !(auto_yaw.mode() == AutoYaw::Mode::FIXED && copter.g.wp_yaw_behavior == WP_YAW_BEHAVIOR_NONE)) {
|
||||
if (auto_yaw.mode() != AutoYaw::Mode::ROI && !(auto_yaw.mode() == AutoYaw::Mode::FIXED && copter.g.wp_yaw_behavior == Copter::WPYawBehavior::NONE)) {
|
||||
auto_yaw.set_mode_to_default(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user