@ -39,7 +39,7 @@ void update_vel_accel(float& vel, float accel, float dt, float limit)
@@ -39,7 +39,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.
// the position and velocity is not moved in the direction of limit if limit is not set to zero
void update_pos_vel_accel ( floa t& pos , float & vel , float accel , float dt , float limit )
void update_pos_vel_accel ( postype_ t& pos , float & vel , float accel , float dt , float limit )
{
// move position and velocity forward by dt if it does not increase error when limited.
float delta_pos = vel * dt + accel * 0.5f * sq ( dt ) ;
@ -68,7 +68,7 @@ void update_vel_accel_xy(Vector2f& vel, const Vector2f& accel, float dt, Vector2
@@ -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 ( Vector2f & 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 , Vector2f limit )
{
// move position and velocity forward by dt.
Vector2f delta_pos = vel * dt + accel * 0.5f * sq ( dt ) ;
@ -81,7 +81,7 @@ void update_pos_vel_accel_xy(Vector2f& pos, Vector2f& vel, const Vector2f& accel
@@ -81,7 +81,7 @@ void update_pos_vel_accel_xy(Vector2f& pos, Vector2f& vel, const Vector2f& accel
}
}
pos + = delta_pos ;
pos + = delta_pos . topostype ( ) ;
update_vel_accel_xy ( vel , accel , dt , limit ) ;
}
@ -245,8 +245,8 @@ void shape_vel_accel_xy(const Vector2f &vel_input1, const Vector2f& accel_input,
@@ -245,8 +245,8 @@ void shape_vel_accel_xy(const Vector2f &vel_input1, const Vector2f& accel_input,
The function alters the variable accel to follow a jerk limited kinematic path to pos_input , vel_input and accel_input
The vel_max , vel_correction_max , and accel_max limits can be removed by setting the desired limit to zero .
*/
void shape_pos_vel_accel ( const floa t pos_input , const float vel_input , const float accel_input ,
const floa t pos , const float vel , float & accel ,
void shape_pos_vel_accel ( const postype_ t pos_input , const float vel_input , const float accel_input ,
const postype_ t pos , const float vel , float & accel ,
const float vel_correction_max , const float vel_min , const float vel_max ,
const float accel_min , const float accel_max , const float tc , const float dt )
{
@ -277,8 +277,8 @@ void shape_pos_vel_accel(const float pos_input, const float vel_input, const flo
@@ -277,8 +277,8 @@ void shape_pos_vel_accel(const float pos_input, const float vel_input, const flo
}
// 2D version
void shape_pos_vel_accel_xy ( const Vector2f & pos_input , const Vector2f & vel_input , const Vector2f & accel_input ,
const Vector2f & pos , const Vector2f & vel , Vector2f & accel ,
void shape_pos_vel_accel_xy ( const Vector2p & pos_input , const Vector2f & vel_input , const Vector2f & accel_input ,
const Vector2p & pos , const Vector2f & vel , Vector2f & accel ,
const float vel_correction_max , const float vel_max , const float accel_max , const float tc , const float dt )
{
if ( ! is_positive ( tc ) ) {
@ -290,7 +290,7 @@ void shape_pos_vel_accel_xy(const Vector2f& pos_input, const Vector2f& vel_input
@@ -290,7 +290,7 @@ void shape_pos_vel_accel_xy(const Vector2f& pos_input, const Vector2f& vel_input
const float accel_tc_max = accel_max * ( 1.0f - 1.0f / CONTROL_TIME_CONSTANT_RATIO ) ;
// position error to be corrected
Vector2f pos_error = pos_input - pos ;
Vector2f pos_error = ( pos_input - pos ) . tofloat ( ) ;
// velocity to correct position
Vector2f vel_target = sqrt_controller ( pos_error , KPv , accel_tc_max , dt ) ;