From 0fc9c8739e525615817de6ed77fb3fa122746364 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Thu, 18 Apr 2013 15:30:18 +0900 Subject: [PATCH] Copter: add WP_YAW_BEHAVE parameter Allows user to control whether nose points towards next waypoint and/or home when RTLing. Replaces YAW_OVR_BEHAVE which had a very similar purpose. Almost nobody ever knew about or used this parameter. --- ArduCopter/Parameters.h | 4 ++-- ArduCopter/Parameters.pde | 10 +++++----- ArduCopter/commands_logic.pde | 7 ++++--- ArduCopter/defines.h | 7 ++++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index af3771c14a..68a021d45c 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -78,7 +78,7 @@ public: k_param_crosstrack_min_distance, // deprecated - remove with next eeprom number change k_param_rssi_pin, k_param_throttle_accel_enabled, - k_param_yaw_override_behaviour, + k_param_wp_yaw_behavior, k_param_acro_trainer_enabled, k_param_pilot_velocity_z_max, // 28 @@ -282,7 +282,7 @@ public: AP_Int8 battery_curr_pin; AP_Int8 rssi_pin; AP_Int8 throttle_accel_enabled; // enable/disable accel based throttle controller - AP_Int8 yaw_override_behaviour; // controls when autopilot takes back normal control of yaw after pilot overrides + AP_Int8 wp_yaw_behavior; // controls how the autopilot controls yaw during missions // Waypoints // diff --git a/ArduCopter/Parameters.pde b/ArduCopter/Parameters.pde index 729b311022..f29e841aad 100644 --- a/ArduCopter/Parameters.pde +++ b/ArduCopter/Parameters.pde @@ -182,12 +182,12 @@ const AP_Param::Info var_info[] PROGMEM = { // @User: Standard GSCALAR(throttle_accel_enabled, "THR_ACC_ENABLE", 1), - // @Param: YAW_OVR_BEHAVE - // @DisplayName: Yaw override behaviour - // @Description: Controls when autopilot takes back normal control of yaw after pilot overrides - // @Values: 0:At Next WP, 1:On Mission Restart + // @Param: WP_YAW_BEHAVIOR + // @DisplayName: Yaw behaviour during missions + // @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 // @User: Advanced - GSCALAR(yaw_override_behaviour, "YAW_OVR_BEHAVE", YAW_OVERRIDE_BEHAVIOUR_AT_NEXT_WAYPOINT), + GSCALAR(wp_yaw_behavior, "WP_YAW_BEHAVIOR", WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP), // @Param: WP_TOTAL // @DisplayName: Waypoint Total diff --git a/ArduCopter/commands_logic.pde b/ArduCopter/commands_logic.pde index f5a9acc682..edea6da4b4 100644 --- a/ArduCopter/commands_logic.pde +++ b/ArduCopter/commands_logic.pde @@ -279,7 +279,7 @@ static void do_nav_wp() loiter_time_max = command_nav_queue.p1; // reset control of yaw to default - if( g.yaw_override_behaviour == YAW_OVERRIDE_BEHAVIOUR_AT_NEXT_WAYPOINT ) { + if( g.wp_yaw_behavior == WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP || g.wp_yaw_behavior == WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP_EXCEPT_RTL) { set_yaw_mode(AUTO_YAW); } } @@ -516,8 +516,9 @@ static bool verify_RTL() rtl_state = RTL_STATE_INITIAL_CLIMB; }else{ // point nose towards home - // To-Do: make this user configurable whether RTL points towards home or not - set_yaw_mode(RTL_YAW); + if(g.wp_yaw_behavior == WP_YAW_BEHAVIOR_LOOK_AT_NEXT_WP) { + set_yaw_mode(RTL_YAW); + } // Set wp navigation target to above home wp_nav.set_destination(Vector3f(0,0,get_RTL_alt())); diff --git a/ArduCopter/defines.h b/ArduCopter/defines.h index da6f946037..a2e3b82179 100644 --- a/ArduCopter/defines.h +++ b/ArduCopter/defines.h @@ -187,9 +187,10 @@ #define NAV_WP 3 #define NAV_WP_INAV 5 -// Yaw override behaviours - used for setting yaw_override_behaviour -#define YAW_OVERRIDE_BEHAVIOUR_AT_NEXT_WAYPOINT 0 // auto pilot takes back yaw control at next waypoint -#define YAW_OVERRIDE_BEHAVIOUR_AT_MISSION_RESTART 1 // auto pilot tkaes back control only when mission is restarted +// 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 // TOY mixing options #define TOY_LOOKUP_TABLE 0