Skip to content

Commit 7bd68e4

Browse files
committed
build_PTG_collision_grids(): simplified and more accurate
Leave only one build_PTG_collision_grids() function. Slighly slower but more accurate and conservative (safer) computation of collision grids for PTGs.
1 parent 0a12607 commit 7bd68e4

File tree

7 files changed

+89
-345
lines changed

7 files changed

+89
-345
lines changed

doc/doxygen-pages/changeLog_doc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- mrpt::reactivenav::CParameterizedTrajectoryGenerator: New methods:
5555
- mrpt::reactivenav::CParameterizedTrajectoryGenerator::inverseMap_WS2TP() for inverse look-up of WS to TP space - [(commit)](https://github.com/jlblancoc/mrpt/commit/4d04ef50e3dea581bed6287d4ea6593034c47da3)
5656
- mrpt::reactivenav::CParameterizedTrajectoryGenerator::renderPathAsSimpleLine() - [(commit)](https://github.com/jlblancoc/mrpt/commit/a224fc2489ad00b3ab116c84e8d4a48532a005df)
57+
- Changed the signature of mrpt::reactivenav::build_PTG_collision_grids() to become more generic for 2D & 2.5D PTGs - [(commit)]()
5758
- Deleted classes:
5859
- mrpt::utils::CEvent, which was actually unimplemented (!)
5960
- mrpt::hwdrivers::CInterfaceNI845x has been deleted. It didn't offer features enough to justify a class.

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

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -116,42 +116,6 @@ namespace mrpt
116116
float GetCPathPoint_v( uint16_t k, int n ) const { return CPoints[k][n].v; }
117117
float GetCPathPoint_w( uint16_t k, int n ) const { return CPoints[k][n].w; }
118118

119-
void allocMemForVerticesData( int nVertices );
120-
121-
void setVertex_xy( uint16_t k, int n, int m, float x, float y )
122-
{
123-
vertexPoints_x[k][ n*nVertices + m ] = x;
124-
vertexPoints_y[k][ n*nVertices + m ] = y;
125-
}
126-
127-
float getVertex_x( uint16_t k, int n, int m ) const
128-
{
129-
int idx = n*nVertices + m;
130-
// assert( idx>=0);assert(idx<nVertices * nPointsInEachPath[k] );
131-
return vertexPoints_x[k][idx];
132-
}
133-
134-
float getVertex_y( uint16_t k, int n, int m ) const
135-
{
136-
int idx = n*nVertices + m;
137-
// assert( idx>=0);assert(idx<nVertices * nPointsInEachPath[k] );
138-
return vertexPoints_y[k][idx];
139-
}
140-
141-
float* getVertixesArray_x( uint16_t k, int n )
142-
{
143-
int idx = n*nVertices;
144-
return &vertexPoints_x[k][idx];
145-
}
146-
147-
float* getVertixesArray_y( uint16_t k, int n )
148-
{
149-
int idx = n*nVertices;
150-
return &vertexPoints_y[k][idx];
151-
}
152-
153-
unsigned int getVertixesCount() const { return nVertices; }
154-
155119
float getMax_V() const { return V_MAX; }
156120
float getMax_W() const { return W_MAX; }
157121
float getMax_V_inTPSpace() const { return maxV_inTPSpace; }
@@ -301,11 +265,6 @@ namespace mrpt
301265
typedef std::vector<TCPoint> TCPointVector;
302266
std::vector<TCPointVector> CPoints;
303267

304-
/** The shape of the robot along the trajectories:
305-
*/
306-
std::vector<vector_float> vertexPoints_x,vertexPoints_y;
307-
int nVertices;
308-
309268
/** Free all the memory buffers */
310269
void FreeMemory();
311270

libs/reactivenav/include/mrpt/reactivenav/motion_planning_utils.h

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,19 @@ namespace mrpt
2020
/** @name Motion planning utilities
2121
@{*/
2222

23-
/** Builds the collision grid for a given list of PTGs.
23+
/** Builds the collision grid for a given PTGs, or load it from a cache file.
2424
* The collision grid must be calculated before calling CParameterizedTrajectoryGenerator::CColisionGrid::getTPObstacle
2525
* \param PTGs The list of PTGs to calculate their grids.
2626
* \param robotShape The shape of the robot.
27-
* \param cacheFilesPrefix The prefix of the files where the collision grids will be dumped to speed-up future recalculations.
28-
* \param verbose
27+
* \param cacheFilename The filename where the collision grids will be dumped to speed-up future recalculations. If it exists upon call, the collision grid will be loaded from here if all PTG parameters match. Example: "PTG_%03d.dat.gz".
2928
* \sa CReactiveNavigationSystem
3029
* \ingroup mrpt_reactivenav_grp
3130
*/
32-
3331
void REACTIVENAV_IMPEXP build_PTG_collision_grids(
34-
std::vector<CParameterizedTrajectoryGenerator*> PTGs,
35-
const mrpt::math::CPolygon &robotShape,
36-
const std::string &cacheFilesPrefix = std::string("ReacNavGrid_"),
37-
bool verbose = true
38-
);
39-
40-
void REACTIVENAV_IMPEXP build_PTG_collision_grid3D(
41-
CParameterizedTrajectoryGenerator* ptg,
42-
const mrpt::math::CPolygon &robotShape,
43-
const unsigned int level,
44-
const unsigned int num_ptg,
45-
bool verbose = true
32+
CParameterizedTrajectoryGenerator * PTG,
33+
const mrpt::math::CPolygon & robotShape,
34+
const std::string & cacheFilename,
35+
const bool verbose = true
4636
);
4737

4838
/** @} */

libs/reactivenav/src/CParameterizedTrajectoryGenerator.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ CParameterizedTrajectoryGenerator::CParameterizedTrajectoryGenerator(const TPara
3939
this->W_MAX = params["w_max"];
4040

4141
m_alphaValuesCount=0;
42-
nVertices = 0;
4342
turningRadiusReference = 0.10f;
4443

4544
initializeCollisionsGrid( refDistance, params["resolution"] );
@@ -85,34 +84,11 @@ void CParameterizedTrajectoryGenerator::FreeMemory()
8584
// Free trajectories:
8685
CPoints.clear();
8786

88-
// And the shape of the robot along them:
89-
vertexPoints_x.clear();
90-
vertexPoints_y.clear();
91-
9287
// Signal an empty PTG:
9388
m_alphaValuesCount = 0;
9489
}
9590
}
9691

97-
/*---------------------------------------------------------------
98-
allocMemFoVerticesData
99-
---------------------------------------------------------------*/
100-
void CParameterizedTrajectoryGenerator::allocMemForVerticesData( int nVertices )
101-
{
102-
vertexPoints_x.resize(m_alphaValuesCount);
103-
vertexPoints_y.resize(m_alphaValuesCount);
104-
105-
// Alloc the exact number of items, all of them set to 0:
106-
for (unsigned int i=0;i<m_alphaValuesCount;i++)
107-
{
108-
vertexPoints_x[i].resize( nVertices * getPointsCountInCPath_k(i), 0 );
109-
vertexPoints_y[i].resize( nVertices * getPointsCountInCPath_k(i), 0 );
110-
}
111-
112-
// Save it:
113-
this->nVertices= nVertices;
114-
}
115-
11692
/*---------------------------------------------------------------
11793
simulateTrajectories
11894
Solve trajectories and fill cells.

libs/reactivenav/src/CReactiveNavigationSystem.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,15 @@ void CReactiveNavigationSystem::STEP1_CollisionGridsBuilder()
202202

203203
m_timelogger.enter("build_PTG_collision_grids");
204204

205-
mrpt::reactivenav::build_PTG_collision_grids(
206-
PTGs,
207-
m_robotShape,
208-
format("ReacNavGrid_%s",robotName.c_str())
209-
);
205+
for (unsigned int i=0;i<PTGs.size();i++)
206+
{
207+
mrpt::reactivenav::build_PTG_collision_grids(
208+
PTGs[i],
209+
m_robotShape,
210+
format("ReacNavGrid_%s_%03u.dat.gz",robotName.c_str(),i),
211+
m_enableConsoleOutput /*verbose*/
212+
);
213+
}
210214

211215
m_timelogger.leave("build_PTG_collision_grids");
212216
}

libs/reactivenav/src/CReactiveNavigationSystem3D.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,12 @@ void CReactiveNavigationSystem3D::STEP1_CollisionGridsBuilder()
215215
{
216216
for (unsigned int i=0; i<m_robotShape.heights.size(); i++)
217217
{
218-
build_PTG_collision_grid3D(m_ptgmultilevel[j].PTGs[i], m_robotShape.polygons[i], i+1, j+1, m_enableConsoleOutput /*VERBOSE*/ );
218+
mrpt::reactivenav::build_PTG_collision_grids(
219+
m_ptgmultilevel[j].PTGs[i],
220+
m_robotShape.polygons[i],
221+
format("ReacNavGrid_%s_%03u_L%02u.dat.gz",robotName.c_str(),i,j),
222+
m_enableConsoleOutput /*VERBOSE*/
223+
);
219224
}
220225
}
221226

0 commit comments

Comments
 (0)