From 3c0440b0b4727a349373c52ed0d722b1c5aae7e7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 19 Dec 2012 17:02:13 +1100 Subject: [PATCH] Math: use common degrees() and radians() functions --- APMrover2/defines.h | 4 ++-- ArduCopter/defines.h | 4 ++-- ArduPlane/defines.h | 4 ++-- Tools/ArduTracker/defines.h | 4 ++-- Tools/VARTest/defines.h | 4 ++-- archive/ArducopterNG/Arducopter.h | 4 ++-- archive/WaypointWriterCopterMega/defines.h | 4 ++-- archive/WaypointWriterMega/defines.h | 4 ++-- libraries/AP_Common/AP_Common.h | 4 ++-- libraries/AP_InertialSensor/AP_InertialSensor_Oilpan.cpp | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/APMrover2/defines.h b/APMrover2/defines.h index 51f802110e..a1e14bc005 100644 --- a/APMrover2/defines.h +++ b/APMrover2/defines.h @@ -8,8 +8,8 @@ #define TRUE 1 #define FALSE 0 -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi #define DEBUG 0 #define SERVO_MAX 4500 // This value represents 45 degrees and is just an arbitrary representation of servo max travel. diff --git a/ArduCopter/defines.h b/ArduCopter/defines.h index 5501744be1..12c5ce49aa 100644 --- a/ArduCopter/defines.h +++ b/ArduCopter/defines.h @@ -88,8 +88,8 @@ #define TRUE 1 #define FALSE 0 -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi #define DEBUG 0 #define LOITER_RANGE 60 // for calculating power outside of loiter radius diff --git a/ArduPlane/defines.h b/ArduPlane/defines.h index 39b950e63e..d5858b9e34 100644 --- a/ArduPlane/defines.h +++ b/ArduPlane/defines.h @@ -8,8 +8,8 @@ #define TRUE 1 #define FALSE 0 -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi #define DEBUG 0 #define LOITER_RANGE 60 // for calculating power outside of loiter radius diff --git a/Tools/ArduTracker/defines.h b/Tools/ArduTracker/defines.h index fc752170b5..e99f900230 100644 --- a/Tools/ArduTracker/defines.h +++ b/Tools/ArduTracker/defines.h @@ -5,8 +5,8 @@ #define TRUE 1 #define FALSE 0 -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi #define DEBUG 0 #define LOITER_RANGE 30 // for calculating power outside of loiter radius diff --git a/Tools/VARTest/defines.h b/Tools/VARTest/defines.h index 9f900459e0..4913981dd5 100644 --- a/Tools/VARTest/defines.h +++ b/Tools/VARTest/defines.h @@ -8,8 +8,8 @@ #define TRUE 1 #define FALSE 0 -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi #define DEBUG 0 #define LOITER_RANGE 60 // for calculating power outside of loiter radius diff --git a/archive/ArducopterNG/Arducopter.h b/archive/ArducopterNG/Arducopter.h index afc7b814d0..2511f71e1c 100644 --- a/archive/ArducopterNG/Arducopter.h +++ b/archive/ArducopterNG/Arducopter.h @@ -164,8 +164,8 @@ int SENSOR_SIGN[]={ #define PITCH_DEF 0 // Level values for pitch, used to calculate pitch_acc_offset #define Z_DEF GRAVITY // Stable level value for Z, used to calculate z_acc_offset, same as GRAVITY -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi // IDG500 Sensitivity (from datasheet) => 2.0mV/ยบ/s, 0.8mV/ADC step => 0.8/3.33 = 0.4 // Tested values : diff --git a/archive/WaypointWriterCopterMega/defines.h b/archive/WaypointWriterCopterMega/defines.h index 85e5eaca5b..4d561b90bc 100644 --- a/archive/WaypointWriterCopterMega/defines.h +++ b/archive/WaypointWriterCopterMega/defines.h @@ -29,8 +29,8 @@ #define TRUE 1 #define FALSE 0 -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi #define DEBUG 0 #define LOITER_RANGE 60 // for calculating power outside of loiter radius diff --git a/archive/WaypointWriterMega/defines.h b/archive/WaypointWriterMega/defines.h index 85e5eaca5b..4d561b90bc 100644 --- a/archive/WaypointWriterMega/defines.h +++ b/archive/WaypointWriterMega/defines.h @@ -29,8 +29,8 @@ #define TRUE 1 #define FALSE 0 -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi #define DEBUG 0 #define LOITER_RANGE 60 // for calculating power outside of loiter radius diff --git a/libraries/AP_Common/AP_Common.h b/libraries/AP_Common/AP_Common.h index cf2f77c68e..4416630729 100644 --- a/libraries/AP_Common/AP_Common.h +++ b/libraries/AP_Common/AP_Common.h @@ -42,8 +42,8 @@ #define FPSTR(s) (wchar_t *)(s) -#define ToRad(x) (x*0.01745329252) // *pi/180 -#define ToDeg(x) (x*57.2957795131) // *180/pi +#define ToRad(x) radians(x) // *pi/180 +#define ToDeg(x) degrees(x) // *180/pi // @} diff --git a/libraries/AP_InertialSensor/AP_InertialSensor_Oilpan.cpp b/libraries/AP_InertialSensor/AP_InertialSensor_Oilpan.cpp index 5ba181e1b7..ad803a3c50 100644 --- a/libraries/AP_InertialSensor/AP_InertialSensor_Oilpan.cpp +++ b/libraries/AP_InertialSensor/AP_InertialSensor_Oilpan.cpp @@ -26,7 +26,7 @@ const float AP_InertialSensor_Oilpan::_adc_constraint = 900; #define OILPAN_RAW_ACCEL_OFFSET ((2465.0 + 1617.0) * 0.5) #define OILPAN_RAW_GYRO_OFFSET 1658.0 -#define ToRad(x) (x*0.01745329252) // *pi/180 +#define ToRad(x) radians(x) // *pi/180 // IDG500 Sensitivity (from datasheet) => 2.0mV/degree/s, // 0.8mV/ADC step => 0.8/3.33 = 0.4 // Tested values : 0.4026, ?, 0.4192