Corentin Chauvin-Hameau – 2019-2020
Coverage Path Planning for an underwater robot surveying a marine farm
Public Member Functions | Private Member Functions | Private Attributes | List of all members
mfcpp::Spline Class Reference

Class for spline interpolation. More...

#include <spline.hpp>

Public Member Functions

 Spline ()
 Default constructor. More...
 
 Spline (const std::vector< Eigen::Vector3f > &positions, const std::vector< Eigen::Vector3f > &orientations, float speed)
 Constructor for a spline given by a list of poses. More...
 
void set_poses (const std::vector< Eigen::Vector3f > &positions, const std::vector< Eigen::Vector3f > &orientations)
 Sets the poses to interpolate. More...
 
void set_speed (float speed)
 Set the desired speed on the path. More...
 
void evaluate (float t, Eigen::Vector3f &position, Eigen::Vector3f &orientation, bool &last_reached)
 Evaluates the spline at a specific time instant (assuming constant speed) More...
 

Private Member Functions

void compute_parameters ()
 Computes the spline parameters. More...
 
void prepare ()
 Prepares the class for interpolation. More...
 
Eigen::Vector3f evaluate_position (float s)
 Evaluates the spline at a specific curvilinear abscissa. More...
 
Eigen::Vector3f compute_orientation (float s)
 Computes the orientation at a specific curvilinear abscissa. More...
 
void deriv_abscissa (const std::vector< double > &s, std::vector< double > &dsdt, const double t)
 Computes the derivative of the curvilinear abscissa wrt time. More...
 
float compute_abscissa (float t)
 Computes the curvilinear abscissa corresponding to a time instant. More...
 

Private Attributes

int n_
 Number of poses to interpolate. More...
 
float speed_
 Constant speed to adopt on the path. More...
 
std::vector< Eigen::Vector3f > p_
 Positions to interpolate. More...
 
std::vector< Eigen::Vector3f > o_
 Corresponding orientations. More...
 
std::vector< std::vector< Eigen::Vector3f > > a_
 Spline parameters for each segment (ie between each pose) More...
 
bool prepared_
 Whether the class is ready for interpolation. More...
 
float last_s_
 Curvilinear abscissa of the last evaluated point. More...
 
float last_t_
 Time instant of the last evaluated point. More...
 

Detailed Description

Class for spline interpolation.

Interpolates a list of given positions and orientations by cubic splines at constant speed. The evaluation function is optimised for successive calls with increasing time.

Definition at line 24 of file spline.hpp.

Constructor & Destructor Documentation

mfcpp::Spline::Spline ( )

Default constructor.

Definition at line 22 of file spline.cpp.

mfcpp::Spline::Spline ( const std::vector< Eigen::Vector3f > &  positions,
const std::vector< Eigen::Vector3f > &  orientations,
float  speed 
)

Constructor for a spline given by a list of poses.

Will call Spline::prepare().

Parameters
positionsPositions to interpolate
orientationsCorresponding orientations
speedDesired constant speed

Definition at line 29 of file spline.cpp.

Member Function Documentation

float mfcpp::Spline::compute_abscissa ( float  t)
private

Computes the curvilinear abscissa corresponding to a time instant.

The function is optimised for successive calls with an increasing s.

Parameters
tTime at which to interpolate (should be positive)
Returns
Corresponding curvilinear abscissa

Definition at line 150 of file spline.cpp.

Eigen::Vector3f mfcpp::Spline::compute_orientation ( float  s)
private

Computes the orientation at a specific curvilinear abscissa.

Parameters
sCurvilinear abscissa (in [0, n])
Returns
Interpolated orientation

Definition at line 127 of file spline.cpp.

void mfcpp::Spline::compute_parameters ( )
private

Computes the spline parameters.

Definition at line 101 of file spline.cpp.

void mfcpp::Spline::deriv_abscissa ( const std::vector< double > &  s,
std::vector< double > &  dsdt,
const double  t 
)
private

Computes the derivative of the curvilinear abscissa wrt time.

This is the ODE used to compute the abscissa corresponding to at time.

Parameters
[in]Abscissaat which to compute the derivative (vector of size 1)
[out]Derivativeof the abscissa (vector of size 1)
[in]Timeparameter (not used here since no time dependency)

Definition at line 141 of file spline.cpp.

void mfcpp::Spline::evaluate ( float  t,
Eigen::Vector3f &  position,
Eigen::Vector3f &  orientation,
bool &  last_reached 
)

Evaluates the spline at a specific time instant (assuming constant speed)

If t is larger than the time t_max when the last specified pose is reached, the output pose will be this last pose.

Parameters
[in]tTime instant (should be positive)
[out]positionInterpolated position
[out]orientationInterpolated orientation
[out]last_reachedWhether the last pose has been reached

Definition at line 63 of file spline.cpp.

Eigen::Vector3f mfcpp::Spline::evaluate_position ( float  s)
private

Evaluates the spline at a specific curvilinear abscissa.

Parameters
sCurvilinear abscissa (in [0, n])
Returns
Interpolated position

Definition at line 114 of file spline.cpp.

void mfcpp::Spline::prepare ( )
private

Prepares the class for interpolation.

Computes the spline parameters and the time instants at the given points.

Definition at line 90 of file spline.cpp.

void mfcpp::Spline::set_poses ( const std::vector< Eigen::Vector3f > &  positions,
const std::vector< Eigen::Vector3f > &  orientations 
)

Sets the poses to interpolate.

Parameters
positionsPositions to interpolate
orientationsCorresponding orientations

Definition at line 40 of file spline.cpp.

void mfcpp::Spline::set_speed ( float  speed)

Set the desired speed on the path.

Parameters
speedDesired speed

Definition at line 56 of file spline.cpp.

Member Data Documentation

std::vector< std::vector<Eigen::Vector3f> > mfcpp::Spline::a_
private

Spline parameters for each segment (ie between each pose)

Definition at line 86 of file spline.hpp.

float mfcpp::Spline::last_s_
private

Curvilinear abscissa of the last evaluated point.

Definition at line 88 of file spline.hpp.

float mfcpp::Spline::last_t_
private

Time instant of the last evaluated point.

Definition at line 89 of file spline.hpp.

int mfcpp::Spline::n_
private

Number of poses to interpolate.

Definition at line 82 of file spline.hpp.

std::vector<Eigen::Vector3f> mfcpp::Spline::o_
private

Corresponding orientations.

Definition at line 85 of file spline.hpp.

std::vector<Eigen::Vector3f> mfcpp::Spline::p_
private

Positions to interpolate.

Definition at line 84 of file spline.hpp.

bool mfcpp::Spline::prepared_
private

Whether the class is ready for interpolation.

Definition at line 87 of file spline.hpp.

float mfcpp::Spline::speed_
private

Constant speed to adopt on the path.

Definition at line 83 of file spline.hpp.


The documentation for this class was generated from the following files: