Commit Graph

147 Commits

Author SHA1 Message Date
Andrew Tridgell 88f0a324fd AP_Math: added rounding functions
prevent undefined behaviour in float -> integer types
2022-07-12 11:00:08 +10:00
Andrew Tridgell a95b429acc AP_Math: added unsigned versions of constrain functions
sometimes it really does matter that we use constrain_uint32() instead
of constrain_int32(). For example, if we have a value like 0xFFFFFFFF
then the result will be very different

we should use unsigned constrain when dealing with unsigned values
2022-04-05 17:46:52 +10:00
Peter Barker d9f819085c AP_Math: add specialisation for sq(float)
avoids conversion to double
2022-03-30 08:44:19 +11:00
Andy Piper 87a369727a AP_Math: specialize float and double functions to use fabsf() and simple comparison otherwise 2022-02-13 14:43:37 +11:00
Andrew Tridgell 319592a148 AP_Math: added degF_to_Kelvin() 2022-01-17 15:16:24 +11:00
Peter Barker 2205b95c99 AP_Math: create double versions of is_zero, is_positive and is_negative
Seeks to prevent

Thread 1 "ardurover" received signal SIGFPE, Arithmetic exception.
is_positive<double> (fVal1=9.6315720352771873e+44)
    at ../../libraries/AP_Math/AP_Math.h:66
66          return (static_cast<float>(fVal1) >= FLT_EPSILON);
2021-12-15 19:33:55 +11:00
Buzz adaccdf0ba AP_Math: esp32 with esp_idf have MIN and MAX defined to something else.
Author: Charles Villard <charlesvillard10@gmail.com>
Author: Buzz <davidbuzz@gmail.com>
2021-11-01 17:40:31 +11:00
Andrew Tridgell c5ef672fb5 AP_Math: fixed expo_curve()
doesn't make sense as constexpr
2021-07-23 14:47:14 +10:00
Andrew Tridgell d91397f2f2 AP_Math: change wrap_PI to ftype
prevent loss of precision
2021-07-10 07:20:41 +10:00
Andrew Tridgell afb928081a AP_Math: use ftype for a few internal trig fns 2021-07-10 07:20:41 +10:00
Andrew Tridgell 0f2f0d4cb2 AP_Math: allow for double EKF build 2021-07-10 07:20:41 +10:00
Andrew Tridgell 154ae64e63 AP_Math: support either polarity in linear_interpolate() 2021-06-05 13:05:30 +10:00
Tom Pittenger ba6bb21560 AP_Math: added helper for16bit float conversions 2021-04-28 19:22:53 -07:00
Andrew Tridgell e884e4c5ac AP_Math: added fixedwing_turn_rate() helper 2021-02-27 14:42:20 +11:00
Andrew Tridgell 999268cbba AP_Math: fixup matrix algorithms to be in cpp file
this fixes an issue where optimize O2 was forced on any file that
included AP_Math.h. It also fixes the test suite for matrix_alg, and
fixes the type handling to be consistent
2021-01-21 13:09:21 +11:00
bugobliterator 3b3e2c01f8 AP_Math: templatize matrix_alg methods 2021-01-21 13:09:21 +11:00
Andrew Tridgell 720f9a1de0 AP_Math: cleanup maths functions
use class template instantiation, and cleanup const in matrix code
2021-01-21 13:09:21 +11:00
Leonard Hall 1e38440c83 AP_Math: add control common functions 2021-01-20 18:19:40 +11:00
Andrew Tridgell d9dbcb17c4 AP_Math: enable constrain value with line numbers on all boards 2021-01-19 10:24:39 +11:00
Andrew Tridgell cdcf32d22c AP_Math: added calc_lowpass_alpha_dt()
used in several places
2020-11-10 16:15:45 +11:00
Michael du Breuil 051640e2b2 AP_Math: Log line numbers on constrain_nan's for constrain float 2020-11-03 11:04:13 +11:00
Tom Pittenger 787d7f5254 Revert "AP_Math: add function to convert any base to any base"
This reverts commit 935cb39dff.
2020-10-07 19:11:38 +11:00
Tom Pittenger 935cb39dff AP_Math: add function to convert any base to any base
Example: convert dec 12345 to 0x12345 or dec 1200 to octal 1200
2020-09-15 13:09:50 -07:00
Randy Mackay bdb67532b0 AP_Math: clarify get_vel_correction_for_sensor_offset comment 2020-06-02 08:33:42 +09:00
Randy Mackay 4639e8a698 AP_Math: add get_vel_correction_for_sensor_offset 2020-06-01 17:51:24 +09:00
Patrick José Pereira 1635054c4f AP_Math: Add missing constexpr
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-03-17 10:23:47 +11:00
Andrew Tridgell 66b4e92444 AP_Math: make fill_nanf() use a signalling NaN
we want use of these values to trigger a FPE
2019-10-01 17:35:26 +10:00
Peter Barker 6fe09b6120 AP_Math: move is_valid_octal into adsb
This doesn't ensure the value is octal digits - there's more magic in
it.
2019-10-01 09:18:15 +10:00
Peter Barker 975804fa35 AP_Math: remove unit_mod concept from wrap functions
devcall decided it would be clearer to have non-shared implementation
for the _cd variants
2019-09-25 13:19:44 +10:00
Andrew Tridgell 9b746b89db AP_Math: added fill_nanf()
used in SITL to invalidate memory
2019-09-24 12:51:54 +10:00
Peter Barker 5692f3d79e AP_Math: stop returning float for integer wrap_180/wrap_360 etc 2019-09-18 12:57:02 +10:00
Peter Barker 4c434c2df9 AP_Math: add WARN_IF_UNUSED to bool methods 2019-07-26 09:26:02 +09:00
murata c6bcb1d54c AP_Math: Collect CRC16 into CRC file
AP_Math: Collect CRC16 into CRC file
2019-05-21 09:19:19 +10:00
Mark Whitehorn b515431008 AP_Math: add expo and throttle_curve functions 2019-04-23 09:46:38 +10:00
Pierre Kancir f6941beeb9 AP_Math: fix circulary inclusion error 2019-04-02 19:00:02 +11:00
Andrew Tridgell ecbe67a0fe AP_Math: fixed inefficient sq() function 2019-02-23 21:04:00 +11:00
Andrew Tridgell d4eaf09baf AP_Math: added rotation_equal() 2018-10-01 14:26:56 +09:00
Peter Barker 6af0dcfed0 AP_Math: create a constrain_int64
The template system doesn't work across 32/64 bit builds (SITL
vs fmuv4), probably because int is typedef'd to int64
2018-06-15 08:01:22 +10:00
Tom Pittenger 3653ba61d7 AP_Math: add is_valid_octal helper function.
returns true if valid
2018-05-23 14:02:45 -07:00
bnsgeyer 600e0dac92 AP_Math: added support for cubic spline interpolation 2018-03-27 09:07:03 +11:00
Peter Barker 1ca76173a5 AP_Math: set radians(...) and degrees(...) as constexpr 2017-10-27 16:33:45 +11:00
Miguel Arroyo 7cea21afa2 AP_Math: Moves rand_vec3f from SITL_State. 2017-06-29 09:22:08 +10:00
Francisco Ferreira da5060964b AP_Math: uniformize template type parameter keyword
Use typename everywhere instead of class
2017-06-21 18:19:31 +09:00
Francisco Ferreira 7b98f41947 AP_Math: correct norm to need two arguments
Correctly use sqrtf instead of the double version
Stop casting to float since sq already returns one
2017-06-21 18:19:31 +09:00
Michael du Breuil 2cd6ff6dd5 AP_Math: Accept float epsilon in is_positive is_negative as a valid result 2017-05-27 10:46:59 -07:00
Michael du Breuil 5a15413513 AP_Math: Add is_negative and is_positive helpers 2017-05-24 15:22:27 -07:00
Andrew Tridgell 607220d12b AP_Math: rename macros to avoid conflicts
these macros were also defined in NuttX in clock.h
2017-05-06 15:21:14 +10:00
Andrew Tridgell 2fcecaa7c5 AP_Math: added rand_float() 2017-05-03 20:12:04 +10:00
Pierre Kancir da49149d19 AP_Math: is_equal correct comparison for integer as epsilon doesn't exist.
Credit to Kwikius for the right solution
2016-12-20 14:09:04 +00:00
Pierre Kancir ce734b5f7b AP_Math: Remove unecessary check 2016-12-19 14:36:03 +00:00