Commit Graph
843 Commits
Author SHA1 Message Date
Leonard Hall fa8e927743 AP_Math: SCurve: remove redundant arc path_unit normalization 2026-08-04 11:19:49 +10:00
Leonard Hall ae252883c5 AP_Math: SCurve: remove unreachable arc degeneracy guard 2026-07-28 10:47:40 +09:00
Leonard Hall 67052e7f79 AP_Math: SCurve: fix arc velocity/accel for climbing arcs 2026-07-28 10:47:40 +09:00
Leonard Hall 5c91c80c76 AP_Math: SCurve: base arc kinematic limits on arc length not chord 2026-07-28 10:47:40 +09:00
Leonard Thall 044b249da5 AP_Math: limit_accel_xy: take a normalised velocity, fade below 0.25 2026-07-27 12:10:17 +09:00
ChrisRosserandClaude Opus 4.8 99619ec9bc AP_Math: fade cross-track accel prioritisation to zero near zero speed
limit_accel_xy() splits the acceleration command into along-track and
cross-track components using the normalised velocity, and prioritises the
cross-track component when the command saturates the maximum lean angle.

As the velocity vector rotates through zero (e.g. a hard stick reversal in
Loiter, where forward speed passes through zero before reversing) the unit
velocity spins rapidly. With any small residual lateral velocity (wind crab,
residual velocity from prior manoeuvring) this re-projects the saturated
longitudinal braking command onto a rapidly rotating axis and emits a large
lateral acceleration spike, seen as a roll wobble at the moment of the stop
and as a PSCE.TAE spike at each PSCN.VN zero crossing.

Fade the cross-track prioritisation out to a direction-preserving magnitude
limit below LIMIT_ACCEL_XY_MIN_SPEED_MS (1 m/s). Above that speed behaviour is
unchanged, so path/corner tracking is unaffected. The limiter only acts when
the command saturates the lean-angle limit, and stationary hold already used
the isotropic branch, so precision position hold is unaffected.

Adds a regression test sweeping velocity through zero and asserting no lateral
acceleration is injected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-27 12:10:17 +09:00
94xhn 20b9e346e5 AP_Math: fix Polygon_closest_distance_line to include closing edge
Polygon_closest_distance_line()'s fallback loop (used whenever the
query line does not cross the polygon) iterated i=0..N-2 and never
tested the closing edge V[N-1]->V[0]. Every other polygon helper in
this file (Polygon_outside, Polygon_intersects) and the sibling
Polygon_closest_distance_point() already wrap around to include this
edge; this function was the one left behind.

The only caller, AP_OABendyRuler::calc_margin_from_inclusion_and_exclusion_polygons(),
passes in AC_Fence polygons in their raw unclosed form (no duplicated
closing vertex), so in real fences this is a genuine edge that was
silently skipped, causing the reported clearance/margin to the fence
boundary to be overestimated near that edge.

Fix mirrors the existing wrap-around pattern from Polygon_intersects()
a few lines above in the same file. Added a regression test using a
simple square fence to confirm the closing edge is now considered and
that behaviour near unaffected edges is unchanged.

Assisted-by: Claude:claude-sonnet-5
2026-07-13 09:43:45 +10:00
Michelle Rossouw e716854cbb AP_Math: Log SCurve for Blimp as well 2026-06-02 17:46:27 +10:00
George Zogopoulos 6f4d04ecb5 AP_Math: Typo fix 2026-05-26 22:31:38 +10:00
Hunter McClelland f2b8d052b4 AP_Math: unit tests for kinematic_limit() 2026-05-26 22:31:04 +10:00
Leonard Hall 347e4b0a5f SCurve: deduplicate empty segment fill and constant jerk loop 2026-04-20 19:37:29 +09:00
Leonard Hall a605c03bb4 AP_Math: SCurve: extract extend_const_vel_to helper 2026-04-20 19:37:29 +09:00
Leonard Hall c2045d7198 AP_Math: Remove fabsf from kinematic_limit clean up 2026-04-15 15:43:13 +10:00
Leonard Hall 0760b4c7c0 AP_Math: Clarify kinematic_limit clean up 2026-04-15 15:43:13 +10:00
Leonard Hall f025da2fd8 AP_Math: add constraint validation to calculate_path tests 2026-04-14 10:29:49 +09:00
Leonard Hall 0b4020f7a1 SCurve: fix comment, whitespace and operator spacing 2026-04-14 10:29:49 +09:00
Leonard Hall 0918f5ef23 SCurve: use consistent float literals throughout 2026-04-14 10:29:49 +09:00
Leonard Hall 7e68cdc8d5 SCurve: fix path length sign, integer division, and divide-by-zero bugs 2026-04-14 10:29:49 +09:00
Leonard Hall 22df7b8ac7 AP_Math: add comprehensive calculate_path tests covering all code paths 2026-04-14 10:29:49 +09:00
Leonard Hall 74b078e67c AP_Math: Clarify kinematic_limit behavior and improve naming 2026-04-14 09:06:33 +09:00
Magnus Lindhé bcd11bf8ac AP_Math: Add checksum function used by AP_ExternalAHRS_SensAItion 2026-03-20 09:32:48 +11:00
Peter Barker f17b91326b AP_Math: provide float and double norm variants 2026-02-11 18:37:04 +11:00
Leonard Hall bc6e5150f6 AP_Math: Support future plane command model requirements. 2026-02-04 18:38:37 +11:00
Peter Barker cbcb3ba3c7 AP_Math: stop gating wrap_Pi<double> on AP_MATH_ALLOW_DOUBLE_FUNCTIONS 2026-01-28 19:17:49 +11:00
Peter Barker 0c26780cce AP_Math: add separate double and float implementations for wrap_PI and wrap_2PI
avoids double promotion when the argument is not double
2026-01-28 19:17:49 +11:00
Leonard Hall 8d30995077 AP_Math: limit_accel_corner_xy: Improve function readability. 2026-01-26 19:07:31 -05:00
Leonard Hall 420ddafa1a AP_Math: Shaper algorithm - limit handling update 2026-01-26 19:07:31 -05:00
Leonard Hall 801ac6ad64 AP_Math: limit_accel_corner_xy: Improve post corner cross track behavior 2026-01-26 19:07:31 -05:00
Leonard Hall 5170571b51 AP_Math: Simplify Shaper algorithm, same behavior 2026-01-26 19:07:31 -05:00
Leonard Hall 4d07b4216a AP_Math: limit_accel_corner_xy: Improve corner behavior 2026-01-26 19:07:31 -05:00
Leonard Hall 2f5e5e7c6b AP_Math: Tighten sqrt_controller_accel input checks 2026-01-26 19:07:31 -05:00
Leonard Hall 4692e07845 AP_Math: Update shaping to use improved command model 2026-01-26 19:07:31 -05:00
nttedt-murata 8df51a9917 AP_Math: Add an 8-bit constrain function 2026-01-27 08:47:40 +11:00
Leonard Hall 84bf935c1c AP_Math: Control: Add limit_accel_corner_xy 2026-01-08 11:50:49 +11:00
Leonard Hall aba26e9882 AP_Math: Control: Name and comment changes 2026-01-08 06:43:51 +11:00
Leonard Hall 1fc79cdd48 AP_Math: Fix NEU to NED comments 2025-12-17 08:03:10 +09:00
Leonard Hall acc584da2a AP_Math: NEU to NED renaming - Conversion 2025-12-17 08:03:10 +09:00
Leonard Hall f784181dba AP_Math: Ensure sign of speed and acceleration limits 2025-11-21 13:01:44 +09:00
Leonard Hall 160936cec0 AP_Math: Comment Change No compiler change 2025-11-14 10:01:37 +11:00
Leonard Hall d650d534f9 AP_Math: Support SCurve Arcs 2025-11-12 20:47:30 +11:00
Andy Piper 2b670c6124 AP_Math: return direction and length of closest segment to point from Polygon_closest_distance_point() 2025-11-05 18:24:54 +11:00
davydrybak e682702ded AP_Math: tests: include <signal.h> on macOS for sigemptyset() 2025-10-16 17:30:48 -05:00
llandThomas Watson 579a350ef0 AP_Math: add quaternion division annotation
Co-authored-by: Thomas Watson <twatson52@mac.com>
2025-09-30 13:03:40 -05:00
Leonard Hall ef7c4935bd AP_Math: Convert to postype 2025-09-26 10:35:25 +09:00
Peter Barker 6a95df2f4e AP_Math: replace ALLOW_DOUBLE_MATH_FUNCTIONS with AP_MATH_ALLOW_DOUBLE_FUNCTIONS
.... and this one is always defined, so check for truth!
2025-07-26 15:56:56 +10:00
Peter Barker 3708936c62 global: correct shebang lines to refernce python3
also remove the odd encoding line which is not required in Py3
2025-07-22 10:45:57 +10:00
Leonard Hall bb3c031049 AP_Math: Remove units on get_horizontal_distance 2025-07-17 09:12:37 +09:00
Leonard Hall df6e48f1fd AP_Math: Control: Improve comments 2025-07-11 13:50:33 +09:00
Leonard Hall 5a06f14dff AP_Math: No Compiler Change 2025-07-11 13:50:33 +09:00
Leonard Hall a33e6d9e8f AP_Math: support get_bearing_to_target_rad 2025-07-07 09:28:56 +09:00