Skip to content

Commit 4d04ef5

Browse files
committed
PTGs: small code refactoring; new method inverseMap_WS2TP()
1 parent dca29e6 commit 4d04ef5

17 files changed

Lines changed: 42 additions & 88 deletions

File tree

doc/doxygen-pages/changeLog_doc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
- mrpt::slam::TMatchingExtraResults
7070
- mrpt::slam::CObservationIMU now includes data fields for 3D magnetometers and altimeters. - [(commit)](http://code.google.com/p/mrpt/source/detail?r=3451)
7171
- Method renamed mrpt::utils::CEnhancedMetaFile::selectVectorTextFont() to avoid shadowing mrpt::utils::CCanvas::selectTextFont()
72+
- mrpt::reactivenav::CParameterizedTrajectoryGenerator: New method for inverse look-up of WS to TP space - [(commit)]()
73+
- mrpt::reactivenav::CParameterizedTrajectoryGenerator::inverseMap_WS2TP()
7274
- Deleted classes:
7375
- mrpt::utils::CEvent, which was actually unimplemented (!)
7476
- mrpt::hwdrivers::CInterfaceNI845x has been deleted. It didn't offer features enough to justify a class.

libs/reactivenav/include/mrpt/reactivenav/CPTG1.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ namespace mrpt
4848
*/
4949
CPTG1(const TParameters<double> &params );
5050

51-
/** The lambda function. */
52-
void lambdaFunction( float x, float y, int &out_k, float &out_d );
51+
virtual bool inverseMap_WS2TP(float x, float y, int &out_k, float &out_d, float tolerance_dist = 0.10f) const;
5352

5453
/** Gets a short textual description of the PTG and its parameters. */
5554
std::string getDescription() const;

libs/reactivenav/include/mrpt/reactivenav/CPTG2.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ namespace mrpt
4545
*/
4646
CPTG2(const TParameters<double> &params );
4747

48-
/** The lambda function.
49-
*/
50-
void lambdaFunction( float x, float y, int &out_k, float &out_d );
51-
5248
/** Gets a short textual description of the PTG and its parameters.
5349
*/
5450
std::string getDescription() const;

libs/reactivenav/include/mrpt/reactivenav/CPTG3.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ namespace mrpt
2727
*/
2828
CPTG3(const TParameters<double> &params );
2929

30-
/** The lambda function.
31-
*/
32-
void lambdaFunction( float x, float y, int &out_k, float &out_d );
33-
3430
/** Gets a short textual description of the PTG and its parameters.
3531
*/
3632
std::string getDescription() const;

libs/reactivenav/include/mrpt/reactivenav/CPTG4.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ namespace mrpt
2727
*/
2828
CPTG4(const TParameters<double> &params );
2929

30-
/** The lambda function.
31-
*/
32-
void lambdaFunction( float x, float y, int &out_k, float &out_d );
33-
3430
/** Gets a short textual description of the PTG and its parameters.
3531
*/
3632
std::string getDescription() const;

libs/reactivenav/include/mrpt/reactivenav/CPTG5.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ namespace mrpt
2828
*/
2929
CPTG5(const TParameters<double> &params );
3030

31-
/** The lambda function.
32-
*/
33-
void lambdaFunction( float x, float y, int &out_k, float &out_d );
34-
3531
/** Gets a short textual description of the PTG and its parameters.
3632
*/
3733
std::string getDescription() const;

libs/reactivenav/include/mrpt/reactivenav/CPTG6.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ namespace mrpt
2525
*/
2626
CPTG6(const TParameters<double> &params );
2727

28-
/** The lambda function.
29-
*/
30-
void lambdaFunction( float x, float y, int &out_k, float &out_d );
31-
3228
/** Gets a short textual description of the PTG and its parameters.
3329
*/
3430
std::string getDescription() const;

libs/reactivenav/include/mrpt/reactivenav/CPTG7.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ namespace mrpt
2626
*/
2727
CPTG7(const TParameters<double> &params );
2828

29-
/** The lambda function.
30-
*/
31-
void lambdaFunction( float x, float y, int &out_k, float &out_d );
32-
3329
/** Gets a short textual description of the PTG and its parameters.
3430
*/
3531
std::string getDescription() const;

libs/reactivenav/include/mrpt/reactivenav/CParameterizedTrajectoryGenerator.h

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ namespace mrpt
2020
{
2121
using namespace mrpt::utils;
2222

23-
/** This is the base class for any user defined PTG.
23+
/** This is the base class for any user-defined PTG.
2424
* The class factory interface in CParameterizedTrajectoryGenerator::CreatePTG.
2525
*
26+
* Papers:
27+
* - J.L. Blanco, J. Gonzalez-Jimenez, J.A. Fernandez-Madrigal, "Extending Obstacle Avoidance Methods through Multiple Parameter-Space Transformations", Autonomous Robots, vol. 24, no. 1, 2008. http://ingmec.ual.es/~jlblanco/papers/blanco2008eoa_DRAFT.pdf
28+
*
2629
* Changes history:
2730
* - 30/JUN/2004: Creation (JLBC)
2831
* - 16/SEP/2004: Totally redesigned.
@@ -39,6 +42,8 @@ namespace mrpt
3942
* - ref_distance: The maximum distance in PTGs
4043
* - resolution: The cell size
4144
* - v_max, w_max: Maximum robot speeds.
45+
*
46+
* See docs of derived classes for additional parameters:
4247
*/
4348
CParameterizedTrajectoryGenerator(const TParameters<double> &params);
4449

@@ -75,9 +80,22 @@ namespace mrpt
7580
float *out_max_acc_v = NULL,
7681
float *out_max_acc_w = NULL);
7782

78-
/** The "lambda" function, see paper for info. It takes the (a,d) pair that is closest to a given location.
79-
*/
80-
virtual void lambdaFunction( float x, float y, int &out_k, float &out_d );
83+
84+
/** Computes the closest (alpha,d) TP coordinates of the trajectory point closest to the Workspace (WS) Cartesian coordinates (x,y).
85+
* \param[in] x X coordinate of the query point.
86+
* \param[in] y Y coordinate of the query point.
87+
* \param[out] out_k Trajectory parameter index (discretized alpha value, 0-based index).
88+
* \param[out] out_d Trajectory distance, normalized such that D_max becomes 1.
89+
*
90+
* \return true if the distance between (x,y) and the actual trajectory point is below the given tolerance (in meters).
91+
* \note The default implementation in CParameterizedTrajectoryGenerator relies on a look-up-table. Derived classes may redefine this to closed-form expressions, when they exist.
92+
*/
93+
virtual bool inverseMap_WS2TP(float x, float y, int &out_k, float &out_d, float tolerance_dist = 0.10f) const;
94+
95+
/** The "lambda" function, see paper for info. It takes the (a,d) pair that is closest to a given location. */
96+
MRPT_DEPRECATED_PRE("Use inverseMap_WS2TP() instead")
97+
void lambdaFunction( float x, float y, int &out_k, float &out_d );
98+
MRPT_DEPRECATED_POST("Use inverseMap_WS2TP() instead");
8199

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

libs/reactivenav/src/CPTG1.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,9 @@ bool CPTG1::PTG_IsIntoDomain( float x, float y )
5050
return true;
5151
}
5252

53-
/*---------------------------------------------------------------
54-
lambdaFunction
55-
---------------------------------------------------------------*/
56-
void CPTG1::lambdaFunction( float x, float y, int &k_out, float &d_out )
53+
bool CPTG1::inverseMap_WS2TP(float x, float y, int &k_out, float &d_out, float tolerance_dist) const
5754
{
58-
MRPT_TODO("Update API to return a bool for approximate results!")
59-
55+
bool is_exact = true;
6056
if (y!=0)
6157
{
6258
double R = (x*x+y*y)/(2*y);
@@ -83,10 +79,9 @@ void CPTG1::lambdaFunction( float x, float y, int &k_out, float &d_out )
8379
// Distance thru arc:
8480
d_out = (float)(theta * (fabs(R)+turningRadiusReference));
8581

86-
bool is_approx = false;
8782
if (std::abs(R)<Rmin)
8883
{
89-
is_approx=true;
84+
is_exact=false;
9085
R=Rmin*mrpt::utils::sign(R);
9186
}
9287

@@ -101,11 +96,13 @@ void CPTG1::lambdaFunction( float x, float y, int &k_out, float &d_out )
10196
{
10297
k_out = alpha2index(0);
10398
d_out = x;
99+
is_exact=true;
104100
}
105101
else
106102
{
107103
k_out = alpha2index((float)M_PI);
108104
d_out = 1e+3;
105+
is_exact=false;
109106
}
110107
}
111108

@@ -114,4 +111,6 @@ void CPTG1::lambdaFunction( float x, float y, int &k_out, float &d_out )
114111

115112
ASSERT_ABOVEEQ_(k_out,0)
116113
ASSERT_BELOW_(k_out,this->m_alphaValuesCount)
114+
115+
return is_exact;
117116
}

0 commit comments

Comments
 (0)