mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
AP_Math: Remove fabsf from kinematic_limit clean up
This commit is contained in:
committed by
Peter Barker
parent
0760b4c7c0
commit
c2045d7198
@@ -725,7 +725,7 @@ float kinematic_limit(Vector3f direction, float max_xy, float max_z_neg, float m
|
||||
float kinematic_limit(float dir_xy, float dir_z, float max_xy, float max_z_neg, float max_z_pos)
|
||||
{
|
||||
// Reject invalid limits
|
||||
if (!is_positive(max_xy) || !is_positive(max_z_pos) || !is_positive(max_z_neg)) {
|
||||
if (is_negative(dir_xy) || !is_positive(max_xy) || !is_positive(max_z_pos) || !is_positive(max_z_neg)) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@@ -755,21 +755,21 @@ float kinematic_limit(float dir_xy, float dir_z, float max_xy, float max_z_neg,
|
||||
|
||||
if (is_positive(slope)) {
|
||||
// Positive-Z: constrained by max_z_pos
|
||||
if (fabsf(slope) < max_z_pos / max_xy) {
|
||||
if (slope < max_z_pos / max_xy) {
|
||||
// Shallow direction: horizontal limit reached first
|
||||
return max_xy / dir_xy;
|
||||
}
|
||||
// Steep direction: vertical limit reached first
|
||||
return fabsf(max_z_pos / dir_z);
|
||||
return max_z_pos / dir_z;
|
||||
}
|
||||
|
||||
// Negative-Z: constrained by max_z_neg
|
||||
if (fabsf(slope) < max_z_neg / max_xy) {
|
||||
if (-slope < max_z_neg / max_xy) {
|
||||
// Shallow direction: horizontal limit reached first
|
||||
return max_xy / dir_xy;
|
||||
}
|
||||
// Steep direction: vertical limit reached first
|
||||
return fabsf(max_z_neg / dir_z);
|
||||
return -max_z_neg / dir_z;
|
||||
}
|
||||
|
||||
// Applies an exponential curve to a normalized input in the range [-1, 1].
|
||||
|
||||
Reference in New Issue
Block a user