Main MRPT website > C++ reference for MRPT 1.3.2
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
mrpt::nav::CParameterizedTrajectoryGenerator Class Referenceabstract

Detailed Description

This is the base class for any user-defined PTG.

The class factory interface in CParameterizedTrajectoryGenerator::CreatePTG.

Papers:

Changes history:

Definition at line 56 of file CParameterizedTrajectoryGenerator.h.

#include <mrpt/nav/tpspace/CParameterizedTrajectoryGenerator.h>

Inheritance diagram for mrpt::nav::CParameterizedTrajectoryGenerator:
Inheritance graph

Classes

class  CColisionGrid
 An internal class for storing the collision grid. More...
 
struct  TCellForLambdaFunction
 Specifies the min/max values for "k" and "n", respectively. More...
 

Public Types

typedef std::vector< std::pair< uint16_t, float > > TCollisionCell
 A list of all the pairs (alpha,distance) such as the robot collides at that cell. More...
 

Public Member Functions

virtual std::string getDescription () const =0
 Gets a short textual description of the PTG and its parameters. More...
 
virtual ~CParameterizedTrajectoryGenerator ()
 Destructor. More...
 
void simulateTrajectories (uint16_t alphaValuesCount, float max_time, float max_dist, unsigned int max_n, float diferencial_t, float min_dist, float *out_max_acc_v=NULL, float *out_max_acc_w=NULL)
 The main method: solves the diferential equation to generate a family of parametrical trajectories. More...
 
void saveTrajectories (mrpt::utils::CStream &out) const
 Saves the simulated trajectories and other parameters to a target stream. More...
 
virtual std::string loadTrajectories (mrpt::utils::CStream &in)
 Loads the simulated trajectories and other parameters from a target stream. More...
 
virtual bool inverseMap_WS2TP (float x, float y, int &out_k, float &out_d, float tolerance_dist=0.10f) const
 Computes the closest (alpha,d) TP coordinates of the trajectory point closest to the Workspace (WS) Cartesian coordinates (x,y). More...
 
void lambdaFunction (float x, float y, int &out_k, float &out_d)\
 The "lambda" function, see paper for info. More...
 
void directionToMotionCommand (uint16_t k, float &out_v, float &out_w)
 Converts an "alpha" value (into the discrete set) into a feasible motion command. More...
 
uint16_t getAlfaValuesCount () const
 
size_t getPointsCountInCPath_k (uint16_t k) const
 
void getCPointWhen_d_Is (float d, uint16_t k, float &x, float &y, float &phi, float &t, float *v=NULL, float *w=NULL)
 Returns the C-Space coordinates (pose) when the robot has transversed a distance d along trajectory index . More...
 
float GetCPathPoint_x (uint16_t k, int n) const
 
float GetCPathPoint_y (uint16_t k, int n) const
 
float GetCPathPoint_phi (uint16_t k, int n) const
 
float GetCPathPoint_t (uint16_t k, int n) const
 
float GetCPathPoint_d (uint16_t k, int n) const
 
float GetCPathPoint_v (uint16_t k, int n) const
 
float GetCPathPoint_w (uint16_t k, int n) const
 
float getMax_V () const
 
float getMax_W () const
 
float getMax_V_inTPSpace () const
 
float index2alpha (uint16_t k) const
 Alfa value for the discrete corresponding value. More...
 
uint16_t alpha2index (float alpha) const
 Discrete index value for the corresponding alpha value. More...
 
bool debugDumpInFiles (const int nPT)
 Dump PTG trajectories in a binary file "./reactivenav.logs/PTGs/PTG%i.dat", with "%i" being the user-supplied parameter "nPT", and in FIVE text files: "./reactivenav.logs/PTGs/PTG%i_{x,y,phi,t,d}.txt". More...
 
void renderPathAsSimpleLine (const uint16_t k, mrpt::opengl::CSetOfLines &gl_obj, const float decimate_distance=0.1f, const float max_path_distance=0.0f) const
 Returns the representation of one trajectory of this PTG as a 3D OpenGL object (a simple curved line). More...
 
bool SaveColGridsToFile (const std::string &filename, const mrpt::math::CPolygon &computed_robotShape)
 
bool LoadColGridsFromFile (const std::string &filename, const mrpt::math::CPolygon &current_robotShape)
 
virtual void PTG_Generator (float alpha, float t, float x, float y, float phi, float &v, float &w)=0
 The main method to be implemented in derived classes. More...
 
virtual bool PTG_IsIntoDomain (float x, float y)=0
 To be implemented in derived classes. More...
 

Static Public Member Functions

static CParameterizedTrajectoryGeneratorCreatePTG (const mrpt::utils::TParameters< double > &params)
 The class factory for creating a PTG from a list of parameters "params". More...
 

Public Attributes

CColisionGrid m_collisionGrid
 The collision grid. More...
 
float refDistance
 

Protected Member Functions

 CParameterizedTrajectoryGenerator (const mrpt::utils::TParameters< double > &params)
 Constructor: possible values in "params": More...
 
void initializeCollisionsGrid (float refDistance, float resolution)
 Initialized the collision grid with the given size and resolution. More...
 
 CParameterizedTrajectoryGenerator ()
 Protected constructor for CPTG_Dummy; does not init collision grid. More...
 
void FreeMemory ()
 Free all the memory buffers. More...
 

Protected Attributes

float V_MAX
 
float W_MAX
 
float turningRadiusReference
 
std::vector< TCPointVectorCPoints
 
mrpt::utils::CDynamicGrid< TCellForLambdaFunctionm_lambdaFunctionOptimizer
 This grid will contain indexes data for speeding-up the default, brute-force lambda function. More...
 
float maxV_inTPSpace
 
uint16_t m_alphaValuesCount
 The number of discrete values for "alpha" between -PI and +PI. More...
 

Member Typedef Documentation

typedef std::vector<std::pair<uint16_t,float> > mrpt::nav::CParameterizedTrajectoryGenerator::TCollisionCell

A list of all the pairs (alpha,distance) such as the robot collides at that cell.

  • map key (uint16_t) -> alpha value (k)
    • map value (float) -> the MINIMUM distance (d), in meters, associated with that "k".

Definition at line 193 of file CParameterizedTrajectoryGenerator.h.

Constructor & Destructor Documentation

mrpt::nav::CParameterizedTrajectoryGenerator::CParameterizedTrajectoryGenerator ( const mrpt::utils::TParameters< double > &  params)
protected

Constructor: possible values in "params":

  • ref_distance: The maximum distance in PTGs
  • resolution: The cell size
  • v_max, w_max: Maximum robot speeds.

See docs of derived classes for additional parameters:

virtual mrpt::nav::CParameterizedTrajectoryGenerator::~CParameterizedTrajectoryGenerator ( )
inlinevirtual

Destructor.

Definition at line 88 of file CParameterizedTrajectoryGenerator.h.

mrpt::nav::CParameterizedTrajectoryGenerator::CParameterizedTrajectoryGenerator ( )
inlineprotected

Protected constructor for CPTG_Dummy; does not init collision grid.

Not for normal usage

Definition at line 243 of file CParameterizedTrajectoryGenerator.h.

Member Function Documentation

uint16_t mrpt::nav::CParameterizedTrajectoryGenerator::alpha2index ( float  alpha) const
inline

Discrete index value for the corresponding alpha value.

See also
index2alpha

Definition at line 157 of file CParameterizedTrajectoryGenerator.h.

References M_2PI, and M_PI.

static CParameterizedTrajectoryGenerator* mrpt::nav::CParameterizedTrajectoryGenerator::CreatePTG ( const mrpt::utils::TParameters< double > &  params)
static

The class factory for creating a PTG from a list of parameters "params".

Possible values in "params" are:

Exceptions
std::logic_errorOn invalid or missing parameters.
bool mrpt::nav::CParameterizedTrajectoryGenerator::debugDumpInFiles ( const int  nPT)

Dump PTG trajectories in a binary file "./reactivenav.logs/PTGs/PTG%i.dat", with "%i" being the user-supplied parameter "nPT", and in FIVE text files: "./reactivenav.logs/PTGs/PTG%i_{x,y,phi,t,d}.txt".

Text files are loadable from MATLAB/Octave, and can be visualized with the script [MRPT_DIR]/scripts/viewPTG.m , also online: http://mrpt.googlecode.com/svn/trunk/scripts/viewPTG.m

Note
The directory "./reactivenav.logs/PTGs" will be created if doesn't exist.
Returns
false on any error writing to disk.
void mrpt::nav::CParameterizedTrajectoryGenerator::directionToMotionCommand ( uint16_t  k,
float &  out_v,
float &  out_w 
)

Converts an "alpha" value (into the discrete set) into a feasible motion command.

void mrpt::nav::CParameterizedTrajectoryGenerator::FreeMemory ( )
protected

Free all the memory buffers.

uint16_t mrpt::nav::CParameterizedTrajectoryGenerator::getAlfaValuesCount ( ) const
inline

Definition at line 128 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::GetCPathPoint_d ( uint16_t  k,
int  n 
) const
inline

Definition at line 138 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::GetCPathPoint_phi ( uint16_t  k,
int  n 
) const
inline

Definition at line 136 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::GetCPathPoint_t ( uint16_t  k,
int  n 
) const
inline

Definition at line 137 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::GetCPathPoint_v ( uint16_t  k,
int  n 
) const
inline

Definition at line 139 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::GetCPathPoint_w ( uint16_t  k,
int  n 
) const
inline

Definition at line 140 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::GetCPathPoint_x ( uint16_t  k,
int  n 
) const
inline

Definition at line 134 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::GetCPathPoint_y ( uint16_t  k,
int  n 
) const
inline

Definition at line 135 of file CParameterizedTrajectoryGenerator.h.

void mrpt::nav::CParameterizedTrajectoryGenerator::getCPointWhen_d_Is ( float  d,
uint16_t  k,
float &  x,
float &  y,
float &  phi,
float &  t,
float *  v = NULL,
float *  w = NULL 
)

Returns the C-Space coordinates (pose) when the robot has transversed a distance d along trajectory index .

Returns (0,0,0) if out of bounds.

virtual std::string mrpt::nav::CParameterizedTrajectoryGenerator::getDescription ( ) const
pure virtual

Gets a short textual description of the PTG and its parameters.

Implemented in mrpt::nav::CPTG_Dummy, mrpt::nav::CPTG1, mrpt::nav::CPTG2, mrpt::nav::CPTG3, mrpt::nav::CPTG4, mrpt::nav::CPTG5, mrpt::nav::CPTG7, and mrpt::nav::CPTG6.

float mrpt::nav::CParameterizedTrajectoryGenerator::getMax_V ( ) const
inline

Definition at line 142 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::getMax_V_inTPSpace ( ) const
inline

Definition at line 144 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::getMax_W ( ) const
inline

Definition at line 143 of file CParameterizedTrajectoryGenerator.h.

size_t mrpt::nav::CParameterizedTrajectoryGenerator::getPointsCountInCPath_k ( uint16_t  k) const
inline

Definition at line 129 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::index2alpha ( uint16_t  k) const
inline

Alfa value for the discrete corresponding value.

See also
alpha2index

Definition at line 149 of file CParameterizedTrajectoryGenerator.h.

References M_PI.

void mrpt::nav::CParameterizedTrajectoryGenerator::initializeCollisionsGrid ( float  refDistance,
float  resolution 
)
protected

Initialized the collision grid with the given size and resolution.

virtual bool mrpt::nav::CParameterizedTrajectoryGenerator::inverseMap_WS2TP ( float  x,
float  y,
int &  out_k,
float &  out_d,
float  tolerance_dist = 0.10f 
) const
virtual

Computes the closest (alpha,d) TP coordinates of the trajectory point closest to the Workspace (WS) Cartesian coordinates (x,y).

Parameters
[in]xX coordinate of the query point.
[in]yY coordinate of the query point.
[out]out_kTrajectory parameter index (discretized alpha value, 0-based index).
[out]out_dTrajectory distance, normalized such that D_max becomes 1.
Returns
true if the distance between (x,y) and the actual trajectory point is below the given tolerance (in meters).
Note
The default implementation in CParameterizedTrajectoryGenerator relies on a look-up-table. Derived classes may redefine this to closed-form expressions, when they exist.

Reimplemented in mrpt::nav::CPTG1.

void mrpt::nav::CParameterizedTrajectoryGenerator::lambdaFunction ( float  x,
float  y,
int &  out_k,
float &  out_d 
)

The "lambda" function, see paper for info.

It takes the (a,d) pair that is closest to a given location.

bool mrpt::nav::CParameterizedTrajectoryGenerator::LoadColGridsFromFile ( const std::string &  filename,
const mrpt::math::CPolygon current_robotShape 
)
virtual std::string mrpt::nav::CParameterizedTrajectoryGenerator::loadTrajectories ( mrpt::utils::CStream in)
virtual

Loads the simulated trajectories and other parameters from a target stream.

Returns
The PTG textual description

Reimplemented in mrpt::nav::CPTG_Dummy.

Referenced by mrpt::nav::CPTG_Dummy::loadTrajectories().

virtual void mrpt::nav::CParameterizedTrajectoryGenerator::PTG_Generator ( float  alpha,
float  t,
float  x,
float  y,
float  phi,
float &  v,
float &  w 
)
pure virtual

The main method to be implemented in derived classes.

Implemented in mrpt::nav::CPTG_Dummy, mrpt::nav::CPTG1, mrpt::nav::CPTG2, mrpt::nav::CPTG3, mrpt::nav::CPTG4, mrpt::nav::CPTG5, mrpt::nav::CPTG7, and mrpt::nav::CPTG6.

virtual bool mrpt::nav::CParameterizedTrajectoryGenerator::PTG_IsIntoDomain ( float  x,
float  y 
)
pure virtual
void mrpt::nav::CParameterizedTrajectoryGenerator::renderPathAsSimpleLine ( const uint16_t  k,
mrpt::opengl::CSetOfLines gl_obj,
const float  decimate_distance = 0.1f,
const float  max_path_distance = 0.0f 
) const

Returns the representation of one trajectory of this PTG as a 3D OpenGL object (a simple curved line).

Parameters
[in]kThe 0-based index of the selected trajectory (discrete "alpha" parameter).
[out]gl_objOutput object.
[in]decimate_distanceMinimum distance between path points (in meters).
[in]max_path_distanceIf >0, cut the path at this distance (in meters).
bool mrpt::nav::CParameterizedTrajectoryGenerator::SaveColGridsToFile ( const std::string &  filename,
const mrpt::math::CPolygon computed_robotShape 
)
void mrpt::nav::CParameterizedTrajectoryGenerator::saveTrajectories ( mrpt::utils::CStream out) const

Saves the simulated trajectories and other parameters to a target stream.

void mrpt::nav::CParameterizedTrajectoryGenerator::simulateTrajectories ( uint16_t  alphaValuesCount,
float  max_time,
float  max_dist,
unsigned int  max_n,
float  diferencial_t,
float  min_dist,
float *  out_max_acc_v = NULL,
float *  out_max_acc_w = NULL 
)

The main method: solves the diferential equation to generate a family of parametrical trajectories.

Member Data Documentation

std::vector<TCPointVector> mrpt::nav::CParameterizedTrajectoryGenerator::CPoints
protected

Definition at line 247 of file CParameterizedTrajectoryGenerator.h.

uint16_t mrpt::nav::CParameterizedTrajectoryGenerator::m_alphaValuesCount
protected

The number of discrete values for "alpha" between -PI and +PI.

Definition at line 276 of file CParameterizedTrajectoryGenerator.h.

CColisionGrid mrpt::nav::CParameterizedTrajectoryGenerator::m_collisionGrid

The collision grid.

Definition at line 226 of file CParameterizedTrajectoryGenerator.h.

mrpt::utils::CDynamicGrid<TCellForLambdaFunction> mrpt::nav::CParameterizedTrajectoryGenerator::m_lambdaFunctionOptimizer
protected

This grid will contain indexes data for speeding-up the default, brute-force lambda function.

Definition at line 269 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::maxV_inTPSpace
protected

Definition at line 272 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::refDistance

Definition at line 233 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::turningRadiusReference
protected

Definition at line 246 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::V_MAX
protected

Definition at line 245 of file CParameterizedTrajectoryGenerator.h.

float mrpt::nav::CParameterizedTrajectoryGenerator::W_MAX
protected

Definition at line 245 of file CParameterizedTrajectoryGenerator.h.




Page generated by Doxygen 1.8.9.1 for MRPT 1.3.2 SVN:Unversioned directory at Thu Dec 10 00:07:55 UTC 2015