mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-09 08:04:14 -03:00
Add AVR compatibility header for missing math.h definitions.
- Define float versions of math functions to the double versions on AVR (eg. #define sinf sin). - These macros appear to be missing in older versions of avr-libs. - Include AP_Math.h rather than math.h to get these definitions.
This commit is contained in:
parent
5631f865b2
commit
4fa7bb1486
@ -3,7 +3,7 @@
|
||||
/// @file AC_PID.cpp
|
||||
/// @brief Generic PID algorithm
|
||||
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
#include "AC_PID.h"
|
||||
|
||||
// Examples for _filter:
|
||||
|
@ -7,7 +7,7 @@
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
#include <AP_HAL.h>
|
||||
#include <AP_Common.h>
|
||||
#include "AP_PitchController.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
#include <AP_HAL.h>
|
||||
|
||||
#include "AP_RollController.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
#include <AP_HAL.h>
|
||||
#include "AP_YawController.h"
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
/// @file ACM_PI.cpp
|
||||
/// @brief Generic PI algorithm
|
||||
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
|
||||
#include "APM_PI.h"
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
* of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
#include <AP_Common.h>
|
||||
#include <AP_Baro.h>
|
||||
#include <AP_HAL.h>
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
// AVR LibC Includes
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
#include <AP_HAL.h>
|
||||
|
||||
#include "AP_Compass_HMC5843.h"
|
||||
|
@ -23,9 +23,8 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#include <AP_Math.h>
|
||||
#include "../AP_HAL_Namespace.h"
|
||||
#include "Print.h"
|
||||
using namespace AP_HAL;
|
||||
|
@ -7,6 +7,8 @@
|
||||
*/
|
||||
|
||||
#include <AP_HAL.h>
|
||||
#include <AP_Math.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
|
||||
|
||||
#include "AP_HAL_AVR_SITL.h"
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include <AP_Common.h>
|
||||
#include <AP_Param.h>
|
||||
#include <math.h>
|
||||
#ifdef __AVR__
|
||||
# include <AP_Math_AVR_Compat.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include "rotations.h"
|
||||
#include "vector2.h"
|
||||
|
153
libraries/AP_Math/AP_Math_AVR_Compat.h
Normal file
153
libraries/AP_Math/AP_Math_AVR_Compat.h
Normal file
@ -0,0 +1,153 @@
|
||||
// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: t -*-
|
||||
|
||||
#ifndef AP_MATH_AVR_COMPAT_H
|
||||
#define AP_MATH_AVR_COMPAT_H
|
||||
|
||||
// This file defines the floating-point version of standard C math
|
||||
// functions on doubles, if they are not present in avr-libc.
|
||||
|
||||
#ifndef cosf
|
||||
# define cosf cos
|
||||
#endif
|
||||
|
||||
#ifndef sinf
|
||||
# define sinf sin
|
||||
#endif
|
||||
|
||||
#ifndef tanf
|
||||
# define tanf tan
|
||||
#endif
|
||||
|
||||
#ifndef fabsf
|
||||
# define fabsf fabs
|
||||
#endif
|
||||
|
||||
#ifndef fmodf
|
||||
# define fmodf fmod
|
||||
#endif
|
||||
|
||||
#ifndef sqrtf
|
||||
# define sqrtf sqrt
|
||||
#endif
|
||||
|
||||
#ifndef cbrtf
|
||||
# define cbrtf cbrt
|
||||
#endif
|
||||
|
||||
#ifndef hypotf
|
||||
# define hypotf hypot
|
||||
#endif
|
||||
|
||||
#ifndef squaref
|
||||
# define squaref square
|
||||
#endif
|
||||
|
||||
#ifndef floorf
|
||||
# define floorf floor
|
||||
#endif
|
||||
|
||||
#ifndef ceilf
|
||||
# define ceilf ceil
|
||||
#endif
|
||||
|
||||
#ifndef frexpf
|
||||
# define frexpf frexp
|
||||
#endif
|
||||
|
||||
#ifndef ldexpf
|
||||
# define ldexpf ldexp
|
||||
#endif
|
||||
|
||||
#ifndef expf
|
||||
# define expf exp
|
||||
#endif
|
||||
|
||||
#ifndef coshf
|
||||
# define coshf cosh
|
||||
#endif
|
||||
|
||||
#ifndef sinhf
|
||||
# define sinhf sinh
|
||||
#endif
|
||||
|
||||
#ifndef tanhf
|
||||
# define tanhf tanh
|
||||
#endif
|
||||
|
||||
#ifndef acosf
|
||||
# define acosf acos
|
||||
#endif
|
||||
|
||||
#ifndef asinf
|
||||
# define asinf asin
|
||||
#endif
|
||||
|
||||
#ifndef atanf
|
||||
# define atanf atan
|
||||
#endif
|
||||
|
||||
#ifndef atan2f
|
||||
# define atan2f atan2
|
||||
#endif
|
||||
|
||||
#ifndef logf
|
||||
# define logf log
|
||||
#endif
|
||||
|
||||
#ifndef log10f
|
||||
# define log10f log10
|
||||
#endif
|
||||
|
||||
#ifndef powf
|
||||
# define powf pow
|
||||
#endif
|
||||
|
||||
#ifndef isnanf
|
||||
# define isnanf isnan
|
||||
#endif
|
||||
|
||||
#ifndef isinff
|
||||
# define isinff isinf
|
||||
#endif
|
||||
|
||||
#ifndef isfinitef
|
||||
# define isfinitef isfinite
|
||||
#endif
|
||||
|
||||
#ifndef copysignf
|
||||
# define copysignf copysign
|
||||
#endif
|
||||
|
||||
#ifndef signbitf
|
||||
# define signbitf signbit
|
||||
#endif
|
||||
|
||||
#ifndef fdimf
|
||||
# define fdimf fdim
|
||||
#endif
|
||||
|
||||
#ifndef fmaf
|
||||
# define fmaf fma
|
||||
#endif
|
||||
|
||||
#ifndef fminf
|
||||
# define fminf fmin
|
||||
#endif
|
||||
|
||||
#ifndef truncf
|
||||
# define truncf trunc
|
||||
#endif
|
||||
|
||||
#ifndef roundf
|
||||
# define roundf round
|
||||
#endif
|
||||
|
||||
#ifndef lroundf
|
||||
# define lroundf lround
|
||||
#endif
|
||||
|
||||
#ifndef lrintf
|
||||
# define lrintf lrint
|
||||
#endif
|
||||
|
||||
#endif // !defined AP_MATH_AVR_COMPAT_H
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
#include <FastSerial.h>
|
||||
#include "Arduino.h"
|
||||
#include "AP_PerfMon.h"
|
||||
@ -216,4 +216,4 @@ void AP_PerfMon::DisplayAndClear(uint32_t display_after_seconds)
|
||||
DisplayResults();
|
||||
ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
/// See http://www.holoborodko.com/pavel/numerical-methods/numerical-derivative/smooth-low-noise-differentiators/
|
||||
//
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <AP_Math.h>
|
||||
#include <Filter.h>
|
||||
#include <DerivativeFilter.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user