From 092730c32ee5e8d94422fb9cd5c62e2fd8739891 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Tue, 23 Nov 2021 19:58:44 +0900 Subject: [PATCH] AP_Math: update_pos_vel_accel methods accept limit as const reference also update some comments --- libraries/AP_Math/control.cpp | 6 +++--- libraries/AP_Math/control.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/AP_Math/control.cpp b/libraries/AP_Math/control.cpp index 13b1586bd5..1f28aee248 100644 --- a/libraries/AP_Math/control.cpp +++ b/libraries/AP_Math/control.cpp @@ -37,7 +37,7 @@ void update_vel_accel(float& vel, float accel, float dt, float limit) } } -// update_pos_vel_accel - single axis projection of position and velocity, pos and vel, forwards in time based on a time step of dt and acceleration of accel. +// update_pos_vel_accel - single axis projection of position and velocity forward in time based on a time step of dt and acceleration of accel. // the position and velocity is not moved in the direction of limit if limit is not set to zero void update_pos_vel_accel(postype_t& pos, float& vel, float accel, float dt, float limit) { @@ -52,7 +52,7 @@ void update_pos_vel_accel(postype_t& pos, float& vel, float accel, float dt, flo // update_vel_accel - dual axis projection of position and velocity, pos and vel, forwards in time based on a time step of dt and acceleration of accel. // the velocity is not moved in the direction of limit if limit is not set to zero -void update_vel_accel_xy(Vector2f& vel, const Vector2f& accel, float dt, Vector2f limit) +void update_vel_accel_xy(Vector2f& vel, const Vector2f& accel, float dt, const Vector2f& limit) { // increase velocity by acceleration * dt if it does not increase error when limited. Vector2f delta_vel = accel * dt; @@ -68,7 +68,7 @@ void update_vel_accel_xy(Vector2f& vel, const Vector2f& accel, float dt, Vector2 // update_pos_vel_accel - dual axis projection of position and velocity, pos and vel, forwards in time based on a time step of dt and acceleration of accel. // the position and velocity is not moved in the direction of limit if limit is not set to zero -void update_pos_vel_accel_xy(Vector2p& pos, Vector2f& vel, const Vector2f& accel, float dt, Vector2f limit) +void update_pos_vel_accel_xy(Vector2p& pos, Vector2f& vel, const Vector2f& accel, float dt, const Vector2f& limit) { // move position and velocity forward by dt. Vector2f delta_pos = vel * dt + accel * 0.5f * sq(dt); diff --git a/libraries/AP_Math/control.h b/libraries/AP_Math/control.h index 3da0dff6d1..0084e9a81e 100644 --- a/libraries/AP_Math/control.h +++ b/libraries/AP_Math/control.h @@ -29,15 +29,15 @@ typedef Vector3f Vector3p; // update_vel_accel - single axis projection. void update_vel_accel(float& vel, float accel, float dt, float limit); -// update_vel_accel projects the velocity, vel, forward in time based on a time step of dt and acceleration of accel. -// update_vel_accel - single axis projection. +// update_pos_vel_accel - single axis projection of position and velocity forward in time based on a time step of dt and acceleration of accel. +// the position and velocity is not moved in the direction of limit if limit is not set to zero void update_pos_vel_accel(postype_t & pos, float& vel, float accel, float dt, float limit); // update_pos_vel_accel_xy - dual axis projection operating on the x, y axis of Vector2f or Vector3f inputs. -void update_vel_accel_xy(Vector2f& vel, const Vector2f& accel, float dt, Vector2f limit); +void update_vel_accel_xy(Vector2f& vel, const Vector2f& accel, float dt, const Vector2f& limit); // update_pos_vel_accel_xy - dual axis projection operating on the x, y axis of Vector2f or Vector3f inputs. -void update_pos_vel_accel_xy(Vector2p& pos, Vector2f& vel, const Vector2f& accel, float dt, Vector2f limit); +void update_pos_vel_accel_xy(Vector2p& pos, Vector2f& vel, const Vector2f& accel, float dt, const Vector2f& limit); /* shape_accel calculates a jerk limited path from the current acceleration to an input acceleration. The function takes the current acceleration and calculates the required jerk limited adjustment to the acceleration for the next time dt.