Go to the documentation of this file.
30 #include <Eigen/Dense>
41 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
48 virtual T
pos(
double t)
const = 0;
55 virtual T
vel(
double t)
const = 0;
62 virtual T
accel(
double t)
const = 0;
93 double arcLength(
double t_start,
double t_end)
const
95 struct GaussLengendreCoefficient
100 static constexpr GaussLengendreCoefficient coeffs[] = {{0.0, 128. / 225.},
101 {-0.53846931010568311, 0.47862867049936647},
102 {+0.53846931010568311, 0.47862867049936647},
103 {-0.90617984593866396, 0.23692688505618908},
104 {+0.90617984593866396, 0.23692688505618908}};
105 double a = (t_end - t_start) / 2.;
106 double b = (t_end + t_start) / 2.;
108 for(
auto coeff : coeffs)
110 length += coeff.w * this->
vel(a * coeff.t + b).norm();
130 constexpr
double PRECISION = 1e-3;
133 t_guess = t_start + 1.;
135 double l_guess =
arcLength(t_start, t_guess);
136 if(std::abs(l_guess - length) < PRECISION)
140 else if(l_guess < length)
157 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
189 return C1_ + t * (2 *
C2_ + 3 * t *
C3_);
199 return 2 *
C2_ + 6 * t *
C3_;
212 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
231 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
253 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
276 reset(initPos, initVel, targetPos, targetVel);
290 void reset(
const T & initPos,
const T & initVel,
const T & targetPos,
const T & targetVel)
306 void reset(
const T & initPos,
const T & targetPos)
342 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
356 double Delta_v0 = Delta.dot(this->
initVel_);
357 double Delta_v1 = Delta.dot(this->
targetVel_);
361 double houbaInitVelScaling =
362 6. * (3. * Delta_v0 * v1_v1 - 2. * Delta_v1 * v0_v1) / (9. * v0_v0 * v1_v1 - 4. * v0_v1 * v0_v1);
363 if(houbaInitVelScaling < 0.)
365 houbaInitVelScaling *= -1.;
367 double houbaTargetVelScaling =
368 6. * (-2. * Delta_v0 * v0_v1 + 3. * Delta_v1 * v0_v0) / (9. * v0_v0 * v1_v1 - 4. * v0_v1 * v0_v1);
369 if(houbaTargetVelScaling < 0.)
371 houbaTargetVelScaling *= -1.;
373 this->
initVel_ *= houbaInitVelScaling;
423 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
462 return C1_ + t * (2 *
C2_ + t * (3 *
C3_ + t * (4 *
C4_ + t * 5 *
C5_)));
472 return 2 *
C2_ + t * (6 *
C3_ + t * (12 *
C4_ + t * 20 *
C5_));
490 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
512 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
534 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
557 reset(initPos, initVel, targetPos, targetVel);
580 const T & targetAccel)
602 void reset(
const T & initPos,
const T & initVel,
const T & targetPos,
const T & targetVel)
620 void reset(
const T & initPos,
const T & targetPos)
643 this->
C3_ = 10 * Delta - 4 * Sigma + Gamma - 2 * kappa;
644 this->
C4_ = -15 * Delta + 7 * Sigma - 2 * Gamma + kappa;
645 this->
C5_ = 6 * Delta - 3 * Sigma + Gamma;
661 template<
template<
class>
class Polynomial,
typename T>
664 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
700 poly_.reset(initPos, targetPos);
716 void reset(
const T & initPos,
const T & initVel,
const T & targetPos,
const T & targetVel,
double duration)
744 const T & targetAccel,
750 duration2 * targetAccel);
756 double s(
double t)
const
765 double sd(
double t)
const
797 return std::pow(
sd(t), 2) *
poly_.accel(
s(t));
void reset(const T &initPos, const T &initVel, const T &targetPos, const T &targetVel, double duration)
Reset duration and boundary positions and velocities.
void reset(const T &initPos, const T &targetPos)
Reset boundaries with zero tangents.
RetimedPolynomial(Polynomial< T > poly, double duration)
Constructor.
Hermite polynomial with Overall Uniformly-Bounded Accelerations (HOUBA).
virtual EIGEN_MAKE_ALIGNED_OPERATOR_NEW T pos(double t) const =0
Get the value of the polynomial at time t.
double arcLengthInverse(double t_start, double length, double t_guess=-1.) const
Inverse of the arc length function.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW RetimedPolynomial()
Empty constructor.
virtual T accel(double t) const =0
Get the value of the second-order derivative (acceleration) at time t.
T vel(double t) const
Get the value of the first-order derivative (velocity) at time t.
T vel(double t) const
Get the value of the first-order derivative (velocity) at time t.
QuinticPolynomial()
Empty constructor.
Cubic Hermite polynomial.
double sd(double t) const
Mapping from to .
void reset(const T &initPos, const T &initVel, const T &initAccel, const T &targetPos, const T &targetVel, const T &targetAccel)
Reset boundary values.
virtual T vel(double t) const =0
Get the value of the first-order derivative (velocity) at time t.
void extraInitVelScaling(double scaling)
Add extra initial velocity scaling to the HOUBA one.
T pos(double t) const
Get the value of the polynomial at time t.
Quintic polynomial over vectors.
void reset(const T &initPos, const T &targetPos)
Reset boundaries with zero tangents.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW double zero()
Zero function used for double specialization.
virtual void reset()
Reset underlying cubic polynomial coefficients.
T accel(double t) const
Acceleration along the retimed trajectory.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW QuinticHermitePolynomial()
Empty constructor.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW QuinticPolynomialBase(const T &C0, const T &C1, const T &C2, const T &C3, const T &C4, const T &C5)
Build a new curve from its monomial vector coefficients.
double extraInitVelScaling()
Get extra initial velocity scaling.
double extraTargetVelScaling_
QuinticPolynomial()
Empty constructor.
void reset(const T &initPos, const T &initVel, const T &targetPos, const T &targetVel)
Reset boundaries with zero boundary velocities.
void reset(const T &initPos, const T &initVel, const T &targetPos, const T &targetVel)
Reset boundaries.
double s(double t) const
Mapping from to .
T pos(double t) const
Position along the retimed trajectory.
double arcLength(double t_start, double t_end) const
Compute the arc length between two points of the polynomial curve.
double duration() const
Get trajectory duration.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW double zero()
Zero function used for double specialization.
void extraTargetVelScaling(double scaling)
Add extra target velocity scaling to the HOUBA one.
void reset() override
Rescale boundary velocities, then reset as Hermite polynomial.
QuinticHermitePolynomial(const T &initPos, const T &initVel, const T &targetPos, const T &targetVel)
Build a new cubic Hermite polynomial.
CubicPolynomial()
Empty constructor.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW CubicPolynomialBase(const T &C0, const T &C1, const T &C2, const T &C3)
Build a new curve from its monomial vector coefficients.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW T zero()
Return T's zero.
T vel(double t) const
Velocity along the retimed trajectory.
T accel(double t) const
Get the value of the second-order derivative (acceleration) at time t.
CubicPolynomial()
Empty constructor.
T accel(double t) const
Get the value of the second-order derivative (acceleration) at time t.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW T zero()
Return T's zero.
Utility functions and classes.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW CubicHermitePolynomial()
Empty constructor.
double extraInitVelScaling_
void reset(const T &initPos, const T &targetPos, double duration)
Reset duration and boundary positions.
T tangent(double t) const
Get the value of the tangent vector at time t.
double extraTargetVelScaling()
Get extra target velocity scaling.
void reset(const T &initPos, const T &initVel, const T &initAccel, const T &targetPos, const T &targetVel, const T &targetAccel, double duration)
Reset duration and boundary positions, velocities and accelerations.
T pos(double t) const
Get the value of the polynomial at time t.
Polynomial whose argument is retimed to by .
Quintic polynomial with zero velocity and zero acceleration at 0 and 1.
void reset()
Reset underlying cubic polynomial coefficients.
CubicHermitePolynomial(const T &initPos, const T &initVel, const T &targetPos, const T &targetVel)
Build a new cubic Hermite polynomial.