diff --git a/ArduCopter/ArduCopter.pde b/ArduCopter/ArduCopter.pde index 04f88d7c3c..291eb9567b 100644 --- a/ArduCopter/ArduCopter.pde +++ b/ArduCopter/ArduCopter.pde @@ -2040,7 +2040,7 @@ static void update_trig(void){ // 270 = cos_yaw: 0.00, sin_yaw: -1.00, } -// read baro and sonar altitude at 10hz +// read baro and sonar altitude at 20hz static void update_altitude() { #if HIL_MODE == HIL_MODE_ATTITUDE @@ -2218,6 +2218,11 @@ static void tuning(){ case CH6_THR_ACCEL_KD: g.pid_throttle_accel.kD(tuning_value); break; + + case CH6_DECLINATION: + // set declination to +-20degrees + compass.set_declination(ToRad(20-g.rc_6.control_in/25), false); // 2nd parameter is false because we do not want to save to eeprom because this would have a performance impact + break; } } diff --git a/ArduCopter/Parameters.pde b/ArduCopter/Parameters.pde index 1e71909179..63ae4a3227 100644 --- a/ArduCopter/Parameters.pde +++ b/ArduCopter/Parameters.pde @@ -368,7 +368,7 @@ const AP_Param::Info var_info[] PROGMEM = { // @DisplayName: Channel 6 Tuning // @Description: Controls which parameters (normally PID gains) are being tuned with transmitter's channel 6 knob // @User: Standard - // @Values: 0:CH6_NONE,1:CH6_STABILIZE_KP,2:CH6_STABILIZE_KI,3:CH6_YAW_KP,4:CH6_RATE_KP,5:CH6_RATE_KI,6:CH6_YAW_RATE_KP,7:CH6_THROTTLE_KP,8:CH6_TOP_BOTTOM_RATIO,9:CH6_RELAY,10:CH6_WP_SPEED,12:CH6_LOITER_KP,13:CH6_HELI_EXTERNAL_GYRO,14:CH6_THR_HOLD_KP,17:CH6_OPTFLOW_KP,18:CH6_OPTFLOW_KI,19:CH6_OPTFLOW_KD,21:CH6_RATE_KD,22:CH6_LOITER_RATE_KP,23:CH6_LOITER_RATE_KD,24:CH6_YAW_KI,25:CH6_ACRO_KP,26:CH6_YAW_RATE_KD,27:CH6_LOITER_KI,28:CH6_LOITER_RATE_KI,29:CH6_STABILIZE_KD,30:CH6_AHRS_YAW_KP,31:CH6_AHRS_KP,32:CH6_INAV_TC,33:CH6_THROTTLE_KI,34:CH6_THR_ACCEL_KP,35:CH6_THR_ACCEL_KI,36:CH6_THR_ACCEL_KD + // @Values: 0:CH6_NONE,1:CH6_STABILIZE_KP,2:CH6_STABILIZE_KI,3:CH6_YAW_KP,4:CH6_RATE_KP,5:CH6_RATE_KI,6:CH6_YAW_RATE_KP,7:CH6_THROTTLE_KP,8:CH6_TOP_BOTTOM_RATIO,9:CH6_RELAY,10:CH6_WP_SPEED,12:CH6_LOITER_KP,13:CH6_HELI_EXTERNAL_GYRO,14:CH6_THR_HOLD_KP,17:CH6_OPTFLOW_KP,18:CH6_OPTFLOW_KI,19:CH6_OPTFLOW_KD,21:CH6_RATE_KD,22:CH6_LOITER_RATE_KP,23:CH6_LOITER_RATE_KD,24:CH6_YAW_KI,25:CH6_ACRO_KP,26:CH6_YAW_RATE_KD,27:CH6_LOITER_KI,28:CH6_LOITER_RATE_KI,29:CH6_STABILIZE_KD,30:CH6_AHRS_YAW_KP,31:CH6_AHRS_KP,32:CH6_INAV_TC,33:CH6_THROTTLE_KI,34:CH6_THR_ACCEL_KP,35:CH6_THR_ACCEL_KI,36:CH6_THR_ACCEL_KD,38:CH6_DECLINATION GSCALAR(radio_tuning, "TUNE", 0), // @Param: TUNE_LOW diff --git a/ArduCopter/defines.h b/ArduCopter/defines.h index f487d48edc..b6e21ca66f 100644 --- a/ArduCopter/defines.h +++ b/ArduCopter/defines.h @@ -174,6 +174,7 @@ #define CH6_AHRS_YAW_KP 30 // ahrs's compass effect on yaw angle (0 = very low, 1 = very high) #define CH6_AHRS_KP 31 // accelerometer effect on roll/pitch angle (0=low) #define CH6_INAV_TC 32 // inertial navigation baro/accel and gps/accel time constant (1.5 = strong baro/gps correction on accel estimatehas very strong does not correct accel estimate, 7 = very weak correction) +#define CH6_DECLINATION 38 // compass declination in radians // Commands - Note that APM now uses a subset of the MAVLink protocol @@ -286,6 +287,7 @@ enum gcs_severity { #define LOG_DATA_INT32_MSG 0x16 #define LOG_DATA_UINT32_MSG 0x17 #define LOG_DATA_FLOAT_MSG 0x18 +#define LOG_WPNAV_MSG 0x19 #define LOG_INDEX_MSG 0xF0 #define MAX_NUM_LOGS 50 diff --git a/ArduCopter/radio.pde b/ArduCopter/radio.pde index f20d59821f..9e5a1b9b3a 100644 --- a/ArduCopter/radio.pde +++ b/ArduCopter/radio.pde @@ -16,6 +16,7 @@ static void default_dead_zones() g.rc_3.set_dead_zone(60); g.rc_4.set_dead_zone(80); #endif + g.rc_6.set_dead_zone(0); } static void init_rc_in() diff --git a/libraries/AP_Compass/Compass.cpp b/libraries/AP_Compass/Compass.cpp index 8e5459936b..633be07a43 100644 --- a/libraries/AP_Compass/Compass.cpp +++ b/libraries/AP_Compass/Compass.cpp @@ -159,9 +159,13 @@ Compass::set_initial_location(int32_t latitude, int32_t longitude) } void -Compass::set_declination(float radians) +Compass::set_declination(float radians, bool save_to_eeprom) { - _declination.set_and_save(radians); + if (save_to_eeprom) { + _declination.set_and_save(radians); + }else{ + _declination.set(radians); + } } float diff --git a/libraries/AP_Compass/Compass.h b/libraries/AP_Compass/Compass.h index 05567a6963..e6e2ac776e 100644 --- a/libraries/AP_Compass/Compass.h +++ b/libraries/AP_Compass/Compass.h @@ -122,8 +122,9 @@ public: /// Sets the local magnetic field declination. /// /// @param radians Local field declination. + /// @param save_to_eeprom true to save to eeprom (false saves only to memory) /// - void set_declination(float radians); + void set_declination(float radians, bool save_to_eeprom = true); float get_declination(); // set overall board orientation