/motion

Motion Profile Generators

Primary LanguageC++

Motion Profile Generators

Cubic

Built upon:

q = a_0 + a_1t + a_2t^2 + a_3t^3

With boundary conditions s.t. q = q0, v = v0 at t = t0 and q = qf, v = vf at t = tf.

motion::profile::cubic<float> MP;

// Motion profile from 0 to 5 in time 0 to 10
MP.set(0,10,0,5);

// Position at time 1
MP.q_at(1);

// Velocity at time 10
MP.v_at(10);

// Motion profile from last q (5) to 0 in time 10 to 15 
MP.set(15,0);

Fill a container with N values from t0, Ts apart

std::vector<float> v(N);
std::generate(v.begin(), v.end(), [](){
    static float t = t0;
    return MP.at_q( t+= Ts );
});