Class G2solve3arc

Class Documentation

class G2lib::G2solve3arc

Construct a piecewise clothoids \( G(s) \) composed by 3 clothoid and one line segment that solve the G2 problem

match

\[\begin{split} \begin{array}{ll} \textrm{endpoints:}\quad& \begin{cases} G(0) = \mathbf{p}_0 & \\[0.5em] G(L) = \mathbf{p}_1 & \end{cases} \\[1em] \textrm{angles:}\quad& \begin{cases} \theta(0) = \theta_0 & \\[0.5em] \theta(L) = \theta_1 & \end{cases} \\[1em] \textrm{curvature:}\quad& \begin{cases} \kappa(0) = \kappa_0 & \\[0.5em] \kappa(L) = \kappa_1 & \end{cases} \end{array} \end{split}\]

Reference

The solution algorithm is described in

  • E.Bertolazzi, M.Frego, On the G2 Hermite Interpolation Problem with clothoids Journal of Computational and Applied Mathematics, vol 341, pp. 99-116, 2018

../_images/G2problem3arc.jpg

Public Functions

inline G2solve3arc()
inline ~G2solve3arc()
void setTolerance(real_type tol)

Fix tolerance for the G2 problem

void setMaxIter(int miter)

Fix maximum number of iteration for the G2 problem

int build(real_type x0, real_type y0, real_type theta0, real_type kappa0, real_type x1, real_type y1, real_type theta1, real_type kappa1, real_type Dmax = 0, real_type dmax = 0)

Compute the 3 arc clothoid spline that fit the data

Parameters
  • x0[in] initial x position

  • y0[in] initial y position

  • theta0[in] initial angle

  • kappa0[in] initial curvature

  • x1[in] final x position

  • y1[in] final y position

  • theta1[in] final angle

  • kappa1[in] final curvature

  • Dmax[in] rough desidered maximum angle variation, if 0 computed automatically

  • dmax[in] rough desidered maximum angle divergence from guess, if 0 computed automatically

Returns

number of iteration, -1 if fails

int build_fixed_length(real_type s0, real_type x0, real_type y0, real_type theta0, real_type kappa0, real_type s1, real_type x1, real_type y1, real_type theta1, real_type kappa1)

Compute the 3 arc clothoid spline that fit the data

Parameters
  • s0[in] length of the first segment

  • x0[in] initial x position

  • y0[in] initial y position

  • theta0[in] initial angle

  • kappa0[in] initial curvature

  • s1[in] length of the last segment

  • x1[in] final x position

  • y1[in] final y position

  • theta1[in] final angle

  • kappa1[in] final curvature

Returns

number of iteration, -1 if fails

inline ClothoidCurve const &getS0() const
Returns

get the first clothoid for the 3 arc G2 fitting

inline ClothoidCurve const &getS1() const
Returns

get the last clothoid for the 3 arc G2 fitting

inline ClothoidCurve const &getSM() const
Returns

get the middle clothoid for the 3 arc G2 fitting

inline real_type totalLength() const
Returns

get the length of the 3 arc G2 fitting

inline real_type thetaTotalVariation() const
Returns

get the total angle variation of the 3 arc G2 fitting

inline real_type curvatureTotalVariation() const
Returns

get the total curvature variation of the 3 arc G2 fitting

inline real_type integralCurvature2() const
Returns

get the integral of the curvature squared of the 3 arc G2 fitting

inline real_type integralJerk2() const
Returns

get the integral of the jerk squared of the 3 arc G2 fitting

inline real_type integralSnap2() const
Returns

get the integral of the snap squared of the 3 arc G2 fitting

real_type thetaMinMax(real_type &thMin, real_type &thMax) const
Parameters
  • thMin[out] minimum angle in the 3 arc G2 fitting curve

  • thMax[out] maximum angle in the 3 arc G2 fitting curve

Returns

the difference of thMax and thMin

inline real_type deltaTheta() const

Return the difference of maximum-minimum angle in the 3 arc G2 fitting curve

real_type curvatureMinMax(real_type &kMin, real_type &kMax) const
Parameters
  • kMin[out] minimum curvature in the 3 arc G2 fitting curve

  • kMax[out] maximum curvature in the 3 arc G2 fitting curve

Returns

the difference of kMax and kMin

real_type theta(real_type s) const

Return angle as a function of curvilinear coordinate

real_type theta_D(real_type s) const

Return angle derivative (curvature) as a function of curvilinear coordinate

real_type theta_DD(real_type s) const

Return angle second derivative (curvature derivative) as a function of curvilinear coordinate

real_type theta_DDD(real_type s) const

Return angle third derivative as a function of curvilinear coordinate

real_type X(real_type s) const

Return x coordinate of the3 arc clothoid as a function of curvilinear coordinate

real_type Y(real_type s) const

Return y coordinate of the3 arc clothoid as a function of curvilinear coordinate

inline real_type xBegin() const

Return initial x coordinate of the 3 arc clothoid

inline real_type yBegin() const

Return initial y coordinate of the 3 arc clothoid

inline real_type kappaBegin() const

Return initial curvature of the 3 arc clothoid

inline real_type thetaBegin() const

Return initial angle of the 3 arc clothoid

inline real_type xEnd() const

Return final x coordinate of the 3 arc clothoid

inline real_type yEnd() const

Return final y coordinate of the 3 arc clothoid

inline real_type kappaEnd() const

Return final curvature of the 3 arc clothoid

inline real_type thetaEnd() const

Return final angle of the 3 arc clothoid

void eval(real_type s, real_type &theta, real_type &kappa, real_type &x, real_type &y) const

Compute parameters of 3 arc clothoid at curvilinear coordinate s

Parameters
  • s[in] curvilinear coordinate of where curve is computed

  • theta[out] the curve angle

  • kappa[out] the curve curvature

  • x[out] the curve x-coordinate

  • y[out] the curve y-coordinate

void eval(real_type s, real_type &x, real_type &y) const

x and y-coordinate at curvilinear coordinate s

void eval_D(real_type s, real_type &x_D, real_type &y_D) const

x and y-coordinate derivative at curvilinear coordinate s

void eval_DD(real_type s, real_type &x_DD, real_type &y_DD) const

x and y-coordinate second derivative at curvilinear coordinate s

void eval_DDD(real_type s, real_type &x_DDD, real_type &y_DDD) const

x and y-coordinate third derivative at curvilinear coordinate s

void eval_ISO(real_type s, real_type offs, real_type &x, real_type &y) const

x and y-coordinate at curvilinear coordinate s with offset

void eval_ISO_D(real_type s, real_type offs, real_type &x_D, real_type &y_D) const

x and y-coordinate derivative at curvilinear coordinate s with offset

void eval_ISO_DD(real_type s, real_type offs, real_type &x_DD, real_type &y_DD) const

x and y-coordinate second derivative at curvilinear coordinate s with offset

void eval_ISO_DDD(real_type s, real_type offs, real_type &x_DDD, real_type &y_DDD) const

x and y-coordinate third derivative at curvilinear coordinate s with offset

inline void rotate(real_type angle, real_type cx, real_type cy)

Rotate curve by angle \( theta \) centered at point \( (c_x,c_y)\)

Parameters
  • angle[in] angle \( theta \)

  • cx[in] \( c_x\)

  • cy[in] \( c_y\)

inline void translate(real_type tx, real_type ty)

Translate curve by \( (t_x,t_y) \)

inline void reverse()

Reverse curve parameterization

void save(ostream_type &stream) const

save clothoid list of a file stream

Friends

friend ostream_type &operator<<(ostream_type &stream, ClothoidCurve const &c)