MRPT  1.9.9
CReactiveNavigationSystem3D.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef CReactiveNavigationSystem3D_H
10 #define CReactiveNavigationSystem3D_H
11 
13 
14 namespace mrpt::nav
15 {
16 /** A 3D robot shape stored as a "sliced" stack of 2D polygons, used for
17  * CReactiveNavigationSystem3D
18  * Depending on each PTG, only the 2D polygon or the circular radius will be
19  * taken into account
20  * \ingroup nav_reactive
21  */
23 {
24  size_t size() const { return polygons.size(); }
25  void resize(size_t num_levels)
26  {
27  polygons.resize(num_levels);
28  radius.resize(num_levels);
29  heights.resize(num_levels);
30  }
31 
32  const mrpt::math::CPolygon& polygon(size_t level) const
33  {
34  return polygons[level];
35  }
36  const double& getRadius(size_t level) const { return radius[level]; }
37  const double& getHeight(size_t level) const { return heights[level]; }
39  void setRadius(size_t level, double r) { radius[level] = r; }
40  void setHeight(size_t level, double h) { heights[level] = h; }
41  const std::vector<double>& getHeights() const { return heights; }
42  private:
43  std::vector<mrpt::math::CPolygon> polygons; // The polygonal bases
44  std::vector<double> radius; // The radius of each prism.
45  std::vector<double> heights; // Heights of the prisms
46 };
47 
48 /** See base class CAbstractPTGBasedReactive for a description and instructions
49 * of use.
50 * This particular implementation assumes a 3D (or "2.5D") robot shape model,
51 * build as a vertical stack of "2D slices".
52 *
53 * Paper describing the method:
54 * - M. Jaimez-Tarifa, J. Gonzalez-Jimenez, J.L. Blanco,
55 * "Efficient Reactive Navigation with Exact Collision Determination for 3D
56 * Robot Shapes",
57 * International Journal of Advanced Robotic Systems, 2015.
58 *
59 * Class history:
60 * - SEP/2012: First design.
61 * - JUL/2013: Integrated into MRPT library.
62 * - DEC/2013: Code refactoring between this class and
63 * CAbstractHolonomicReactiveMethod
64 * - FEB/2017: Refactoring of all parameters for a consistent organization in
65 * sections by class names (MRPT 1.5.0)
66 *
67 * This class requires a number of parameters which are usually provided via an
68 * external config (".ini") file.
69 * Alternatively, a memory-only object can be used to avoid physical files, see
70 * mrpt::config::CConfigFileMemory.
71 *
72 * A template config file can be generated at any moment by the user by calling
73 * saveConfigFile() with a default-constructed object.
74 *
75 * Next we provide a self-documented template config file; or see it online:
76 * https://github.com/MRPT/mrpt/blob/master/share/mrpt/config_files/navigation-ptgs/reactive3d_config.ini
77 * \verbinclude reactive3d_config.ini
78 *
79 * \sa CAbstractNavigator, CParameterizedTrajectoryGenerator,
80 * CAbstractHolonomicReactiveMethod
81 * \ingroup nav_reactive
82 */
84 {
85  public:
87  public:
88  /** See docs in ctor of base class */
90  CRobot2NavInterface& react_iterf_impl, bool enableConsoleOutput = true,
91  bool enableLogFile = false, const std::string& logFileDirectory =
92  std::string("./reactivenav.logs"));
93 
94  /** Destructor */
96 
97  /** Change the robot shape, which is taken into account for collision grid
98  * building. */
99  void changeRobotShape(TRobotShape robotShape);
100 
101  // See base class docs:
103  const mrpt::math::TPose2D& relative_robot_pose) const override;
104  virtual size_t getPTG_count() const override
105  {
106  ASSERT_(!m_ptgmultilevel.empty());
107  return m_ptgmultilevel.size();
108  }
109  virtual CParameterizedTrajectoryGenerator* getPTG(size_t i) override
110  {
111  ASSERT_(!m_ptgmultilevel.empty() && !m_ptgmultilevel[i].PTGs.empty());
112  return m_ptgmultilevel[i].PTGs[0]; // Return for the 0'th level (ptgs
113  // are replicated at each level)
114  }
116  size_t i) const override
117  {
118  ASSERT_(!m_ptgmultilevel.empty() && !m_ptgmultilevel[i].PTGs.empty());
119  return m_ptgmultilevel[i].PTGs[0]; // Return for the 0'th level (ptgs
120  // are replicated at each level)
121  }
122 
123  virtual void loadConfigFile(const mrpt::config::CConfigFileBase& c)
124  override; // See base class docs!
126  const override; // See base class docs!
127 
128  private:
129  // ------------------------------------------------------
130  // PRIVATE DEFINITIONS
131  // ------------------------------------------------------
132 
133  /** A set of PTGs of the same type, one per "height level" */
135  {
136  std::vector<CParameterizedTrajectoryGenerator*> PTGs;
139 
140  TPTGmultilevel();
141  ~TPTGmultilevel();
142  };
143 
144  // ------------------------------------------------------
145  // PRIVATE VARIABLES
146  // ------------------------------------------------------
147  /** The unsorted set of obstacles from the sensors */
149  /** One point cloud per 2.5D robot-shape-slice, coordinates relative to the
150  * robot local frame */
151  std::vector<mrpt::maps::CSimplePointsMap> m_WS_Obstacles_inlevels;
152 
153  /** The robot 3D shape model */
155 
156  /** The set of PTG-transformations to be used: indices are
157  * [ptg_index][height_index] */
158  std::vector<TPTGmultilevel> m_ptgmultilevel;
159 
160  // Steps for the reactive navigation sytem.
161  // ----------------------------------------------------------------------------
162  virtual void STEP1_InitPTGs() override;
163 
164  // See docs in parent class
166  mrpt::system::TTimeStamp& obs_timestamp) override;
167 
168  // See docs in parent class
170  const size_t ptg_idx, std::vector<double>& out_TPObstacles,
171  mrpt::nav::ClearanceDiagram& out_clearance,
172  const mrpt::math::TPose2D& rel_pose_PTG_origin_wrt_sense,
173  const bool eval_clearance) override;
174 
175  /** Generates a pointcloud of obstacles, and the robot shape, to be saved in
176  * the logging record for the current timestep */
177  virtual void loggingGetWSObstaclesAndShape(
178  CLogFileRecord& out_log) override;
179 
180 }; // end class
181 }
182 #endif
183 
184 
void setHeight(size_t level, double h)
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)...
void resize(size_t num_levels)
mrpt::maps::CSimplePointsMap m_WS_Obstacles_unsorted
The unsorted set of obstacles from the sensors.
A 3D robot shape stored as a "sliced" stack of 2D polygons, used for CReactiveNavigationSystem3D Depe...
virtual void saveConfigFile(mrpt::config::CConfigFileBase &c) const override
Saves all current options to a config file.
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...
A set of PTGs of the same type, one per "height level".
TRobotShape m_robotShape
The robot 3D shape model.
std::vector< CParameterizedTrajectoryGenerator * > PTGs
const mrpt::math::CPolygon & polygon(size_t level) const
void enableLogFile(bool enable)
Enables/disables saving log files.
A wrapper of a TPolygon2D class, implementing CSerializable.
Definition: CPolygon.h:19
A cloud of points in 2D or 3D, which can be built from a sequence of laser scans. ...
Clearance information for one particular PTG and one set of obstacles.
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
Put this macro inside any class with members that require {16,32,64}-byte memory alignment (e...
A class for storing, saving and loading a reactive navigation log record for the CReactiveNavigationS...
void setRadius(size_t level, double r)
virtual CParameterizedTrajectoryGenerator * getPTG(size_t i) override
Gets the i&#39;th PTG.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
Definition: datetime.h:40
This is the base class for any user-defined PTG.
This class allows loading and storing values and vectors of different types from a configuration text...
virtual const CParameterizedTrajectoryGenerator * getPTG(size_t i) const override
Gets the i&#39;th PTG.
virtual void loadConfigFile(const mrpt::config::CConfigFileBase &c) override
Loads all params from a file.
std::vector< TPTGmultilevel > m_ptgmultilevel
The set of PTG-transformations to be used: indices are [ptg_index][height_index]. ...
const GLubyte * c
Definition: glext.h:6313
Base class for reactive navigator systems based on TP-Space, with an arbitrary holonomic reactive met...
GLsizei const GLchar ** string
Definition: glext.h:4101
const std::vector< double > & getHeights() const
See base class CAbstractPTGBasedReactive for a description and instructions of use.
std::vector< mrpt::math::CPolygon > polygons
bool implementSenseObstacles(mrpt::system::TTimeStamp &obs_timestamp) override
Return false on any fatal error.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
std::vector< mrpt::maps::CSimplePointsMap > m_WS_Obstacles_inlevels
One point cloud per 2.5D robot-shape-slice, coordinates relative to the robot local frame...
void changeRobotShape(TRobotShape robotShape)
Change the robot shape, which is taken into account for collision grid building.
Lightweight 2D pose.
GLint level
Definition: glext.h:3600
const double & getRadius(size_t level) const
mrpt::math::CPolygon & polygon(size_t level)
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
Transform the obstacle into TP-Obstacles in TP-Spaces.
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
Lightweight 2D point.
const double & getHeight(size_t level) const
CReactiveNavigationSystem3D(CRobot2NavInterface &react_iterf_impl, bool enableConsoleOutput=true, bool enableLogFile=false, const std::string &logFileDirectory=std::string("./reactivenav.logs"))
See docs in ctor of base class.
virtual size_t getPTG_count() const override
Returns the number of different PTGs that have been setup.
Stores a candidate movement in TP-Space-based navigation.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020