Daniel Ricketts
249d95b413
AP_Math: add Polygon_outside and Polygon_complete functions
2016-06-25 15:55:55 +09:00
Leonard Hall
e0eecd56b2
AP_Math: use is_zero and float constants
2016-06-24 16:16:34 +09:00
Leonard Hall
7f933140c7
AP_Math: small formatting fix to quaternion rotation_matrix
...
No functional change
2016-06-24 16:16:33 +09:00
Leonard Hall
8afd29cc85
AP_Math: add quaternion::rotation_matrix_norm
2016-06-24 16:16:28 +09:00
Pierre Kancir
a8e5ff93b5
AP_Math: Correct missing declaration warning
2016-06-21 12:17:46 -03:00
Tom Pittenger
00aaa78757
AP_Math: add separate check_lat() and check_lng()
2016-06-06 13:02:56 -07:00
Andrew Tridgell
3969bde84a
AP_Math: fixed coverity warning in example
2016-06-05 07:20:46 +10:00
Peter Barker
cb16d0b6c6
AP_Math: correct examples build on px4
2016-06-04 12:31:36 -03:00
Tom Pittenger
7b4c503052
AP_Math: use new check_latlng helper
2016-06-01 17:38:48 -07:00
Tom Pittenger
ce9ecf9f3d
AP_Math: added check_latlng helper
2016-06-01 17:38:48 -07:00
Gustavo Jose de Sousa
ef61096e08
AP_Math: geodesic_grid tool: show triangle number for sections too
2016-05-18 13:28:52 -03:00
Gustavo Jose de Sousa
a6deb65d95
AP_Math: geodesic_grid tool: add option --section
2016-05-18 13:28:52 -03:00
Lucas De Marchi
1ac712fa65
AP_Math: fix is_zero() after template conversion
2016-05-17 15:49:29 -07:00
Lucas De Marchi
fa6f2c6b67
AP_Math: fix some coding style mistakes
...
- fix alignement of &
- remove const from bool arguments
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
390b196eda
AP_Math: AP_GeodesicGrid: add notice for auto generated code
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
b3068baa11
AP_Math: add geodesic_grid toolset
...
That was used to aid development AP_GeodesicGrid and understanding its
concepts.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
9d34b3b996
AP_Math: AP_GeodesicGrid: make all methods static
...
Since all members are.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
3b05ec1157
AP_Math: make vectors and matrix constructors constexpr
...
That allows some object to be constructed at compile time.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
77223a7fcb
AP_Math: AP_GeodesicGrid: make data static
...
That gives the change of storing that data in flash storage in some
architectures. That doesn't happen yet though, some extra changes are required
for that to happen.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
fd2428db34
AP_Math: AP_GeodesicGrid: reduce number of _neighbor_umbrellas items
...
Only the first half is necessary. The values for the other half can be derived.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
43d9e00ab7
AP_Math: AP_GeodesicGrid: use uint8_t for _neighbor_umbrellas
...
All integers there are limited to the range [0,20), so uint8_t is enough.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
54889e4175
AP_Math: AP_GeodesicGrid: reduce number of inverses by half
...
We don't actually need all of them, since the second half is for the opposite
triangles. In that case we just need to negate the resulting vector when
changing basis.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
f31161ecb6
AP_Math: AP_GeodesicGrid: remove triangles
...
There's no need to keep those triangles, since we just need the inverses.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
b34c04a4f9
AP_Math: test_geodesic_grid: test also non-centroid vectors
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
8e8ab3af96
AP_Math: AP_GeodesicGrid: remove section_triangle() function
...
That function was only being used by the unit tests and the benchmark. In order
to remove memory usage, the triangles will be removed, since we don't actually
need to keep them in real situations. Thus, this patch removes that function
and copy those triangles to the test and benchmark.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
c7eb46fae2
AP_Math: AP_GeodesicGrid: optimize _from_neighbor_umbrella()
...
This is the second optimization. With that we don't have to iterate over the
umbrella's components.
The table below summarizes the mean CPU time in ns from the brenchmark results
on an Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz processor:
| Naive implementation | First Optimization | Second Optimization
------------------------------------------------------------------------
Min. | 26.0 | 28.00 | 26.0
1st Qu.| 78.0 | 48.75 | 39.0
Median | 132.0 | 57.00 | 41.0
Mean | 130.1 | 61.20 | 41.6
3rd Qu.| 182.2 | 76.00 | 47.0
Max. | 234.0 | 98.00 | 54.0
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
eb90ef23a1
AP_Math: AP_GeodesicGrid: fix algorithm for null vector
...
If v is the null vector, then alpha * v is still the null vector for any alpha
as a real number. That means that the null vector doesn't cross any section.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
c28c3265c8
AP_Math: AP_GeodesicGrid: optimize with neighbor umbrellas
...
This is a first optimization of the algorithm. The struct for the neighbor
umbrella has only one member, but new members will be added in the next
optimization.
The table below summarizes the mean CPU time in ns from the brenchmark results
on an Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz processor:
Cases | Naive implementation | First Optimization
--------------------------------------------------
Min. | 26.0 | 28.00
1st Qu.| 78.0 | 48.75
Median | 132.0 | 57.00
Mean | 130.1 | 61.20
3rd Qu.| 182.2 | 76.00
Max. | 234.0 | 98.00
This optimization reduces the mean time for the worst case (Max. line) by more
than 50%.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
0ff05b7af3
AP_Math: test_geodesic_grid: test triangles indexes
...
That helps figuring out which intermediate step failed the high level call.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
4398e1e49b
AP_Math: AP_GeodesicGrid: change order of triangles
...
- Change the order of the icosahedron triangles so that there's a uniform way of
finding the opposite triangle. The order visually still makes sense.
- Change test to accommodate the order change.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
ea412ad629
AP_Math: benchmark_geodesic_grid: add benchmark
...
That will help to benchmark improvements on the section search algorithm.
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
797a2da031
AP_Math: test_geodesic_grid: test when inclusive=true
2016-05-16 19:08:36 -03:00
Gustavo Jose de Sousa
b299261ad4
AP_Math: AP_GeodesicGrid: add first implementation
...
The search for the geodesic section is still naive in this version.
Additionally, add unit tests.
2016-05-16 19:08:35 -03:00
Gustavo Jose de Sousa
3f2ad764ca
AP_Math: Matrix3: add inverse() and invert() functions
...
Additionally, add unit tests.
2016-05-16 19:08:35 -03:00
Gustavo Jose de Sousa
06eea2838f
AP_Math: Matrix3: add det() function
...
Function to calculate determinant. Additionally, add unit tests.
2016-05-16 19:08:35 -03:00
Gustavo Jose de Sousa
26959f1448
AP_Math: define golden ratio constant
2016-05-16 19:08:35 -03:00
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.
2016-05-16 19:08:35 -03:00
Ricardo de Almeida Gonzaga
481e3a2af6
AP_Math: Fix typos
2016-05-13 19:20:06 -03:00
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.
2016-05-11 22:51:19 -03:00
Lucas De Marchi
bd6e268122
AP_Math: fix coding style
...
- cleanup whitespace
- function reorder
- fix brace position
2016-05-10 11:41:26 -03:00
Lucas De Marchi
1dbffef7ea
AP_Math: remove trailing whitespace on headers
2016-05-10 11:41:26 -03:00
Lucas De Marchi
ab1fa4b435
AP_Math: reorganize headers
...
Sort and add pragma once where needed.
2016-05-10 11:41:26 -03:00
dgrat
6d3b491c02
AP_Math: Replace is_equal with a type safe template function
...
It makes sense to consider also other floating point types.
2016-05-10 11:41:26 -03:00
dgrat
503867b7dc
AP_Math: Replace safe_sqrt() by template function
2016-05-10 11:41:26 -03:00
dgrat
5deb0e8e03
AP_Math: Replace safe_asin() by template function
2016-05-10 11:41:26 -03:00
Lucas De Marchi
846b4927ec
AP_Math: use if/else chain instead of 2 ternary operators
2016-05-10 11:41:26 -03:00
dgrat
174f899a29
AP_Math: Replace the constrain_* functions by a single template
...
Besides being simpler this reduces ~4k in the binary size for PX4.
2016-05-10 11:41:26 -03:00
Lucas De Marchi
348b07609c
AP_Math: remove macros from unit tests
...
Avoid warnings like:
[2130/2168] Compiling libraries/AP_Math/tests/test_math.cpp
../../libraries/AP_Math/tests/test_math.cpp: In member function ‘virtual void MathTest_IsZero_Test::TestBody()’:
../../libraries/AP_Math/tests/test_math.cpp:73:196: warning: converting ‘false’ to pointer type for argument 1 of ‘char
testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Wconversion-null]
../../libraries/AP_Math/tests/test_math.cpp:74:199: warning: converting ‘false’ to pointer type for argument 1 of ‘char
testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Wconversion-null]
Use EXPECT_TRUE() and EXPECT_FALSE() from gtest instead.
2016-05-10 11:41:26 -03:00
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.
2016-05-10 11:41:26 -03:00
Lucas De Marchi
880f130670
AP_Math: fix loss of precision on float addition
...
When using wrap_180_cd() we are adding a small float (180 * 100) to a
possibly big number. This may lose float precision as illustrated by the
unit test failing:
OUT: ../../libraries/AP_Math/tests/test_math.cpp:195: Failure
OUT: Value of: wrap_180_cd(-3600000000.f)
OUT: Actual: -80
OUT: Expected: 0.f
OUT: Which is: 0
2016-05-10 11:41:26 -03:00
dgrat
76362caee0
AP_Math: Replace wrap_* functions with template versions
2016-05-10 11:41:26 -03:00
dgrat
49cfd6fd9b
AP_Math: Add gtest support for some functions
...
These functions (or variants thereof) now have unit tests:
- is_zero()
- is_equal()
- sq()
- pythagorous()
- constrain()
- wrap_180()
- wrap_360()
Some tests in wrap_180_cd are failing: -180 should be wrapped to 180,
not -180.
2016-05-10 11:41:26 -03:00
Lucas De Marchi
ceea7540fd
AP_Math: rename test file
...
This will be reused for more math tests.
2016-05-10 11:41:26 -03:00
Gustavo Jose de Sousa
b594b5a08b
AP_Math: matrix_alg: disable FE_OVERFLOW in inverse4x4() for SITL
...
There are occasional overflows on the determinant calculation in inverse4x4()
when using calibration SITL model.
2016-05-10 16:16:37 +10:00
Gustavo Jose de Sousa
a7543d369f
AP_Math: matrix_alg: protect inverseixi() against overflow
...
Fail on inverse3x3() and inverse4x4() if there's float overflow during the
determinant calculation.
2016-05-10 16:16:37 +10:00
Gustavo Jose de Sousa
39f72610e2
AP_Math: quaternion: fix style
...
Remove trailing spaces and run astyle.
2016-05-10 16:16:37 +10:00
Andrew Tridgell
e8142b0b5b
AP_Math: added wrap_360()
2016-05-07 18:27:21 +10:00
Andrew Tridgell
97d27ce58f
AP_Math: fixed memory leak
...
found by coverity
2016-04-26 16:41:44 +10:00
Andrew Tridgell
6165c42535
AP_Math: added from_axis_angle() method on Matrix3f
...
for arbitrary rotations in simulator
2016-04-22 10:28:15 +10:00
Michael du Breuil
bb7cf6c0b6
AP_Math: Update location_sanitize to sanitize for lat/lng
2016-04-17 19:00:03 -07:00
Ricardo de Almeida Gonzaga
5bd034a5a8
Global: start using cmath instead of math.h
2016-04-05 21:06:19 -07:00
Andrew Tridgell
6bff07397e
AP_Math: added linear_interpolate() function
2016-04-02 22:44:47 +11:00
Lucas De Marchi
b4a8a0b961
AP_Math: replace header guard with pragma once
2016-03-16 18:40:41 +11:00
Gustavo Jose de Sousa
6729475b25
AP_Math: fix eulers example for PX4
2016-03-14 11:54:31 -03:00
Gustavo Jose de Sousa
d9bb696fa3
AP_Math: avoid bias in rand_num() in eulers example
...
Use RAND_MAX to avoid bias.
2016-03-14 11:54:31 -03:00
Tom Pittenger
278fb2e60d
AP_Math: add location sanity checker/fixer util
2016-03-02 08:48:26 -08:00
dgrat
672acdc8ef
AP_Math: Created location.h header for location functions
...
Helps to order AP_Math functions by purpose.
2016-02-27 02:51:33 -03:00
Lucas De Marchi
7f685a12bd
AP_Math: remove trailing whitespaces and tabs
2016-02-27 02:51:33 -03:00
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.
2016-02-27 02:51:33 -03:00
dgrat
7c4c8ea579
AP_Math: Remove ROTATION_COMBINATION_SUPPORT
...
This function is not used.
2016-02-27 02:51:33 -03:00
Daniel Frenzel
ead51a9d19
AP_Math: Removed useless "undef INLINE"
2016-02-25 02:10:39 -03:00
Daniel Frenzel
ef7cf7c4aa
AP_Math: Removed useless header
...
"float.h" does not exist. It is useless and wrong to include it.
2016-02-25 02:10:39 -03:00
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
2016-02-19 12:34:23 -02:00
Gustavo Jose de Sousa
c2e3f05dbf
waf: ardupilotwaf: prefix build context methods with ap_
...
It helps to distinguish between things from waf and things from ardupilotwaf.
2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa
a2d2661765
waf: use methods from bld instead of ardupilotwaf for the remaining
2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa
3d22490397
waf: examples: use methods from bld instead of ardupilotwaf
2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa
d281067bcc
waf: make example binaries be placed in 'examples' dir
...
This commit makes examples' wscripts use ardupilotwaf.example() instead of
ardupilot.program().
2016-01-15 16:46:41 -02:00
Andrew Tridgell
60af7a6087
AP_Math: removed matrix3 parameter support
2016-01-04 11:14:43 +11:00
Andrew Tridgell
16e0a6d7b0
AP_Math: fixed angle between two vector3s
2016-01-01 12:41:05 +11:00
Lucas De Marchi
180359d6dd
AP_Math: fix unit test
...
For ROTATION_ROLL_90_PITCH_68_YAW_293 consider the angles as 90, 68.8
and 293.3 degrees to pre-calculate rotation. This matches the rotation
matrix used in code.
While at it, check not only the values are close enough but also the
length of the vector.
2015-12-30 20:22:28 -02:00
Lucas De Marchi
ba3325ffd3
AP_Math: rename rotation
...
The rotations are supposed to follow the name of the enum, in order. The
ROTATION_YAW_293_PITCH_68_ROLL_90 was added with the name of an
intrinsic 321 rotation, but the matrix is actually a 123 rotation,
following the other rotations already present.
Change the name to follow the other names.
2015-12-30 20:22:27 -02:00
Jonathan Challinger
83d5a6664a
AP_Math: minor changes to matrix_alg in response to review
2015-12-29 22:57:21 -08:00
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)
2015-12-29 10:46:35 -08:00
bugobliterator
fe62a049bd
AP_Math: implement LU decomposition based matrix inverse
...
Replaces previous matlab generated code, which was giving imprecise results
2015-12-29 10:46:34 -08:00
Siddharth Bharat Purohit
a0c3cbffee
AP_Math: add inverse matrix test example
...
fix example build
2015-12-29 10:46:34 -08:00
Siddharth Bharat Purohit
5af0cc8eaf
AP_Math: add inverse rotate example function
2015-12-29 10:46:34 -08:00
Jonathan Challinger
7ed8b3814f
AP_Math: add rotate_inverse to Vector3
2015-12-29 10:46:34 -08:00
Lucas De Marchi
a096703b06
Global: don't link with AP_Progmem
...
AP_Progmem is not used anymore.
2015-12-27 15:58:12 -02:00
Lucas De Marchi
502077d763
AP_Math: stop using Progmem.h
2015-12-27 15:58:12 -02:00
José Roberto de Souza
d74bd533c8
AP_Math: Add function to convert frequency to/from microseconds
2015-12-16 08:18:17 +11:00
José Roberto de Souza
38575dd87a
AP_Math: Fix parameter name in nsec_to_hz()
2015-12-16 08:18:17 +11:00
Jonathan Challinger
0a701088d4
AP_Math: fix bug in Quaternion::operator*=
2015-12-14 11:15:33 +09:00
Jonathan Challinger
fff275fd99
AP_Math: add wrap_2PI
2015-12-09 19:58:25 +09:00
Tom Pittenger
f8b0a6a977
AP_Math: compiler warnings - undeclared function
2015-12-07 16:05:00 +09:00
Tom Pittenger
103af93ec3
AP_Math: compiler warnings - float compare to constant (zero)
2015-12-07 16:04:59 +09:00
Lucas De Marchi
f5c03c786d
AP_Math: remove unused AP_ADC_AnalogSource
2015-12-03 13:32:43 +11:00
Gustavo Jose de Sousa
eef784fbe6
AP_Math: add benchmark for matrix multiplication
2015-12-03 07:54:31 +11:00
Gustavo Jose de Sousa
4266e924d0
AP_Math: add unit test for vector rotations
...
This unit test already shows that rotation is wrong for
ROTATION_YAW_293_PITCH_68_ROLL_90.
2015-12-03 07:54:31 +11:00
Caio Marcelo de Oliveira Filho
6e7b73610d
waf: add waf support
2015-12-03 07:54:30 +11:00
Lucas De Marchi
aa9168e0e9
AP_Math: remove unused maxf()
2015-12-01 16:28:18 -02:00
Lucas De Marchi
6f88fba8e5
AP_Math: remove unused minf()
2015-12-01 16:28:18 -02:00
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);
2015-12-01 16:28:18 -02:00
Lucas De Marchi
2591261af6
Global: rename min and max macros to uppercase
...
The problem with using min() and max() is that they conflict with some
C++ headers. Name the macros in uppercase instead. We may go case by
case later converting them to be typesafe.
Changes generated with:
git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)max(/\1MAX(/g'
git ls-files '*.cpp' '*.h' -z | xargs -0 sed -i 's/\([^_[:alnum:]]\)min(/\1MIN(/g'
2015-12-01 16:28:09 -02:00
Caio Marcelo de Oliveira Filho
8257e6ab89
AP_Math: examples use millis/micros/panic functions
2015-11-20 12:31:55 +09:00
Andrew Tridgell
8f4ce7f20b
build: removed all nocore.inoflag files
...
these were APM2 specific
2015-11-16 08:05:17 +11:00
José Roberto de Souza
d53911e3f6
AP_Math: Add functions to convert microseconds to/from nanoseconds
2015-11-10 17:05:34 +11:00
José Roberto de Souza
ca533a9d94
AP_Math: Add functions to convert frequency to/from nanoseconds
2015-11-10 17:05:34 +11:00
Lucas De Marchi
fb28f426da
AP_Math: remove check for AVR CPUs
...
Remove the checks for HAL_CPU_CLASS > HAL_CPU_CLASS_16 and
HAL_CPU_CLASS >= HAL_CPU_CLASS_75. Corresponding dead code will be
removed on separate commits.
2015-11-04 12:14:14 +11:00
Lucas De Marchi
c7871d1bca
AP_Math: remove checks for HAL_BOARD_APM2 and HAL_BOARD_APM1
2015-11-04 12:14:12 +11:00
Lucas De Marchi
5244559010
Minimize AP_Progmem.h includes
...
Most of AP_Progmem is already gone so we can stop including it in most
of the places. The only places that need it are the ones using
pgm_read_*() APIs.
In some cases the header needed to be added in the .cpp since it was
removed from the .h to reduce scope. In those cases the headers were
also reordered.
2015-10-30 14:35:32 +09:00
Lucas De Marchi
20c6ffc5e3
Replace use of UARTDriver::printf_P() with UARTDriver::printf()
...
This also starts to show warnings on places that were already using
wrong printf format strings.
2015-10-30 14:35:25 +09:00
Lucas De Marchi
6f4904189b
Replace use of println_P() with println()
2015-10-30 14:35:22 +09:00
Lucas De Marchi
831d8acca5
Remove use of PROGMEM
...
Now variables don't have to be declared with PROGMEM anymore, so remove
them. This was automated with:
git grep -l -z PROGMEM | xargs -0 sed -i 's/ PROGMEM / /g'
git grep -l -z PROGMEM | xargs -0 sed -i 's/PROGMEM//g'
The 2 commands were done so we don't leave behind spurious spaces.
AVR-specific places were not changed.
2015-10-30 14:35:16 +09:00
Lucas De Marchi
2c38e31c93
Remove use of PSTR
...
The PSTR is already define as a NOP for all supported platforms. It's
only needed for AVR so here we remove all the uses throughout the
codebase.
This was automated with a simple python script so it also converts
places which spans to multiple lines, removing the matching parentheses.
AVR-specific places were not changed.
2015-10-30 14:35:04 +09:00
Caio Marcelo de Oliveira Filho
5020db4481
AP_Math: remove unnecessary includes
...
Remove unnecessary includes, in particular the includes for specific
boards. The list of libraries for 'polygon' example was updated so that
the example compiles again.
2015-10-21 09:16:09 +11:00
Caio Marcelo de Oliveira Filho
ec52df991c
build: compile only the HAL files needed by the board
...
Instead of requiring every program to specify the HAL related modules,
let the build system do it (in practice everything we compiled depended
on HAL anyway). This allow including only the necessary files in the
compilation.
2015-10-21 09:16:07 +11:00
Caio Marcelo de Oliveira Filho
2e464a53c2
AP_HAL: make code not depend on concrete HAL implementations
...
The switching between different AP_HAL was happening by giving different
definitions of AP_HAL_BOARD_DRIVER, and the programs would use it to
instantiate.
A program or library code would have to explicitly include (and depend)
on the concrete implementation of the HAL, even when using it only via
interface.
The proposed change move this dependency to be link time. There is a
AP_HAL::get_HAL() function that is used by the client code. Each
implementation of HAL provides its own definition of this function,
returning the appropriate concrete instance.
Since this replaces the job of AP_HAL_BOARD_DRIVER, the definition was
removed.
The static variables for PX4 and VRBRAIN were named differently to avoid
shadowing the extern symbol 'hal'.
2015-10-21 09:16:07 +11:00
Andrew Tridgell
c9ec8b3f67
AP_Math: added O3 optimisation to core math libraries
...
this costs some flash space but speeds things up considerably
2015-10-20 14:36:53 +11:00
Randy Mackay
6145794da2
AP_Math: remove duplicate RADIUS_OF_EARTH definition
2015-10-05 21:00:14 +09:00
Randy Mackay
39340e70f8
Math: add Vector2 is_zero method
2015-09-16 15:10:25 +09:00
Valmantas Palikša
d4daf19151
AP_Math: Move simple math function implementations to header for better
...
compile time optimization
Functions like sq() are better moved to the header file as inline.
Compiler can then optimize these out when used in code, this saves cpu
cycles with stack push, pop during function calls.
2015-09-09 09:57:51 +10:00
Tom Pittenger
4771d19073
AP_Math: added locations_are_same(loc1,loc2) helper
...
returns true if lat and lng are the same, ignores alt and options
2015-09-08 17:05:54 +10:00
Siddharth Bharat Purohit
1ffbffa0e7
AP_Math: check if failed to allocate memory
2015-09-03 16:59:14 +10:00
Gustavo Jose de Sousa
46774136a6
AP_Compass: standardize inclusion of libaries headers
...
This commit changes the way libraries headers are included in source files:
- If the header is in the same directory the source belongs to, so the
notation '#include ""' is used with the path relative to the directory
containing the source.
- If the header is outside the directory containing the source, then we use
the notation '#include <>' with the path relative to libraries folder.
Some of the advantages of such approach:
- Only one search path for libraries headers.
- OSs like Windows may have a better lookup time.
2015-09-03 16:59:13 +10:00
Jonathan Challinger
1c100498d4
AP_Math: use is_zero instead of defining our own epsilon
2015-09-03 16:59:13 +10:00
Siddharth Bharat Purohit
b654b1c21b
AP_Math: add inverse matrix to math library
2015-09-03 16:59:12 +10:00
Randy Mackay
46c652e42f
Math: maxf and minf functions
2015-08-19 16:44:34 +09:00
Gustavo Jose de Sousa
4790371f9b
AP_Math: standardize inclusion of libaries headers
...
This commit changes the way libraries headers are included in source files:
- If the header is in the same directory the source belongs to, so the
notation '#include ""' is used with the path relative to the directory
containing the source.
- If the header is outside the directory containing the source, then we use
the notation '#include <>' with the path relative to libraries folder.
Some of the advantages of such approach:
- Only one search path for libraries headers.
- OSs like Windows may have a better lookup time.
2015-08-11 16:38:18 +10:00
Lucas De Marchi
0471de2342
AP_Math: use ARRAY_SIZE macro
2015-07-21 14:25:09 +09:00
Lucas De Marchi
fb2eb262e7
AP_Math: use ARRAY_SIZE instead of defining another one
2015-07-21 14:24:49 +09:00
Andrew Tridgell
6009ae55b1
AP_Math: fixed build of eulers example sketch
2015-07-17 08:24:49 +10:00
Andrew Tridgell
8f41d97548
AP_Math: fixed build error on PX4
...
variable set but not used with recent longitude_scale change
2015-07-06 08:19:57 +10:00
Andrew Tridgell
099392d3ca
AP_Math: don't optimise longitude_scale on faster CPUs
...
it causes problems with replay
2015-07-05 17:27:53 +10:00
Andrew Tridgell
3edac37929
AP_Math: removed unused include in example
2015-06-01 17:35:03 +10:00
Andrew Tridgell
4d040bbb94
AP_Math: convert example from .pde to .cpp
2015-06-01 17:07:04 +10:00
Andrew Tridgell
2b828a794e
AP_Math: fixed example build
2015-06-01 16:36:54 +10:00
Randy Mackay
114c4f4077
AP_Match: fix example sketch
2015-05-27 09:47:24 +09:00
Andrew Tridgell
2a8f645d81
AP_Math: use matrix3 euler312 operations in quaternion library
2015-05-25 09:08:31 +10:00
Andrew Tridgell
7aa7e03169
AP_Math: added euler312 functions (for gimbal)
2015-05-25 09:03:11 +10:00
Andrew Tridgell
605b8b4ece
AP_Math: converted rotations example to cpp
...
this is just a test conversion before we start converting on-mass
2015-05-21 13:41:20 +10:00
Andrew Tridgell
062c9406bd
AP_Math: fixed rotations example build
2015-05-21 13:37:44 +10:00
Tom Pittenger
5f677c2b5b
AP_Math: float to double promotion via cos instead of cosf
2015-05-16 08:21:49 +10:00
Tom Pittenger
e20ffa8c75
AP_Math: replace fabs() with fabsf()
2015-05-09 09:57:27 +10:00
Randy Mackay
9dede2f0ec
Math: remove duplicate HALF_SQRT_2 definition
2015-05-05 14:23:14 +09:00
Andrew Tridgell
77a2b4acf6
AP_Math: removed fast_atan
2015-05-05 13:57:22 +10:00
Andrew Tridgell
0b897e04bb
AP_Math: revert AP_Math class change
2015-05-05 13:27:06 +10:00
Andrew Tridgell
936fbbb362
AP_Math: removed AP_Math class
2015-05-05 13:27:03 +10:00
Tom Pittenger
4ec2fb3a9c
AP_Math: Compiler warnings: nuke fast_atan2()
...
per Randy's suggestion, fast_atan2() is no longer necessary over atan2() because only copter uses it and copter is no longer supported on future builds of APM
ccd578664f (commitcomment-11025083)
2015-05-05 13:27:02 +10:00
Tom Pittenger
330e4126bb
Ap_Math: compile warnings: float to double. use atan2f instead of atan2
2015-05-05 13:27:00 +10:00
Tom Pittenger
820f0bf02a
AP_Math: compiler warnings: float to double promotion
...
cast as float because we're in magical template land where T minus T means promote to double
2015-05-05 13:26:58 +10:00
Tom Pittenger
1c3ad00aa7
AP_Math: compiler warnings: use double for the constant so the template can handle it
2015-05-05 13:26:57 +10:00
Tom Pittenger
6e6f481ecb
AP_Math: compiler warnings: apply is_zero(float) or is_equal(float)
2015-05-05 13:26:56 +10:00
Tom Pittenger
35f7a466e5
AP_Math: compiler warnings: apply is_zero(float) or is_equal(float)
2015-05-05 13:26:52 +10:00
Tom Pittenger
a5d2f3a82f
AP_Math: compiler warnings: float to double
2015-05-05 13:26:52 +10:00
Tom Pittenger
ac4e7b2b03
AP_Math: compiler warnings: apply is_equal(float)
2015-05-05 13:26:51 +10:00
Tom Pittenger
c93c773de2
AP_Math: change is_equal and is_zero to static class for better visability
2015-05-05 13:26:50 +10:00
Tom Pittenger
bdda11b327
AP_Math: compiler warning: is_zero special case for vector3.h in a template
2015-05-05 13:26:50 +10:00
Andrew Tridgell
eca675c556
AP_Math: fix for HAL_SITL rename
2015-05-05 09:45:55 +10:00
Andrew Tridgell
24b051565b
AP_Math: added normalize() method to Matrix3f
2015-05-05 09:45:52 +10:00
Randy Mackay
fecbf06008
AP_Math: fix example sketches
2015-05-01 20:57:38 +09:00
Randy Mackay
eaedeeb7bf
AP_Math: add quaternion.initialise
2015-05-01 16:37:34 +09:00
Randy Mackay
0392292489
AP_Math: inline is_equal, add is_zero
2015-04-28 16:19:01 +09:00
dgrat
726d7df710
AP_Math: add is_equal to compare floats
2015-04-28 16:18:59 +09:00
Jonathan Challinger
3812773485
AP_Math: make quaternion divide by zero protection more conservative
2015-04-28 11:42:13 +10:00
Jonathan Challinger
fb8da1b2d8
AP_Math: add get_euler_(roll|pitch|yaw) functions to quaternion
2015-04-28 11:42:13 +10:00
Tom Pittenger
10c933966b
AP_Math: fix compile warning re float constants
2015-04-24 14:25:02 +09:00
Tom Pittenger
a8dda9f2ed
AP_Math: fix compile warnings re float constants
2015-04-24 14:03:54 +09:00
Jonathan Challinger
6baec4952b
AP_Math: add conversions to and from 3-1-2 euler angles
2015-04-07 21:20:51 -07:00
Jonathan Challinger
a1d4f40c16
AP_Math: change quaternion operator* and operator/ to const
2015-04-07 21:20:51 -07:00
Jonathan Challinger
07735fefa6
AP_Math: fix div by zero in quaternion
2015-04-07 21:20:51 -07:00
Andrew Tridgell
728dbf24db
AP_Math: fixed vector inequality test
...
many thanks to cat888
fixes issue #2039
2015-04-01 20:40:37 -07:00
Grant Morphett
300a02f4e4
AP_Math: Changes to fix the warnings in rover sitl build.
...
We are starting the process of resolving all the warnings in the
ardupilot builds of all vehicles and platforms.
2015-02-11 18:16:46 +11:00
Jonathan Challinger
5f7480b740
AP_Math: change fast_atan2 to use atan2f on fast CPUs
2015-02-09 22:24:09 +09:00
Paul Riseborough
255252f387
AP_Math: Fix bug in quaternion division
2015-02-03 09:49:16 +11:00
Paul Riseborough
17445d03f0
AP_Math: Add quaternion division
2015-02-03 09:49:16 +11:00
Randy Mackay
689cc9e298
AP_Math: fix example sketch
2015-01-28 17:15:43 +09:00
Andrew Tridgell
fefdc37a4d
AP_Math: fixed warnings on bounds checking in quaternion
2015-01-09 11:04:50 +11:00
Andrew Tridgell
6bb4a8c361
AP_Math: make location_path_proportion() and location_passed_point() more efficient
...
the dot product is much more efficient than the trigonometry. Thanks
to Paul for the suggestion
2015-01-03 14:06:59 +11:00
Jonathan Challinger
9e5a30d5ba
AP_Math: change ROTATION_YAW_293_PITCH_68_ROLL_180 to ROLL_90
2015-01-02 17:15:18 +09:00
Andrew Tridgell
f38f86ab8c
AP_Math: added location_path_proportion()
...
this can be used for glide slope calculations
2015-01-01 15:17:10 +11:00
Andrew Tridgell
38c5f25c70
AP_Math: fixed example build
2014-11-25 13:22:17 +11:00
Andrew Tridgell
8d54368650
AP_Math: fixed build warning
2014-11-25 08:17:15 +11:00
Randy Mackay
503d14428d
AP_Math: add new rotation to example rotation sketch
2014-11-22 14:10:00 +09:00
Randy Mackay
3d2c9910b3
AP_Math: add yaw 293, pitch 68, roll 180 rotation
2014-11-22 14:09:16 +09:00
Jonathan Challinger
cdd2199138
AP_Math: expand frame transformation test case for quaternions
2014-10-20 06:24:33 +11:00
Jonathan Challinger
3befe74afa
AP_Math: change quaternion class to use const references where optimal
2014-10-20 06:24:30 +11:00
Jonathan Challinger
70845882a7
AP_Math: fix up rotation test suite
2014-10-20 06:24:27 +11:00
Jonathan Challinger
1f7e393e38
AP_Math: refactor quaternion library
2014-10-20 06:24:22 +11:00
Andrew Tridgell
184c4c8ac5
AP_Math: fixed example build
2014-08-13 22:12:04 +10:00
Andrew Tridgell
917c9f7865
AP_Math: fixed example build
2014-08-13 21:48:35 +10:00
Daniel Frenzel
b1a9d6bbcc
AP_Math: Using const references in matrix3
...
Signed-off-by: Daniel Frenzel <dgdanielf@gmail.com>
2014-08-11 09:24:05 +10:00
Andrew Tridgell
b92873cab1
AP_Math: prevent negative longitude scaling
...
for crazy locations
2014-08-07 09:30:02 +10:00
Andrew Tridgell
03dc27147e
AP_Math: port examples to Linux
2014-07-29 15:49:38 +10:00
Andrew Tridgell
aa5940c378
AP_Math: fixed example build
2014-07-25 17:51:30 +10:00
Niels Joubert
398f32d538
AP_Math: Comments on WGS coordinate conversions
2014-06-30 10:29:56 +10:00
David Dewey
17374ff5e8
AP_Math: fast_atan2
...
This is 126us per call vs 199us on the AVR. it is accurate to about
0.28 degrees
Committed by rmackay9 but contribution is from David Dewey
2014-06-06 18:50:41 +09:00
Andrew Tridgell
7e5a491f14
AP_Math: prevent a floating point exception
2014-04-21 15:37:08 +10:00
Andrew Tridgell
e566802bf3
AP_Math: fixed example build
2014-04-07 07:37:34 +10:00
Niels Joubert
879eb5936b
AP_MATH: Adding WGS GPS conversions, CRC16 checks, and double-precision Vectors and Matrices
2014-04-05 13:42:23 +11:00
Andrew Tridgell
9278685cdf
AP_Math: fixed location build on SITL
2014-04-01 14:20:10 +11:00
Andrew Tridgell
acd54d0826
AP_Math: fixed example build
2014-03-19 12:13:48 +09:00
Andrew Tridgell
009913ec60
AP_Math: make is_nan const for quaternion and add .zero() for vector2
2014-02-21 20:24:47 +11:00
Andrew Tridgell
599c3a8abf
AP_Math: added more operators to VectorN
2014-02-19 10:14:58 +11:00
Andrew Tridgell
2df314799e
AP_Math: added tests for quaternion to/from rotation matrix
2014-02-15 12:20:51 +11:00
Andrew Tridgell
689f230d40
AP_Math: added quaternion.from_rotation_matrix()
2014-02-15 12:20:31 +11:00
Andrew Tridgell
c1dff6aa65
AP_Math: fixed example build
2014-02-15 06:39:43 +11:00
Andrew Tridgell
1e0f3f5398
AP_Math: make to_euler() const
2014-02-15 05:27:51 +11:00
Andrew Tridgell
90c41981ac
AP_Math: added quaternion normalization
2014-02-15 05:27:51 +11:00
Randy Mackay
37cfbc9ad5
AP_Math: float versions of wrap_360 and wrap_180
2014-02-15 05:27:45 +11:00
Randy Mackay
a963ec7e3b
AP_Math: bug fix to wrap_360 and wrap_180
...
angles above 720deg and below 3200deg might not have been properly
wrapped.
wrap_360_cd could return 36000 when really this should be wrapped back
to zero.
2014-02-03 12:56:56 +09:00
Andrew Tridgell
93070a673e
AP_Math: fixed example build
2014-01-30 13:33:46 +11:00
Andrew Tridgell
0d174db05b
AP_Math: added equality operator for VectorN
2014-01-24 10:37:08 +11:00
Paul Riseborough
f2c2811ef3
AP_AHRS & AP_Math: fixed bug in use of AHRS_TRIM parameters
2014-01-19 07:19:43 +11:00
Andrew Tridgell
4c99d09265
AP_Math: fixed build of vectorN class on PX4
2013-12-31 10:28:27 +11:00
Andrew Tridgell
96df09fd08
AP_Math: add const to quaternion API
2013-12-30 14:33:17 +11:00
Andrew Tridgell
2e9744d0b3
AP_Math: prevent transpose usage error in matrix API
2013-12-30 14:33:17 +11:00
Andrew Tridgell
2c1e0ba130
AP_Math: added vectorN class, and index checking
2013-12-30 14:33:17 +11:00
Andrew Tridgell
828eed1984
AP_Math: allow vector3 and matrix3 objects to be used as arrays
2013-12-29 18:39:09 +11:00
Andrew Tridgell
9b5b4ced60
AP_Math: fixed example build
2013-12-17 11:51:37 +11:00
Andrew Tridgell
57d5345774
AP_Math: added M_PI_F define
2013-12-11 10:22:47 +11:00
Andrew Tridgell
db400ffa51
AP_Math: added is_zero() method to Vector3
2013-12-09 17:34:06 +11:00
Andrew Tridgell
d2deee07df
AP_Math: fixed zero function for integer vectors
2013-11-07 12:48:16 +11:00
Andrew Tridgell
fb19dbb404
AP_Math: cope with large values passed into the wrap functions
...
this uses modulus if the function would loop too many times
Pair-Programmed-With: Randy Mackay <rmackay9@yahoo.com>
2013-10-03 12:21:07 +10:00
Andrew Tridgell
18896d9c9b
AP_Math: fixed DOS CR/LF errors
2013-09-19 16:26:32 +10:00
Andrew Tridgell
84ed2141a0
AP_Math: fixed float rounding in location_offset()
...
this prevents rounding of positions in the rover code
2013-09-16 11:38:55 +10:00
Andrew Tridgell
97b7130bb9
libraries: update license header to GPLv3
...
we switched to GPLv3 a long time ago, but neglected to update the
per-file license headers
2013-08-30 13:01:39 +10:00
Andrew Tridgell
873e54deb1
AP_Math: fixed example build
2013-08-30 13:01:39 +10:00
Andrew Tridgell
4c752e4a94
AP_Math: simplify rotations test code
2013-08-30 13:01:34 +10:00
Andrew Tridgell
e2b0e07973
AP_Math: removed unused matrix rotation code
...
we only need to rotate vectors
2013-08-30 13:01:34 +10:00
Andrew Tridgell
a295a01bbc
AP_Math: added missing 90 degree rotations
...
this ensures we can handle all 90 degree rotations of the compass and
main board. A test in examples/rotations shows that we have them all.
2013-08-30 13:01:33 +10:00
Andrew Tridgell
2b1fcc964f
AP_Math: added a quick test of floating point location accuracy
...
just confirming some maths ...
2013-08-30 13:01:32 +10:00
Andrew Tridgell
5434b2c017
AP_Math: update location code to avoid float rounding
...
this avoids manipulating global coordinates as float variables. Using
a float reduces our precision from 1cm to about 70cm.
This also adds location_diff() which will be used in the L1 controller
to avoid global positions in floats
2013-08-13 12:07:34 +10:00
Andrew Tridgell
9cb6c987d4
AP_Math: fixed example build
2013-08-05 12:37:51 +10:00
Andrew Tridgell
1d75b52411
AP_Math: use const references not pointers for location functions
...
this makes life a bit easier for the new AP_Mission library
Pair-Programmed-With: Brandon Jones <brnjones@gmail.com>
2013-08-05 10:23:40 +10:00
Andrew Tridgell
468e55d425
AP_Math: added two new vector/matrix ops for kalman airspeed filter
2013-07-22 12:50:00 +10:00
Randy Mackay
540ca25b84
AP_Math: add rotateXY
2013-07-20 17:59:06 +09:00
Randy Mackay
bd6a60f28b
AP_Math: add M_PI_2 definition
...
Required when building under arduino
2013-07-14 15:57:26 +09:00
Andrew Tridgell
8c49ed78a5
AP_Math: make the rotation numbers easier to find
2013-07-08 12:17:59 +10:00
Randy Mackay
8b87849acd
Math: add wrap_PI
2013-06-01 18:21:29 +09:00
Randy Mackay
d81b7b507d
Math: add Leonard's fast tan function
2013-05-30 18:24:32 +09:00
Andrew Tridgell
5024da2695
AP_Math: fixed indent-tabs-mode
2013-05-30 09:51:51 +10:00
Randy Mackay
7c9d9b9800
AP_Math: use DEG_TO_RAD in longitude_scale
...
Also increased accuracy of RadiansToCentiDegrees although it is like the
compiler will throw away the extra digits anyway.
2013-05-05 14:31:24 +09:00
Andrew Tridgell
737f0305ef
AP_Math: implement vector2 cross product
...
useful in DCM for faster yaw correction
2013-05-05 13:47:51 +10:00
Andrew Tridgell
f4189e083b
AP_Math: added mulXY() for matrix3 and vector3
...
returns the XY components of the product
2013-05-05 13:47:23 +10:00
Andrew Tridgell
ba83950fc4
libraries: replace constrain() with constrain_float()
...
this makes the type much more obvious. Thanks to Tobias for the
suggestion.
2013-05-02 10:25:40 +10:00
Andrew Tridgell
e1f9297551
AP_Math: move print_latlon() to location.cpp
2013-04-20 13:52:36 +10:00
Andrew Tridgell
83dc7dbc92
AP_Math: handle NaN in constrain(), returning average
...
this makes it less likely a NaN will propogate
2013-04-15 14:28:51 +10:00
Andrew Tridgell
43c3c60de2
AP_Math: moved a lot of vector templates to cpp from .h
...
this reduces the code size quite a lot on AVR
2013-04-12 12:48:08 +10:00
Andrew Tridgell
78eb12a4ac
AP_Math: added RadiansToCentiDegrees and RADIUS_OF_EARTH
2013-04-12 12:48:08 +10:00
Andrew Tridgell
8b119934ea
AP_Math: fixed grammar error
2013-04-12 12:48:08 +10:00