Go to the documentation of this file.
22 : robot_shape_circular_radius(0.30),
23 ptg_cache_files_directory(
"."),
26 minDistanceBetweenNewNodes(0.10),
42 "No PTG was defined! At least one must be especified.");
46 poly_robot_shape.clear();
47 if (!
params.robot_shape.empty())
49 vector<double> xm, ym;
54 for (
size_t i = 0; i <
m_PTGs.size(); i++)
66 !poly_robot_shape.empty(),
67 "No polygonal robot shape specified, and PTG requires "
80 params.robot_shape_circular_radius > 0,
81 "No circular robot shape specified, and PTG requires one!");
88 "%s/TPRRT_PTG_%03u.dat.gz",
89 params.ptg_cache_files_directory.c_str(),
90 static_cast<unsigned int>(i)),
105 params.robot_shape.clear();
110 if (!mShape.fromMatlabStringFormat(sShape))
112 "Error parsing robot_shape matrix: '%s'", sShape.c_str());
116 for (
int i = 0; i < mShape.cols(); i++)
117 params.robot_shape.push_back(
118 TPoint2D(mShape(0, i), mShape(1, i)));
122 params.robot_shape_circular_radius =
123 ini.
read_double(sSect,
"robot_shape_circular_radius", 0.0);
129 const size_t PTG_COUNT =
130 ini.
read_int(sSect,
"PTG_COUNT", 0,
true);
131 for (
unsigned int n = 0;
n < PTG_COUNT;
n++)
139 sPTGName, ini, sSect,
format(
"PTG%u_",
n))));
149 const float *obs_xs, *obs_ys, *obs_zs;
155 const CPose2D invPose = -asSeenFrom;
159 for (
size_t obs = 0; obs < nObs; obs++)
161 const double gx = obs_xs[obs], gy = obs_ys[obs];
163 if (std::abs(gx - asSeenFrom.
x()) > MAX_DIST_XY ||
164 std::abs(gy - asSeenFrom.
y()) > MAX_DIST_XY)
181 const double MAX_DIST, std::vector<double>& out_TPObstacles)
191 const float *obs_xs, *obs_ys, *obs_zs;
198 for (
size_t obs = 0; obs < nObs; obs++)
200 const float ox = obs_xs[obs];
201 const float oy = obs_ys[obs];
213 catch (std::exception& e)
215 cerr <<
"[PT_RRT::SpaceTransformer] Exception:" << endl;
216 cerr << e.what() << endl;
220 cerr <<
"\n[PT_RRT::SpaceTransformer] Unexpected exception!:\n";
221 cerr <<
format(
"*in_PTG = %p\n", (
void*)in_PTG);
223 cerr <<
format(
"PTG = %s\n", in_PTG->getDescription().c_str());
229 const int tp_space_k_direction,
232 const double MAX_DIST,
double& out_TPObstacle_k)
242 const float *obs_xs, *obs_ys, *obs_zs;
249 for (
size_t obs = 0; obs < nObs; obs++)
251 const float ox = obs_xs[obs];
252 const float oy = obs_ys[obs];
259 ox, oy, tp_space_k_direction, out_TPObstacle_k);
265 catch (std::exception& e)
267 cerr <<
"[PT_RRT::SpaceTransformer] Exception:" << endl;
268 cerr << e.what() << endl;
272 cerr <<
"\n[PT_RRT::SpaceTransformer] Unexpected exception!:\n";
273 cerr <<
format(
"*in_PTG = %p\n", (
void*)in_PTG);
275 cerr <<
format(
"PTG = %s\n", in_PTG->getDescription().c_str());
Base class for all PTGs using a 2D circular robot shape model.
virtual void reserve(size_t newLength)=0
Reserves memory for a given number of points: the size of the map does not change,...
void spaceTransformerOneDirectionOnly(const int tp_space_k_direction, const mrpt::maps::CSimplePointsMap &in_obstacles, const mrpt::nav::CParameterizedTrajectoryGenerator *in_PTG, const double MAX_DIST, double &out_TPObstacle_k)
void setRobotShapeRadius(const double robot_radius)
Robot shape must be set before initialization, either from ctor params or via this method.
double read_double(const std::string §ion, const std::string &name, double defaultValue, bool failIfNotFound=false) const
void getPlotData(std::vector< double > &x, std::vector< double > &y) const
Gets plot data, ready to use on a 2D plot.
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans or other sensors.
void internal_loadConfig_PTG(const mrpt::config::CConfigFileBase &cfgSource, const std::string &sSectionName=std::string("PTG_CONFIG"))
Load all PTG params from a config file source.
void setRobotShape(const mrpt::math::CPolygon &robotShape)
Robot shape must be set before initialization, either from ctor params or via this method.
virtual void updateTPObstacle(double ox, double oy, std::vector< double > &tp_obstacles) const =0
Updates the radial map of closest TP-Obstacles given a single obstacle point at (ox,...
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::CTimeLogger m_timelogger
#define ASSERT_(f)
Defines an assertion mechanism.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void composePoint(double lx, double ly, double &gx, double &gy) const
An alternative, slightly more efficient way of doing with G and L being 2D points and P this 2D pose...
PlannerTPS_VirtualBase()
ctor
std::string read_string(const std::string §ion, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
void spaceTransformer(const mrpt::maps::CSimplePointsMap &in_obstacles, const mrpt::nav::CParameterizedTrajectoryGenerator *in_PTG, const double MAX_DIST, std::vector< double > &out_TPObstacles)
static void transformPointcloudWithSquareClipping(const mrpt::maps::CPointsMap &in_map, mrpt::maps::CPointsMap &out_map, const mrpt::poses::CPose2D &asSeenFrom, const double MAX_DIST_XY)
int read_int(const std::string §ion, const std::string &name, int defaultValue, bool failIfNotFound=false) const
void initTPObstacles(std::vector< double > &TP_Obstacles) const
Resizes and populates the initial appropriate contents in a vector of tp-obstacles (collision-free ra...
This class allows loading and storing values and vectors of different types from a configuration text...
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
double x() const
Common members of all points & poses classes.
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans.
void initTPObstacleSingle(uint16_t k, double &TP_Obstacle_k) const
Base class for all PTGs suitable to non-holonomic, differentially-driven (or Ackermann) vehicles base...
std::shared_ptr< CParameterizedTrajectoryGenerator > Ptr
void setAllVertices(const std::vector< double > &x, const std::vector< double > &y)
Set all vertices at once.
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
A safe way to call enter() and leave() of a mrpt::system::CTimeLogger upon construction and destructi...
A wrapper of a TPolygon2D class, implementing CSerializable.
void internal_initialize_PTG()
Must be called after setting all params (see internal_loadConfig_PTG()) and before calling solve()
void getPointsBuffer(size_t &outPointsCount, const float *&xs, const float *&ys, const float *&zs) const
Provides a direct access to points buffer, or nullptr if there is no points in the map.
static CParameterizedTrajectoryGenerator * CreatePTG(const std::string &ptgClassName, const mrpt::config::CConfigFileBase &cfg, const std::string &sSection, const std::string &sKeyPrefix)
The class factory for creating a PTG from a list of parameters in a section of a given config file (p...
virtual void insertPointFast(float x, float y, float z=0)=0
The virtual method for insertPoint() without calling mark_as_modified()
virtual void updateTPObstacleSingle(double ox, double oy, uint16_t k, double &tp_obstacle_k) const =0
Like updateTPObstacle() but for one direction only (k) in TP-Space.
This base provides a set of functions for maths stuff.
GLsizei const GLchar ** string
void clear()
Erase all the contents of the map.
mrpt::math::TPolygon2D robot_shape
The robot shape used when computing collisions; it's loaded from the config file/text as a single 2xN...
mrpt::nav::TListPTGPtr m_PTGs
This is the base class for any user-defined PTG.
GLenum const GLfloat * params
double DEG2RAD(const double x)
Degrees to radians.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |