3 #ifndef __TRAJ_GEN_HPP__
4 #define __TRAJ_GEN_HPP__
6 #include <yarp/os/Log.h>
29 virtual bool configure(
const double xi,
const double xf,
const double _T) = 0;
30 virtual bool configure(
const double xi,
const double xf,
const double xdoti,
const double xdotf,
const double _T) = 0;
31 virtual double get(
const double ti)
const = 0;
32 virtual double getdot(
const double ti)
const = 0;
33 virtual double getdotdot(
const double ti)
const = 0;
34 virtual bool maxVelBelow(
const double thresVel)
const = 0;
35 virtual bool maxAccBelow(
const double thresAcc)
const = 0;
36 virtual double getT()
const = 0;
37 virtual void dump(
double samples)
const = 0;
50 bool configure(
const double xi,
const double xf,
const double _T)
58 bool configure(
const double xi,
const double xf,
const double xdoti,
const double xdotf,
const double _T)
63 double get(
const double ti)
const
68 double getdot(
const double ti)
const
73 double getdotdot(
const double ti)
const
78 bool maxVelBelow(
const double thresVel)
const
83 bool maxAccBelow(
const double thresAcc)
const
93 void dump(
double samples)
const
95 for (
double i = 0; i < T; i += (T / samples))
97 yInfo(
"%05.2f %+02.6f %+02.6f %+02.6f", i, get(i), getdot(i), getdotdot(i));
118 bool configure(
const double xi,
const double xf,
const double _T)
123 a3 = 2 * (xi - xf) / (T * T * T);
124 a2 = (xf - xi) / (T * T) - a3 * T;
131 bool configure(
const double xi,
const double xf,
const double xdoti,
const double xdotf,
const double _T)
136 a3 = 2.0 * (xi - xf) / (T * T * T) + (xdotf + xdoti) / (T * T);
137 a2 = (xf - xi - xdoti * T) / (T * T) - a3 * T;
144 double get(
const double ti)
const
148 return a3 * T * T * T + a2 * T * T + a1 * T + a0;
150 return a3 * ti * ti * ti + a2 * ti * ti + a1 * ti + a0;
160 return 3 * a3 * T * T + 2 * a2 * T + a1;
162 return 3 * a3 * ti * ti + 2 * a2 * ti + a1;
172 return 6 * a3 * T + 2 * a2;
174 return 6 * a3 * ti + 2 * a2;
182 return getdot(T / 2) < thresVel;
205 void dump(
double samples)
const
207 for (
double i = 0; i < T; i += (T / samples))
214 double a3, a2, a1, a0, T;
Generates a 1DOF order-one trajectory.
Definition: TrajGen.hpp:46
Generates a 1DOF order-three trajectory.
Definition: TrajGen.hpp:111
void dump(double samples) const
Definition: TrajGen.hpp:205
bool maxVelBelow(const double thresVel) const
Definition: TrajGen.hpp:180
bool maxAccBelow(const double thresAcc) const
Definition: TrajGen.hpp:188
double getdot(const double ti) const
Definition: TrajGen.hpp:156
double getT() const
Definition: TrajGen.hpp:196
double getdotdot(const double ti) const
Definition: TrajGen.hpp:168
double get(const double ti) const
Definition: TrajGen.hpp:144
bool configure(const double xi, const double xf, const double xdoti, const double xdotf, const double _T)
Definition: TrajGen.hpp:131
bool configure(const double xi, const double xf, const double _T)
Definition: TrajGen.hpp:118
A base class for 1 degree-of-freedom trajectories.
Definition: TrajGen.hpp:26