Peter Barker
4c434c2df9
AP_Math: add WARN_IF_UNUSED to bool methods
6 years ago
murata
c6bcb1d54c
AP_Math: Collect CRC16 into CRC file
...
AP_Math: Collect CRC16 into CRC file
6 years ago
Mark Whitehorn
b515431008
AP_Math: add expo and throttle_curve functions
6 years ago
Pierre Kancir
f6941beeb9
AP_Math: fix circulary inclusion error
6 years ago
Andrew Tridgell
ecbe67a0fe
AP_Math: fixed inefficient sq() function
6 years ago
Andrew Tridgell
d4eaf09baf
AP_Math: added rotation_equal()
6 years ago
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
7 years ago
Tom Pittenger
3653ba61d7
AP_Math: add is_valid_octal helper function.
...
returns true if valid
7 years ago
bnsgeyer
600e0dac92
AP_Math: added support for cubic spline interpolation
7 years ago
Peter Barker
1ca76173a5
AP_Math: set radians(...) and degrees(...) as constexpr
7 years ago
Miguel Arroyo
7cea21afa2
AP_Math: Moves rand_vec3f from SITL_State.
8 years ago
Francisco Ferreira
da5060964b
AP_Math: uniformize template type parameter keyword
...
Use typename everywhere instead of class
8 years ago
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
8 years ago
Michael du Breuil
2cd6ff6dd5
AP_Math: Accept float epsilon in is_positive is_negative as a valid result
8 years ago
Michael du Breuil
5a15413513
AP_Math: Add is_negative and is_positive helpers
8 years ago
Andrew Tridgell
607220d12b
AP_Math: rename macros to avoid conflicts
...
these macros were also defined in NuttX in clock.h
8 years ago
Andrew Tridgell
2fcecaa7c5
AP_Math: added rand_float()
8 years ago
Pierre Kancir
da49149d19
AP_Math: is_equal correct comparison for integer as epsilon doesn't exist.
...
Credit to Kwikius for the right solution
8 years ago
Pierre Kancir
ce734b5f7b
AP_Math: Remove unecessary check
8 years ago
Andrew Tridgell
a8d10e8c2c
AP_Math: added get_random16()
8 years ago
Lucas De Marchi
0d4caa3ccc
AP_Math: remove declaration of not implemented functions
9 years ago
Lucas De Marchi
1ac712fa65
AP_Math: fix is_zero() after template conversion
9 years ago
dgrat
7ff8004f8f
AP_Math: Replace is_zero() with a template function
...
This function only makes sense for floating point types. However this
function was also used for ints.
9 years ago
Lucas De Marchi
aa974399d0
AP_Math: use inline wrappers for constrain_* functions
...
This avoids some warnings about "constrain_float defined but not used"
in some compilers.
9 years ago
Lucas De Marchi
bd6e268122
AP_Math: fix coding style
...
- cleanup whitespace
- function reorder
- fix brace position
9 years ago
Lucas De Marchi
ab1fa4b435
AP_Math: reorganize headers
...
Sort and add pragma once where needed.
9 years ago
dgrat
6d3b491c02
AP_Math: Replace is_equal with a type safe template function
...
It makes sense to consider also other floating point types.
9 years ago
dgrat
503867b7dc
AP_Math: Replace safe_sqrt() by template function
9 years ago
dgrat
5deb0e8e03
AP_Math: Replace safe_asin() by template function
9 years ago
dgrat
174f899a29
AP_Math: Replace the constrain_* functions by a single template
...
Besides being simpler this reduces ~4k in the binary size for PX4.
9 years ago
dgrat
41661f815f
AP_Math: Replace the pythagorous* functions with a variadic template
...
The new function can deal with a variable number of function parameters.
Additionally, I renamed the functions to norm(), because this is the
standard name used in several other projects.
9 years ago
dgrat
76362caee0
AP_Math: Replace wrap_* functions with template versions
9 years ago
Andrew Tridgell
e8142b0b5b
AP_Math: added wrap_360()
9 years ago
Ricardo de Almeida Gonzaga
5bd034a5a8
Global: start using cmath instead of math.h
9 years ago
Andrew Tridgell
6bff07397e
AP_Math: added linear_interpolate() function
9 years ago
dgrat
672acdc8ef
AP_Math: Created location.h header for location functions
...
Helps to order AP_Math functions by purpose.
9 years ago
dgrat
5148e41c1a
AP_Math: Cleaned macro definitions
...
Moved Definitions into a separate header. Replaced PI with M_PI and
removed the M_PI_*_F macros.
9 years ago
dgrat
7c4c8ea579
AP_Math: Remove ROTATION_COMBINATION_SUPPORT
...
This function is not used.
9 years ago
Daniel Frenzel
ead51a9d19
AP_Math: Removed useless "undef INLINE"
9 years ago
Daniel Frenzel
ef7cf7c4aa
AP_Math: Removed useless header
...
"float.h" does not exist. It is useless and wrong to include it.
9 years ago
Peter Barker
80bc7a50d7
AP_Math: define MATH_CHECK_INDEXES
...
Wrapped in ifndefs so the top-level Makefile can override
Assume MATH_CHECK_INDEXES is always defined
9 years ago
Andrew Tridgell
60af7a6087
AP_Math: removed matrix3 parameter support
9 years ago
bugobliterator
1a4b4fa85e
AP_Math: add inverse matrix test to check if inverse(mat)*mat = I
...
where I is an identity matrix (a matrix with diagonal elements = 1)
9 years ago
José Roberto de Souza
d74bd533c8
AP_Math: Add function to convert frequency to/from microseconds
9 years ago
José Roberto de Souza
38575dd87a
AP_Math: Fix parameter name in nsec_to_hz()
9 years ago
Jonathan Challinger
fff275fd99
AP_Math: add wrap_2PI
9 years ago
Tom Pittenger
f8b0a6a977
AP_Math: compiler warnings - undeclared function
9 years ago
Lucas De Marchi
aa9168e0e9
AP_Math: remove unused maxf()
9 years ago
Lucas De Marchi
6f88fba8e5
AP_Math: remove unused minf()
9 years ago
Lucas De Marchi
e0a0514c79
AP_Math: turn MIN/MAX macros into inline functions
...
The problem with the current MIN/MAX macros is that they evaluate twice
the arguments. For example, these cases provide unintended results:
// a is incremented twice
a = MIN(a++, b);
// foo() with side-effects
a = MIN(foo(), b);
The alternative implementation here was provided by Daniel Frenzel using
template function. It doesn't have type safety as std::min and std::max,
but adding type safety would mean to check case by case what would be a
reasonable type and add proper casts. Here the arguments for MIN and MAX
can have different types and the return type is deduced from the
expression in the function.
Inspecting the current callers no place was found with the unintended
results above, but some in which now we don't calculate twice the
parameters will benefit from this new version. Examples:
float velocity_max = MIN(_pos_control.get_speed_xy(), safe_sqrt(0.5f*_pos_control.get_accel_xy()*_radius));
float acro_level_mix = constrain_float(1-MAX(MAX(abs(roll_in), abs(pitch_in)), abs(yaw_in))/4500.0, 0, 1)*ahrs.cos_pitch()
accel_x_cmss = (GRAVITY_MSS * 100) * (-(_ahrs.cos_yaw() * _ahrs.sin_pitch() / MAX(_ahrs.cos_pitch(),0.5f)) - _ahrs.sin_yaw() * _ahrs.sin_roll() / MAX(_ahrs.cos_roll(),0.5f));
track_leash_slack = MIN(_track_leash_length*(leash_z-track_error_z)/leash_z, _track_leash_length*(leash_xy-track_error_xy)/leash_xy);
RC_Channel_aux::move_servo(RC_Channel_aux::k_sprayer_pump, MIN(MAX(ground_speed * _pump_pct_1ms, 100 *_pump_min_pct),10000),0,10000);
9 years ago