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

Data Structures

struct  a_trajbell
 instance structure for bell-shaped velocity trajectory More...
 

Typedefs

typedef struct a_trajbell a_trajbell
 

Functions

double a_trajbell_gen (a_trajbell *ctx, double jm, double am, double vm, double p0, double p1, double v0, double v1)
 generate for bell-shaped velocity trajectory
 
double a_trajbell_pos (a_trajbell const *ctx, double x)
 calculate position for bell-shaped velocity trajectory
 
double a_trajbell_vel (a_trajbell const *ctx, double x)
 calculate velocity for bell-shaped velocity trajectory
 
double a_trajbell_acc (a_trajbell const *ctx, double x)
 calculate acceleration for bell-shaped velocity trajectory
 
double a_trajbell_jer (a_trajbell const *ctx, double x)
 calculate jerk for bell-shaped velocity trajectory
 

Detailed Description

Function Documentation

◆ a_trajbell_acc()

double a_trajbell_acc ( a_trajbell const * ctx,
double x )

calculate acceleration for bell-shaped velocity trajectory

\[ \ddot{p}(t)=\begin{cases} j_mt,&t\in[0,T_{aj}]\\ j_mT_{aj}=a_m,&t\in[T_{aj},T_a-T_{aj}]\\ j_m(T_a-t),&t\in[T_a-T_{aj},T_a]\\ 0,&t\in[T_a,T_a+T_v]\\ -j_m(t-T+T_d),&t\in[T-T_d,T-T_d+T_{dj}]\\ -j_mT_{dj}=d_m,&t\in[T-T_d+T_{dj},T-T_{dj}]\\ -j_m(T-t),&t\in[T-T_{dj},T] \end{cases} \]

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

◆ a_trajbell_gen()

double a_trajbell_gen ( a_trajbell * ctx,
double jm,
double am,
double vm,
double p0,
double p1,
double v0,
double v1 )

generate for bell-shaped velocity trajectory

If \(p_0>p_1\), then

\begin{aligned}p_0=-p_0\\p_1=-p_1\\v_0=-v_0\\v_1=-v_1\end{aligned}

  1. If \((v_m-v_0)j_m<a_m^2\), the maximum acceleration is not reached, then

    \begin{aligned}T_{aj}&=\sqrt{\frac{v_m-v_0}{j_m}}\\T_a&=2T_{aj}\\a_m&=+j_mT_{aj}\end{aligned}

    else

    \begin{aligned}T_{aj}&=\frac{a_m}{j_m}\\T_a&=T_{aj}+\frac{v_m-v_0}{a_m}\\a_m&=+a_m\end{aligned}

  2. If \((v_m-v_1)j_m<a_m^2\), the maximum deceleration is not reached, then

    \begin{aligned}T_{dj}&=\sqrt{\frac{v_m-v_1}{j_m}}\\T_d&=2T_{dj}\\d_m&=-j_mT_{dj}\end{aligned}

    else

    \begin{aligned}T_{dj}&=\frac{a_m}{j_m}\\T_d&=T_{dj}+\frac{v_m-v_1}{a_m}\\d_m&=-a_m\end{aligned}

  3. Calculate the constant velocity phase

    \[T_v=\frac{p_1-p_0}{v_m} -\frac{T_a}{2}\left(1+\frac{v_0}{v_m}\right)-\frac{T_d}{2}\left(1+\frac{v_1}{v_m}\right)\]

    If \(T_v>0\), then there is a constant velocity phase and the phase calculation ends.
  4. If \(T_v<=0\), then \(T_v=0\),

    \begin{aligned}T_{aj}&=T_{dj}=T_{j}=\frac{a_m}{j_m}\\ T_a&=\cfrac{\frac{a_m^2}{j_m}+\sqrt\Delta-2v_0}{2a_m}\\T_d&=\cfrac{\frac{a_m^2}{j_m}+\sqrt\Delta-2v_1}{2a_m}\\ \Delta&=\frac{a_m^4}{j_m^2}+2(v_0^2+v_1^2)+a_m\left(4(p_1-p_0)-2\frac{a_m}{j_m}(v_0+v_1)\right)\end{aligned}


    a. If \(T_a<0\), there is only deceleration phase, then \(T_a=0\), \(T_{aj}=0\),

    \begin{aligned}T_d&=2\cfrac{p_1-p_0}{v_1+v_0}\\ T_{dj}&=\frac{j_m(p_1-p_0)-\sqrt{j_m(j_m(p_1-p_0)^2+(v_1-v_0)(v_1+v_0)^2)}}{j_m(v_1+v_0 )}\end{aligned}

    b. If \(T_d<0\), there is only acceleration phase, then \(T_d=0\), \(T_{dj}=0\),

    \begin{aligned}T_a&=2\cfrac{p_1-p_0}{v_1+v_0}\\ T_{aj}&=\frac{j_m(p_1-p_0)-\sqrt{j_m(j_m(p_1-p_0)^2+(v_0-v_1)(v_1+v_0)^2)}}{j_m(v_1+v_0 )}\end{aligned}

    c. If \(T_a\ge2T_j\), \(T_d\ge2T_j\), then

    \begin{aligned}a_m&=+j_mT_{aj}\\d_m&=-j_mT_{dj}\\v_m&=v_0+(T_a-T_{aj})a_m=v_1-(T_d-T_{dj})d_m\end{aligned}

    d. If none of the above conditions are met, let \(a_m=\alpha a_m, 0<\alpha<1\), and then repeat step 4.
  5. Finally, use formulas to calculate position, velocity and acceleration.
    Parameters
    [in,out]ctxpoints to an instance of bell-shaped velocity trajectory
    [in]jmdefines the maximum jerk during system operation
    [in]amdefines the maximum acceleration during system operation
    [in]vmdefines the maximum velocity during system operation
    [in]p0defines the initial position
    [in]p1defines the final position
    [in]v0defines the initial velocity
    [in]v1defines the final velocity
    Returns
    total duration

◆ a_trajbell_jer()

double a_trajbell_jer ( a_trajbell const * ctx,
double x )

calculate jerk for bell-shaped velocity trajectory

\[ p^{(3)}(t)=\begin{cases} j_m,&t\in[0,T_{aj}]\\ 0,&t\in[T_{aj},T_a-T_{aj}]\\ -j_m,&t\in[T_a-T_{aj},T_a]\\ 0,&t\in[T_a,T_a+T_v]\\ -j_m,&t\in[T-T_d,T-T_d+T_{dj}]\\ 0,&t\in[T-T_d+T_{dj},T-T_{dj}]\\ j_m,&t\in[T-T_{dj},T] \end{cases} \]

Parameters
[in]ctxpoints to an instance of bell-shaped velocity trajectory
[in]xdifference between current time and initial time
Returns
jerk output

◆ a_trajbell_pos()

double a_trajbell_pos ( a_trajbell const * ctx,
double x )

calculate position for bell-shaped velocity trajectory

\[ p(t)=\begin{cases} p_0+v_0t+j_m\cfrac{t^3}{6},&t\in[0,T_{aj}]\\ p_0+v_0t+\cfrac{a_m}{6}(3t^3-3tT_{aj}+T_{aj}^2),&t\in[T_{aj},T_a-T_{aj}]\\ p_0+(v_m+v_0)\cfrac{T_a}{2}-v_m(T_a-t)+j_m\cfrac{(T_a-t)^3}{6},&t\in[T_a-T_{aj},T_a]\\ p_0+(v_m+v_0)\cfrac{T_a}{2}+v_m(t-T_a),&t\in[T_a,T_a+T_v]\\ p_1-(v_m+v_1)\cfrac{T_d}{2}+v_m(t-T+T_d)-j_m\cfrac{(t-T+T_d)^3}{6},&t\in[T-T_d,T-T_d+T_{dj}]\\ p_1-(v_m+v_1)\cfrac{T_d}{2}+v_m(t-T+T_d)\\ \quad+\cfrac{d_m}{6}\left(3(t-T+T_d)^2-3(t-T+T_d)T_{dj}+T_{dj}^2\right),&t\in[T-T_d+T_{dj},T-T_{dj}]\\ p_1-v_1(T-t)-j_m\cfrac{(T-t)^3}{6},&t\in[T-T_{dj},T] \end{cases} \]

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

◆ a_trajbell_vel()

double a_trajbell_vel ( a_trajbell const * ctx,
double x )

calculate velocity for bell-shaped velocity trajectory

\[ \dot{p}(t)=\begin{cases} v_0+j_m\frac{t^2}{2},&t\in[0,T_{aj}]\\ v_0+a_m(t-\cfrac{T_{aj}}{2}),&t\in[T_{aj},T_a-T_{aj}]\\ v_m-j_m\cfrac{(T_a-t)^2}{2},&t\in[T_a-T_{aj},T_a]\\ v_m,&t\in[T_a,T_a+T_v]\\ v_m-j_m\cfrac{(t-T+T_d)^2}{2},&t\in[T-T_d,T-T_d+T_{dj}]\\ v_m+d_m(t-T+T_d-\cfrac{T_{dj}}{2}),&t\in[T-T_d+T_{dj},T-T_{dj}]\\ v_1+j_m\cfrac{(T-t)^2}{2},&t\in[T-T_{dj},T] \end{cases} \]

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