27 CReactiveNavigationSystem::CReactiveNavigationSystem(
29 bool enableConsoleOutput,
44 for (
size_t i=0;i<
PTGs.size();i++)
delete PTGs[i];
75 unsigned int PTG_COUNT =
PTGs.size();
84 const std::string sectCfg =
"CReactiveNavigationSystem";
87 unsigned int PTG_COUNT =
c.read_int(sectCfg,
"PTG_COUNT",0,
true );
92 c.read_vector(sectCfg,
"RobotModel_shape2D_xs",vector<float>(0), xs,
false );
93 c.read_vector(sectCfg,
"RobotModel_shape2D_ys",vector<float>(0), ys,
false );
94 ASSERTMSG_(xs.size()==ys.size(),
"Config parameters `RobotModel_shape2D_xs` and `RobotModel_shape2D_ys` must have the same length!");
98 for (
size_t i=0;i<xs.size();i++)
105 const double robot_shape_radius =
c.read_double(sectCfg,
"RobotModel_circular_shape_radius",.0,
false );
106 ASSERT_(robot_shape_radius>=.0);
107 if (robot_shape_radius!=.0)
115 for (
size_t i=0;i<
PTGs.size();i++)
delete PTGs[i];
116 PTGs.assign(PTG_COUNT,NULL);
118 for (
unsigned int n=0;
n<PTG_COUNT;
n++)
139 for (
unsigned int i=0;i<
PTGs.size();i++)
141 PTGs[i]->deinitialize();
143 logFmt(mrpt::utils::LVL_INFO,
"[CReactiveNavigationSystem::STEP1_InitPTGs] Initializing PTG#%u (`%s`)...", i,
PTGs[i]->getDescription().c_str());
163 logStr(mrpt::utils::LVL_INFO,
"Done!");
189 catch (std::exception &e)
205 m_navProfiler,
"CReactiveNavigationSystem::STEP3_WSpaceToTPSpace()");
216 const float *xs,*ys,*zs;
219 for (
size_t obs=0;obs<nObs;obs++)
221 double ox,oy,oz=zs[obs];
222 rel_pose_PTG_origin_wrt_sense.
composePoint(xs[obs], ys[obs], ox, oy);
224 if (ox>-OBS_MAX_XY && ox<OBS_MAX_XY &&
225 oy>-OBS_MAX_XY && oy<OBS_MAX_XY &&
229 if (eval_clearance) {
248 for (
size_t i=0;i<nVerts;i++)
268 min_obstacles_height(0.0),
269 max_obstacles_height(10.0)
277 const float *xs, *ys, *zs;
280 for (
size_t i = 0; i < 1 ; i++)
282 const auto ptg =
PTGs[i];
284 const double R = ptg->getMaxRobotRadius();
285 for (
size_t obs = 0; obs < nObs; obs++)
287 const double gox = xs[obs], goy = ys[obs], oz = zs[obs];
295 if (lo.
x>=-
R && lo.
x<=
R &&
296 lo.
y>=-
R && lo.
y<=
R &&
297 ptg->isPointInsideRobotShape(lo.
x, lo.
y)
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
double GetVertex_x(size_t i) const
Methods for accessing the vertices.
virtual void loadConfigFile(const mrpt::utils::CConfigFileBase &c) MRPT_OVERRIDE
Loads all params from a file.
TRobotPoseVel m_curPoseVel
Current robot pose (updated in CAbstractNavigator::navigationStep() )
virtual void loggingGetWSObstaclesAndShape(CLogFileRecord &out_log) MRPT_OVERRIDE
Generates a pointcloud of obstacles, and the robot shape, to be saved in the logging record for the c...
std::vector< CParameterizedTrajectoryGenerator * > PTGs
The list of PTGs to use for navigation.
virtual bool senseObstacles(mrpt::maps::CSimplePointsMap &obstacles, mrpt::system::TTimeStamp ×tamp)=0
Return the current set of obstacle points, as seen from the local coordinate frame of the robot...
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define MRPT_LOAD_CONFIG_VAR_REQUIRED_CS(variableName, variableType)
Shortcut for MRPT_LOAD_CONFIG_VAR_NO_DEFAULT() for REQUIRED variables config file object named c and ...
size_t verticesCount() const
Returns the vertices count in the polygon:
virtual size_t getPTG_count() const MRPT_OVERRIDE
Returns the number of different PTGs that have been setup.
mrpt::math::CVectorFloat robotShape_y
The robot shape in WS. Used by PTGs derived from mrpt::nav::CPTG_RobotShape_Polygonal.
mrpt::maps::CSimplePointsMap m_WS_Obstacles
The obstacle points, as seen from the local robot frame.
Base class for all PTGs using a 2D circular robot shape model.
void changeRobotCircularShapeRadius(const double R)
Defines the 2D circular robot shape radius, used for some PTGs for collision checking.
double max_obstacles_height
#define THROW_EXCEPTION(msg)
TReactiveNavigatorParams params_reactive_nav
#define ASSERT_BELOW_(__A, __B)
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &c, const std::string &s) const MRPT_OVERRIDE
This method saves the options to a ".ini"-like file or memory-stored string list. ...
mrpt::utils::CTimeLogger m_timelogger
A complete time logger.
mrpt::maps::CSimplePointsMap m_WS_Obstacles_original
Obstacle points, before filtering (if filtering is enabled).
A wrapper of a TPolygon2D class, implementing CSerializable.
bool m_enableConsoleOutput
Enables / disables the console debug output.
Clearance information for one particular PTG and one set of obstacles.
virtual void loadConfigFile(const mrpt::utils::CConfigFileBase &c) MRPT_OVERRIDE
Loads all params from a file.
A class for storing, saving and loading a reactive navigation log record for the CReactiveNavigationS...
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...
mrpt::utils::CTimeLogger m_timlog_delays
Time logger to collect delay-related stats.
mrpt::math::CVectorFloat robotShape_x
This class allows loading and storing values and vectors of different types from a configuration text...
virtual bool checkCollisionWithLatestObstacles(const mrpt::math::TPose2D &relative_robot_pose) const MRPT_OVERRIDE
Checks whether the robot shape, when placed at the given pose (relative to the current pose)...
This is the base class for any user-defined PTG.
This base provides a set of functions for maths stuff.
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
virtual CParameterizedTrajectoryGenerator * getPTG(size_t i) MRPT_OVERRIDE
Gets the i'th PTG.
Base class for all PTGs using a 2D polygonal robot shape model.
Base class for reactive navigator systems based on TP-Space, with an arbitrary holonomic reactive met...
void setRobotShapeRadius(const double robot_radius)
Robot shape must be set before initialization, either from ctor params or via this method...
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
mrpt::maps::CSimplePointsMap WS_Obstacles_original
The WS-Obstacles.
virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const MRPT_OVERRIDE
Saves all current options to a config file.
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
std::string ptg_cache_files_directory
(Default: ".")
void updateClearance(const double ox, const double oy, ClearanceDiagram &cd) const
Updates the clearance diagram given one (ox,oy) obstacle point, in coordinates relative to the PTG pa...
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,oy)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double min_obstacles_height
mrpt::maps::CPointCloudFilterBasePtr m_WS_filter
Default: none.
void changeRobotShape(const mrpt::math::CPolygon &shape)
Defines the 2D polygonal robot shape, used for some PTGs for collision checking.
A safe way to call enter() and leave() of a mrpt::utils::CTimeLogger upon construction and destructio...
void getPointsBuffer(size_t &outPointsCount, const float *&xs, const float *&ys, const float *&zs) const
Provides a direct access to points buffer, or NULL if there is no points in the map.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
virtual void STEP1_InitPTGs() MRPT_OVERRIDE
mrpt::utils::CTimeLogger m_navProfiler
Publicly available time profiling object.
TAbstractPTGNavigatorParams params_abstract_ptg_navigator
CRobot2NavInterface & m_robot
The navigator-robot interface.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
void STEP3_WSpaceToTPSpace(const size_t ptg_idx, std::vector< double > &out_TPObstacles, mrpt::nav::ClearanceDiagram &out_clearance, const mrpt::math::TPose2D &rel_pose_PTG_origin_wrt_sense, const bool eval_clearance) MRPT_OVERRIDE
Builds TP-Obstacles from Workspace obstacles for the given PTG.
TReactiveNavigatorParams()
double ref_distance
Maximum distance up to obstacles will be considered (D_{max} in papers).
double m_robotShapeCircularRadius
Radius of the robot if approximated as a circle. Only one of robot_shape or robot_shape_circular_radi...
double GetVertex_y(size_t i) const
virtual void loadFromConfigFile(const mrpt::utils::CConfigFileBase &c, const std::string &s) MRPT_OVERRIDE
This method load the options from a ".ini"-like file or memory-stored string list.
void inverseComposePoint(const TPoint2D g, TPoint2D &l) const
mrpt::maps::CSimplePointsMap WS_Obstacles
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const MRPT_OVERRIDE
Saves all current options to a config file.
virtual ~CReactiveNavigationSystem()
Destructor.
mrpt::math::CPolygon m_robotShape
The robot 2D shape model. Only one of robot_shape or robot_shape_circular_radius will be used in each...
void AddVertex(double x, double y)
Add a new vertex to polygon.
#define ASSERTMSG_(f, __ERROR_MSG)
bool m_PTGsMustBeReInitialized
#define MRPT_LOG_ERROR_STREAM(__CONTENTS)
static CParameterizedTrajectoryGenerator * CreatePTG(const std::string &ptgClassName, const mrpt::utils::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...
void preDestructor()
To be called during children destructors to assure thread-safe destruction, and free of shared object...
bool implementSenseObstacles(mrpt::system::TTimeStamp &obs_timestamp) MRPT_OVERRIDE
Return false on any fatal error.
double robotShape_radius
The circular robot radius. Used by PTGs derived from mrpt::nav::CPTG_RobotShape_Circular.