Go to the documentation of this file.
26 CReactiveNavigationSystem::CReactiveNavigationSystem(
28 bool enableLogToFile,
const std::string& logFileDirectory)
30 react_iterf_impl, enableConsoleOutput, enableLogToFile,
41 for (
size_t i = 0; i <
PTGs.size(); i++)
delete PTGs[i];
72 unsigned int PTG_COUNT =
PTGs.size();
82 const std::string sectCfg =
"CReactiveNavigationSystem";
85 unsigned int PTG_COUNT =
c.read_int(sectCfg,
"PTG_COUNT", 0,
true);
91 sectCfg,
"RobotModel_shape2D_xs", vector<float>(0), xs,
false);
93 sectCfg,
"RobotModel_shape2D_ys", vector<float>(0), ys,
false);
95 xs.size() == ys.size(),
96 "Config parameters `RobotModel_shape2D_xs` and `RobotModel_shape2D_ys` "
97 "must have the same length!");
101 for (
size_t i = 0; i < xs.size(); i++) shape.
AddVertex(xs[i], ys[i]);
107 const double robot_shape_radius =
108 c.read_double(sectCfg,
"RobotModel_circular_shape_radius", .0,
false);
109 ASSERT_(robot_shape_radius >= .0);
110 if (robot_shape_radius != .0)
118 for (
size_t i = 0; i <
PTGs.size(); i++)
delete PTGs[i];
119 PTGs.assign(PTG_COUNT,
nullptr);
121 for (
unsigned int n = 0;
n < PTG_COUNT;
n++)
125 c.read_string(sectCfg,
format(
"PTG%u_Type",
n),
"",
true);
127 sPTGName,
c, sectCfg,
format(
"PTG%u_",
n));
145 for (
unsigned int i = 0; i <
PTGs.size(); i++)
147 PTGs[i]->deinitialize();
151 "[CReactiveNavigationSystem::STEP1_InitPTGs] Initializing "
153 i,
PTGs[i]->getDescription().c_str());
172 "%s/ReacNavGrid_%03u.dat.gz",
209 catch (std::exception& e)
212 "[CReactiveNavigationSystem::STEP2_Sense] Exception:" << e.what());
218 "[CReactiveNavigationSystem::STEP2_Sense] Unexpected exception!");
225 const size_t ptg_idx, std::vector<double>& out_TPObstacles,
228 const bool eval_clearance)
233 rel_pose_PTG_origin_wrt_sense_);
240 const float *xs, *ys, *zs;
243 for (
size_t obs = 0; obs < nObs; obs++)
245 double ox, oy, oz = zs[obs];
246 rel_pose_PTG_origin_wrt_sense.
composePoint(xs[obs], ys[obs], ox, oy);
248 if (ox > -OBS_MAX_XY && ox < OBS_MAX_XY && oy > -OBS_MAX_XY &&
275 for (
size_t i = 0; i < nVerts; i++)
293 min_obstacles_height,
294 "Minimum `z` coordinate of obstacles to be considered fo collision "
297 max_obstacles_height,
298 "Maximum `z` coordinate of obstacles to be considered fo collision "
303 : min_obstacles_height(0.0), max_obstacles_height(10.0)
312 const float *xs, *ys, *zs;
315 for (
size_t i = 0; i < 1 ;
318 const auto ptg =
PTGs[i];
320 const double R = ptg->getMaxRobotRadius();
321 for (
size_t obs = 0; obs < nObs; obs++)
323 const double gox = xs[obs], goy = ys[obs], oz = zs[obs];
332 if (lo.
x >= -
R && lo.
x <=
R && lo.
y >= -
R && lo.
y <=
R &&
333 ptg->isPointInsideRobotShape(lo.
x, lo.
y))
Base class for all PTGs using a 2D polygonal robot shape model.
Base class for all PTGs using a 2D circular robot shape model.
A class for storing, saving and loading a reactive navigation log record for the CReactiveNavigationS...
void logStr(const VerbosityLevel level, const std::string &msg_str) const
Main method to add the specified message string to the logger.
mrpt::system::CTimeLogger m_timelogger
A complete time logger.
Base class for reactive navigator systems based on TP-Space, with an arbitrary holonomic reactive met...
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
double ref_distance
Maximum distance up to obstacles will be considered (D_{max} in papers).
mrpt::math::TPoint2D inverseComposePoint(const TPoint2D g) const
virtual CParameterizedTrajectoryGenerator * getPTG(size_t i) override
Gets the i'th PTG.
mrpt::math::CVectorFloat robotShape_x
The robot shape in WS.
virtual ~CReactiveNavigationSystem()
Destructor.
void setRobotShapeRadius(const double robot_radius)
Robot shape must be set before initialization, either from ctor params or via this method.
void AddVertex(double x, double y)
Add a new vertex to polygon.
double robotShape_radius
The circular robot radius.
std::vector< CParameterizedTrajectoryGenerator * > PTGs
The list of PTGs to use for navigation.
double GetVertex_y(size_t i) const
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...
virtual void saveConfigFile(mrpt::config::CConfigFileBase &c) const override
Saves all current options to a config file.
void setRobotShape(const mrpt::math::CPolygon &robotShape)
Robot shape must be set before initialization, either from ctor params or via this method.
TReactiveNavigatorParams params_reactive_nav
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,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::math::CPolygon m_robotShape
The robot 2D shape model.
double max_obstacles_height
mrpt::maps::CSimplePointsMap m_WS_Obstacles_original
Obstacle points, before filtering (if filtering is enabled).
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
#define THROW_EXCEPTION(msg)
#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...
double GetVertex_x(size_t i) const
Methods for accessing the vertices.
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
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) override
Builds TP-Obstacles from Workspace obstacles for the given PTG.
bool m_PTGsMustBeReInitialized
#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 ...
void changeRobotCircularShapeRadius(const double R)
Defines the 2D circular robot shape radius, used for some PTGs for collision checking.
void logFmt(const VerbosityLevel level, const char *fmt,...) const MRPT_printf_format_check(3
Alternative logging method, which mimics the printf behavior.
double m_robotShapeCircularRadius
Radius of the robot if approximated as a circle.
virtual void loadConfigFile(const mrpt::config::CConfigFileBase &c) override
Loads all params from a file.
TReactiveNavigatorParams()
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.
virtual void saveToConfigFile(mrpt::config::CConfigFileBase &c, const std::string &s) const override
This method saves the options to a ".ini"-like file or memory-stored string list.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Clearance information for one particular PTG and one set of obstacles.
virtual void loadConfigFile(const mrpt::config::CConfigFileBase &c) override
Loads all params from a file.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
CRobot2NavInterface & m_robot
The navigator-robot interface.
size_t verticesCount() const
Returns the vertices count in the polygon:
virtual void loggingGetWSObstaclesAndShape(CLogFileRecord &out_log) override
Generates a pointcloud of obstacles, and the robot shape, to be saved in the logging record for the c...
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
bool m_enableConsoleOutput
Enables / disables the console debug output.
TRobotPoseVel m_curPoseVel
Current robot pose (updated in CAbstractNavigator::navigationStep() )
virtual bool checkCollisionWithLatestObstacles(const mrpt::math::TPose2D &relative_robot_pose) const override
Checks whether the robot shape, when placed at the given pose (relative to the current pose),...
mrpt::maps::CSimplePointsMap WS_Obstacles
The WS-Obstacles.
virtual void STEP1_InitPTGs() override
#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.
bool implementSenseObstacles(mrpt::system::TTimeStamp &obs_timestamp) override
Return false on any fatal error.
std::string ptg_cache_files_directory
(Default: ".")
#define MRPT_LOG_ERROR_STREAM(__CONTENTS)
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.
mrpt::maps::CSimplePointsMap WS_Obstacles_original
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 loadFromConfigFile(const mrpt::config::CConfigFileBase &c, const std::string &s) override
This method load the options from a ".ini"-like file or memory-stored string list.
mrpt::math::CVectorFloat robotShape_y
mrpt::maps::CSimplePointsMap m_WS_Obstacles
The obstacle points, as seen from the local robot frame.
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.
void preDestructor()
To be called during children destructors to assure thread-safe destruction, and free of shared object...
TAbstractPTGNavigatorParams params_abstract_ptg_navigator
This base provides a set of functions for maths stuff.
mrpt::maps::CPointCloudFilterBase::Ptr m_WS_filter
Default: none.
mrpt::system::CTimeLogger m_timlog_delays
Time logger to collect delay-related stats.
GLsizei const GLchar ** string
double min_obstacles_height
This is the base class for any user-defined PTG.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
virtual void saveConfigFile(mrpt::config::CConfigFileBase &c) const override
Saves all current options to a config file.
void changeRobotShape(const mrpt::math::CPolygon &shape)
Defines the 2D polygonal robot shape, used for some PTGs for collision checking.
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 | |