liba 0.1.15
An algorithm library based on C/C++
Loading...
Searching...
No Matches
trapezoidal velocity trajectory
Collaboration diagram for trapezoidal velocity trajectory:

Data Structures

struct  a_trajtrap
 instance structure for trapezoidal velocity trajectory More...
 

Typedefs

typedef struct a_trajtrap a_trajtrap
 

Functions

double a_trajtrap_gen (a_trajtrap *ctx, double vm, double ac, double de, double p0, double p1, double v0, double v1)
 generate for trapezoidal velocity trajectory
 
double a_trajtrap_pos (a_trajtrap const *ctx, double x)
 calculate position for trapezoidal velocity trajectory
 
double a_trajtrap_vel (a_trajtrap const *ctx, double x)
 calculate velocity for trapezoidal velocity trajectory
 
double a_trajtrap_acc (a_trajtrap const *ctx, double x)
 calculate acceleration for trapezoidal velocity trajectory
 

Detailed Description

Function Documentation

◆ a_trajtrap_acc()

double a_trajtrap_acc ( a_trajtrap const * ctx,
double x )

calculate acceleration for trapezoidal velocity trajectory

\[ \ddot{p}(t)=\begin{cases}a,&t\in[0,t_a)\\0,&t\in[t_a,t_d)\\d,&t\in[t_d,T]\end{cases} \]

Parameters
[in]ctxpoints to an instance of trapezoidal velocity trajectory
[in]xdifference between current time and initial time
Returns
acceleration output

◆ a_trajtrap_gen()

double a_trajtrap_gen ( a_trajtrap * ctx,
double vm,
double ac,
double de,
double p0,
double p1,
double v0,
double v1 )

generate for trapezoidal velocity trajectory

Assuming that there is no constant velocity phase, but only acceleration and deceleration phases, the maximum velocity in the motion is \(v\), then we have

\[\frac{v^2-v_0^2}{2a}+\frac{v_1^2-v^2}{2d}=p_1-p_0\]

Solving for the maximum velocity is

\[|v|=\sqrt{\frac{av_1^2-dv_0^2-2ad(p_1-p_0)}{a-d}}\]

  1. If \(|v|>|v_m|\), then there is a constant velocity phase.

    \[p_a=p_0+v_0T_a+\frac{1}{2}aT_a^2\]

    \[a_d=p_1-v_cT_d-\frac{1}{2}dT_d^2\]

    \begin{cases}T_a=\cfrac{v_m-v_0}{a}\\T_c=\cfrac{p_d-p_a}{v_c}\\T_d=\cfrac{v_1-v_m}{d}\end{cases}

  2. Otherwise there is no constant velocity phase.
    a. If \(|v_0|<|v|\le|v_1|\), there is only an acceleration phase.

    \[|v_1|=\sqrt{v_0^2+2a(p_1-p_0)}\]

    \begin{cases}T_a=\cfrac{v_1-v_0}{a}\\T_c=0\\T_d=0\end{cases}

    b. If \(|v_0|\ge|v|>|v_1|\), there is only a deceleration phase.

    \[|v_1|=\sqrt{v_0^2+2d(p_1-p_0)}\]

    \begin{cases}T_a=0\\T_c=0\\T_d=\cfrac{v_1-v_0}{d}\end{cases}

    c. If \(|v|>|v_0|\), \(|v|>|v_1|\), then there are acceleration and deceleration phases.

    \begin{cases}T_a=\cfrac{v-v_0}{a}\\T_c=0\\T_d=\cfrac{v_1-v}{d}\end{cases}

  3. Finally, the position and velocity are calculated using the formula.
    Parameters
    [in,out]ctxpoints to an instance of trapezoidal velocity trajectory
    [in]vmdefines the maximum velocity during system operation
    [in]acdefines the acceleration before constant velocity
    [in]dedefines the acceleration after constant velocity
    [in]p0defines the initial position
    [in]p1defines the final position
    [in]v0defines the initial velocity
    [in]v1defines the final velocity
    Returns
    total duration

◆ a_trajtrap_pos()

double a_trajtrap_pos ( a_trajtrap const * ctx,
double x )

calculate position for trapezoidal velocity trajectory

\[ p(t)=\begin{cases}v_0+\frac{1}{2}at^2,&t\in[0,t_a)\\p_a+v_c(t-t_a),&t\in[t_a,t_d)\\ p_d+v_c(t-t_d)+\frac{1}{2}d(t-t_d)^2,&t\in[t_d,T]\end{cases} \]

Parameters
[in]ctxpoints to an instance of trapezoidal velocity trajectory
[in]xdifference between current time and initial time
Returns
position output

◆ a_trajtrap_vel()

double a_trajtrap_vel ( a_trajtrap const * ctx,
double x )

calculate velocity for trapezoidal velocity trajectory

\[ \dot{p}(t)=\begin{cases}v_0+at,&t\in[0,t_a)\\v_c,&t\in[t_a,t_d)\\v_c+d(t-t_d),&t\in[t_d,T]\end{cases} \]

Parameters
[in]ctxpoints to an instance of trapezoidal velocity trajectory
[in]xdifference between current time and initial time
Returns
velocity output