Commit Graph

656 Commits

Author SHA1 Message Date
Andrew Tridgell 53e5bef0c2 AP_Math: added rotate_xy to Vector3f
this makes it easy to rotate a vector3f in xy plane for earth/body
navigation
2021-05-24 20:13:37 +10:00
Leonard Hall c4bb8baf0c AP_Math: Control: Add XY S-Curve shapers and shaping limits 2021-05-24 20:13:37 +10:00
Leonard Hall 3530d9121f AP_Math: minor format fix to SCurve::advance_target_along_track 2021-05-12 19:53:57 +09:00
Tom Pittenger ba6bb21560 AP_Math: added helper for16bit float conversions 2021-04-28 19:22:53 -07:00
hs293go 93a13bbf0e AP_Math: Implement tests for the Quaternion class
These tests cover Quaternion multiplication, conversion to rotation
matrix, and the optimized rotation operator
2021-04-19 15:34:45 +10:00
hs293go 8bc02ab00b AP_Math: Implement quaternion vector rotation operator
Overloads operator*() with semantics of applying a rotation to a vector, in
common with usage in Eigen/OpenGL. This implementation carries out 30
operations, compared to 58 operations for the q*v*q.inverse() formula
2021-04-19 15:34:45 +10:00
Randy Mackay bc0da915c4 AP_Math: add SplineCurve library
Co-authored-by: Leonard Hall <leonardthall@gmail.com>

includes corrections from peer review
2021-04-03 12:07:59 +09:00
Leonard Hall af7403f4e9 AP_Math: add SCurve library
SCurve const more local variables
rename update to get_jerk_vel_pos_at_time
removed unused update
debug output in SITL
fixes to ensure finished at end of path
fixes including validity check
includes corrections from peer review
2021-04-03 12:07:59 +09:00
Randy Mackay 0e506a71a1 AP_Math: remove control's limit_vector_length
these have been moved to Vector2f and Vector3f
2021-04-03 12:07:59 +09:00
Randy Mackay e2b46d05dc AP_Math: Vector2,3 get limit_length methods 2021-04-03 12:07:59 +09:00
Leonard Hall 3bb0482795 AP_Math: add update_pos_vel_accel to control
also add shape_vel, shape_pos_vel and stopping_distance
also add calculation of kinematic limits
2021-04-03 12:07:59 +09:00
Andrew Tridgell 1f60eb68ec AP_Math: removed assert calls
these waste flash space and do not do us any good
2021-03-25 14:03:40 +11:00
Andrew Tridgell e884e4c5ac AP_Math: added fixedwing_turn_rate() helper 2021-02-27 14:42:20 +11:00
Patrick José Pereira 5d7d955378 AP_Math: Add missing const in member functions
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2021-02-03 18:45:14 +11:00
Rishabh f3d825bebe AP_Math: Add unit tests for 3-D lines 2021-02-01 14:34:13 +09:00
Rishabh 1262d73071 AP_Math: Add new methods to support 3D avoidance 2021-02-01 14:34:13 +09:00
Rishabh 79d5e432ee AP_Math: Add new method to extrapolate 3D vector given distance, yaw, pitch 2021-02-01 14:34:13 +09:00
Andrew Tridgell a1fb0592a9 AP_Math: specialise polyfit for vectors
this is needed to get the precision good enough for wide temperature
ranges when summing the resulting polygon coefficients
2021-01-21 13:09:21 +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 64d9f43d94 AP_Math: added polygon fitting code 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
Peter Barker c81df7b5ad AP_Math: add tests for circle-segment-intersection 2021-01-04 13:58:42 +11:00
Peter Barker f534963413 AP_Math: consolidate error checking 2021-01-04 13:58:42 +11:00
murata 4ffc559ccc AP_Math: judge isnan judgment before operation 2021-01-04 13:58:42 +11:00
Gone4Dirt 5edae526fd AP_Math: Add conversion Ams to mAh 2020-11-24 12:54:52 +11:00
Andrew Tridgell 806852c9c3 AP_Math: speedup fill nanf 2020-11-10 16:15:45 +11:00
Andrew Tridgell cdcf32d22c AP_Math: added calc_lowpass_alpha_dt()
used in several places
2020-11-10 16:15:45 +11:00
Andrew Tridgell a56f07b74d AP_Math: allow build without other headers for vector2.h 2020-11-10 16:15:45 +11:00
Andrew Tridgell c0b20881d6 AP_Math: allow vector3.h to be included earlier in include chain 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
Andrew Tridgell 747b48d0a8 AP_Math: added crc_sum8
for FPort/FPort2
2020-10-28 09:00:34 +11:00
murata 9714d8dde9 AP_MAth: Move the CRC24 to the AP_Math class 2020-10-21 18:24:07 +11:00
Patrick José Pereira 6ee401cb00 AP_Math: Remove isnan check for non-float type
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
2020-10-16 09:22:05 +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 a0f25640a2 Revert "AP_Math: add bitwise fetch/load 16, 24, 32bit operations"
This reverts commit 6efaa29577.
2020-10-07 19:11:38 +11:00
Tom Pittenger ee8f50e6a5 Revert "AP_Math: fix LoadUint() to allow 32bit values"
This reverts commit 5e2450c4ea.
2020-10-07 19:11:38 +11:00
Tom Pittenger 5e2450c4ea AP_Math: fix LoadUint() to allow 32bit values 2020-10-05 15:32:53 -07:00
Tom Pittenger 6efaa29577 AP_Math: add bitwise fetch/load 16, 24, 32bit operations 2020-09-15 13:09:50 -07: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
Pierre Kancir 240c34ecde AP_Math: add missing ; on benchmark test 2020-09-06 19:13:04 +10:00
yaapu 144f7df02f AP_Math: added CRCs needed by AP_MSP 2020-09-02 05:56:46 +10:00
bugobliterator a8d36a37c4 AP_Math: ensure that we use environment Python interpreter 2020-08-03 14:02:09 +10:00
Andy Piper d4c5b945b3 AP_Math: move crc8_dvb_s2 here and add additional crc8 functions 2020-07-07 18:48:06 +10:00
Andrew Tridgell b6a5509409 AP_Math: added test for vector2f rotate 2020-07-06 14:46:48 +10:00
Andrew Tridgell 24d0804249 AP_Math: added rotate() method to Vector2f 2020-07-06 14:46:48 +10:00
Rishabh 0779cf436e AP_Math: Added function to calculate shortest distance betwwen point and line segment in 3D 2020-06-19 09:45:34 +09:00
Peter Barker 2f8c0dd65b AP_Math: remove use of Vector3 as function 2020-06-16 11:06:47 +10:00
Peter Barker dad5b4e903 AP_Math: remove use of Vector2 as function 2020-06-16 11:00:44 +10:00
Andrew Tridgell a56a7f7da4 AP_Math: added more vector3f ops for lua 2020-06-04 09:49:52 +10: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
bugobliterator 05fe49a51f AP_Math: disable INEXACT flag from Float exception 2020-05-17 16:12:43 +10:00
Andrew Tridgell 3e853344f3 AP_Math: avoid build warnings 2020-05-10 15:11:22 +10:00
Peter Barker 58a8e54d83 AP_Math: create and use INTERNAL_ERROR macro so we get line numbers 2020-04-30 13:21:36 +10:00
Mark Whitehorn 7d3d664ddf AP_Math: generate internalError on call to Vector3<T>::rotate and Quaternion::from_rotation with bad rotation value 2020-04-28 10:52:21 +10:00
Randy Mackay 9fd39f3768 AP_Math: alternative quaternion rotation test 2020-04-09 19:41:08 +09:00
Randy Mackay 26e4dd6fef AP_Math: correct quaternion::from_rotation for pitch-180 2020-04-09 19:41:08 +09:00
Randy Mackay c18fce6714 AP_Math: add quaternion rotation test 2020-04-09 19:41:08 +09:00
Randy Mackay 61a06bbb04 AP_Math: add quaternion rotate, from_rotation and invert 2020-04-09 19:41:08 +09:00
Randy Mackay 338548c5eb AP_Math: move HALF_SQRT_2 def to rotation.h
This allows it to be used by the Quaternion class
2020-04-09 19:41:08 +09:00
Samuel Tabor 45cb663d73 AP_Math: Add template for Vector2f::projected. 2020-04-08 09:11:54 +10:00
Randy Mackay 9c8a5a7392 AP_Math: add comments above some quaternion methods
thanks to jchallinger
2020-04-03 10:16:07 +09:00
Randy Mackay 7a48a3f354 AP_Math: minor comment fix 2020-03-30 20:20:02 +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 f908e56154 AP_Math: define ROTATION_MAX_AUTO_ROTATION
we don't want to use ROTATION_PITCH_7 in our auto rotation mix, as it
is too close to level
2020-01-01 16:59:27 +11:00
Randy Mackay f87ae7d445 AP_Math: add vector2f::offset_bearing 2020-01-01 13:38:41 +09:00
Andrew Tridgell ff2cfbaafb AP_Math: added smaller footprint crc32 2019-10-28 15:53:16 +11:00
Siddharth Purohit fb48d8ee1b AP_Math: add method for generating hash 2019-10-19 09:55:38 +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 189ef5f1e7 AP_Math: define != for Vector2<int> 2019-09-28 07:58:48 +09:00
Andrew Tridgell 13a2367278 AP_Math: change optimisation from -O3 to -O2 2019-09-28 08:57:26 +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 84d999142f AP_Math: add more tests for wrap functions 2019-09-18 12:57:02 +10:00
Randy Mackay c7ca9c04f8 AP_Math: add comment to vector2f::point_on_segment 2019-08-10 12:21:01 +09:00
Peter Barker 4c434c2df9 AP_Math: add WARN_IF_UNUSED to bool methods 2019-07-26 09:26:02 +09:00
Andrew Tridgell 2480a62e55 AP_Math: added speed/distance conversions 2019-07-13 11:05:57 +10:00
murata c5a471e778 AP_Math: Common modbus crc method 2019-07-12 15:33:21 +10:00
Randy Mackay 614b0f6dc8 AP_Math: Polygon_intersects handles unclosed polygons 2019-07-07 04:08:34 -07:00
Peter Barker da5d5c9203 AP_Math: add tests for Vector2 2019-06-13 19:36:49 +10:00
Randy Mackay c2bcc0d5f0 AP_Math: define Vector2f::perpendicular 2019-06-11 13:13:22 +09:00
Randy Mackay 071e340827 AP_Math: Polygon_closest_distance_line returns neg numbers
value is negative distance from intersection to p2
2019-06-11 13:13:22 +09:00
Andrew Tridgell 6eb816fd3b AP_Math: add Polygon_closest_distance_line
Also add optimisations
2019-06-11 13:13:22 +09:00
Andrew Tridgell a5fd7ac5ca AP_Math: add vector2f::closest_distance_between_line_and_point_squared
also add vector2f::closest_distance_between_line_and_point and vector2f::closest_distance_between_lines_squared
2019-06-11 13:13:22 +09:00
Andrew Tridgell 2457bf71d4 AP_Math: add simplified vector2f::closest_point
this simpler version assumes the line segment originates at the origin
2019-06-11 13:13:22 +09:00
Andrew Tridgell c8e49259a0 AP_Math: add vector2f::closest_distance_between_radian_and_point_squared 2019-06-11 13:13:22 +09:00
Andrew Tridgell dbf337e1b3 AP_Math: move closest_point to cpp 2019-06-11 13:13:22 +09:00
Andrew Tridgell bfc28dfde9 AP_Math: move normalize, reflect, project and perpendicular to cpp 2019-06-11 13:13:22 +09:00
Andrew Tridgell 01e541b7d1 AP_Math: minor formatting changes to length method 2019-06-11 13:13:22 +09:00
Andrew Tridgell 4c4de1f021 AP_Math: vector2f::length_squared always returns float 2019-06-11 13:13:22 +09:00
Andrew Tridgell 46617e6c72 AP_Math: remove unused include from Vector2 2019-06-11 13:13:22 +09:00
Andrew Tridgell 69781cda42 AP_Math: add Vector2::angle 2019-06-11 13:13:22 +09:00
Peter Hall ea4ecebfc4 AP_Math: add speed unit converstion defs 2019-06-03 10:48:19 +09:00
Peter Barker e4de5a17d1 AP_Math: add pitch-7 to rotation tests 2019-05-29 17:12:32 +10:00
Andrew Tridgell e2eda63d2c AP_Math: added new rotation for PITCH_7 2019-05-29 17:12:32 +10:00