Commit Graph

60 Commits

Author SHA1 Message Date
Dr.-Ing. Amilcar Do Carmo Lucas e13281ab2d AP_Math: add overloaded functions get_horizontal_distance_cm() and get_bearing_cd() (NFC) 2017-12-05 08:54:49 +09:00
Dr.-Ing. Amilcar Do Carmo Lucas ec1790dad9 AP_Math: Use DEGX100 define instead of hardcoded value (NFC) 2017-12-05 08:54:49 +09:00
Tom Pittenger 1abeb03d2b AP_Math: remove HAL_CPU_CLASS_16 2017-04-12 17:25:30 -07:00
Michael du Breuil 97c57764c4 AP_Math: Add a 3D location difference, returning NED 2017-02-13 09:23:14 +11:00
Lucas De Marchi 87038d8ef1 AP_Math: add casts to consider literals as doubles
Since we pass -fsingle-precision-constant to the compiler, add casts to
make literals real doubles.
2017-02-06 09:27:22 -08:00
murata f9add59b58 Global: Aggregate the same definitions.
Global: Aggregate the same definitions.
2016-11-09 11:46:55 -03:00
Mathieu OTHACEHE 152edf7189 Global: remove mode line from headers
Using a global .dir-locals.el file is a better alternative than
reincluding the same emacs header in every file of the project.
2016-10-24 09:42:01 -02:00
Tom Pittenger 00aaa78757 AP_Math: add separate check_lat() and check_lng() 2016-06-06 13:02:56 -07: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
Ricardo de Almeida Gonzaga 481e3a2af6 AP_Math: Fix typos 2016-05-13 19:20:06 -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
dgrat 76362caee0 AP_Math: Replace wrap_* functions with template versions 2016-05-10 11:41:26 -03:00
Andrew Tridgell e8142b0b5b AP_Math: added wrap_360() 2016-05-07 18:27:21 +10:00
Michael du Breuil bb7cf6c0b6 AP_Math: Update location_sanitize to sanitize for lat/lng 2016-04-17 19:00:03 -07: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
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
Jonathan Challinger fff275fd99 AP_Math: add wrap_2PI 2015-12-09 19:58:25 +09: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 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 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
Randy Mackay 6145794da2 AP_Math: remove duplicate RADIUS_OF_EARTH definition 2015-10-05 21:00:14 +09: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
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
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 0b897e04bb AP_Math: revert AP_Math class change 2015-05-05 13:27:06 +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
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
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 b92873cab1 AP_Math: prevent negative longitude scaling
for crazy locations
2014-08-07 09:30:02 +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
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 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 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 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 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
Randy Mackay 8b87849acd Math: add wrap_PI 2013-06-01 18:21:29 +09: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 e1f9297551 AP_Math: move print_latlon() to location.cpp 2013-04-20 13:52:36 +10:00
Andrew Tridgell 8b119934ea AP_Math: fixed grammar error 2013-04-12 12:48:08 +10:00
tobias 217b8d7a59 cleanup: use const for struct Location pointers and references
this allows the compiler to generate more efficient code
2013-04-09 12:10:32 +10:00
Andrew Tridgell 091b474a1d AP_Math: added wrap_360_cd() and wrap_180_cd()
moved from per-vehicle code
2013-03-29 13:13:37 +11:00
Randy Mackay 7729ec950e AP_Math: longitude_scale function made public
Added LATLON_TO_M and LATLON_TO_CM #defines
2013-01-27 23:21:39 +09:00
Randy Mackay d2767b911c AP_Math: switch get_distance_cm to return uint32_t
Includes changes required on ArduCopter and ArduPlane side as well
2013-01-26 17:04:12 +09:00
James Bielman 5631f865b2 Update floating point calculations to use floats instead of doubles.
- Allows use of hardware floating point on the Cortex-M4.
- Added "f" suffix to floating point literals.
- Call floating point versions of stdlib math functions.
2013-01-16 13:52:01 +11:00
Andrew Tridgell d8bed0c2aa AP_Math: fixed get_distance() function 2012-12-20 14:53:23 +11:00