2016-02-17 21:25:25 -04:00
|
|
|
#pragma once
|
2013-01-15 18:12:55 -04:00
|
|
|
|
2019-02-11 01:39:37 -04:00
|
|
|
#include <AP_HAL/AP_HAL_Boards.h>
|
|
|
|
|
2013-01-15 18:12:55 -04:00
|
|
|
/*
|
|
|
|
macros to allow code to build on multiple platforms more easily
|
|
|
|
*/
|
|
|
|
|
2021-05-04 08:12:23 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL || CONFIG_HAL_BOARD == HAL_BOARD_LINUX || HAL_WITH_EKF_DOUBLE
|
2018-05-03 22:18:51 -03:00
|
|
|
/*
|
|
|
|
allow double maths on Linux and SITL to avoid problems with system headers
|
|
|
|
*/
|
2020-08-29 20:14:32 -03:00
|
|
|
#if !defined(ALLOW_DOUBLE_MATH_FUNCTIONS)
|
|
|
|
#define ALLOW_DOUBLE_MATH_FUNCTIONS
|
|
|
|
#endif
|
2018-05-03 22:18:51 -03:00
|
|
|
#endif
|
|
|
|
|
2019-09-27 18:54:48 -03:00
|
|
|
// we need to include math.h here for newer compilers (eg. g++ 7.3.1 for stm32)
|
|
|
|
#include <math.h>
|
|
|
|
|
2018-05-03 22:18:51 -03:00
|
|
|
#if !defined(ALLOW_DOUBLE_MATH_FUNCTIONS)
|
|
|
|
/* give warnings if we use double precision maths functions without
|
|
|
|
specifying ALLOW_DOUBLE_TRIG_FUNCTIONS. Code should use the
|
|
|
|
equivalent f function instead (eg. use cosf() instead of
|
|
|
|
cos()). Individual cpp files that really do need double precision
|
|
|
|
should define ALLOW_DOUBLE_TRIG_FUNCTIONS before including
|
|
|
|
AP_Math.h
|
|
|
|
*/
|
|
|
|
#define sin(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define cos(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define tan(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define acos(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define asin(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define atan(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define atan2(x,y) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define exp(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define pow(x,y) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define sqrt(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define log2(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define log10(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define ceil(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define floor(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define round(x) DO_NOT_USE_DOUBLE_MATHS()
|
2018-11-14 18:54:39 -04:00
|
|
|
#define fmax(x,y) DO_NOT_USE_DOUBLE_MATHS()
|
2020-05-31 09:12:02 -03:00
|
|
|
#if !HAL_NUM_CAN_IFACES
|
2018-05-03 22:18:51 -03:00
|
|
|
// we should do log() and fabs() as well, but can't because of a conflict in uavcan
|
|
|
|
#define log(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#define fabs(x) DO_NOT_USE_DOUBLE_MATHS()
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|