Main MRPT website > C++ reference for MRPT 1.5.7
CAbstractHolonomicReactiveMethod.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-2017, 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 CAbstractHolonomicReactiveMethod_H
10 #define CAbstractHolonomicReactiveMethod_H
11 
13 #include <mrpt/utils/TEnumType.h>
18 
20 
21 namespace mrpt
22 {
23  namespace nav
24  {
25  /** \addtogroup nav_holo Holonomic navigation methods
26  * \ingroup mrpt_nav_grp
27  * @{ */
28 
29  /** The implemented reactive navigation methods. This enum works with mrpt::utils::TEnumType.
30  * Since MRPT 1.5.0 the preferred way to select a holonomic method is, instead of this enum,
31  * via the class factory method CAbstractHolonomicReactiveMethod::Create() via the class name. */
33  {
34  hmVIRTUAL_FORCE_FIELDS = 0, //!< CHolonomicVFF
35  hmSEARCH_FOR_BEST_GAP = 1, //!< CHolonomicND
36  hmFULL_EVAL = 2 //!< CHolonomicFullEval
37  };
38 
40 
41  /** A base class for holonomic reactive navigation methods.
42  * \sa CHolonomicVFF,CHolonomicND,CHolonomicFullEval, CReactiveNavigationSystem
43  */
45  public mrpt::utils::CSerializable
46  {
48  public:
49  /** Input parameters for CAbstractHolonomicReactiveMethod::navigate() */
51  {
52  /** Distance to obstacles in polar coordinates, relative to the robot.
53  * First index refers to -PI direction, and last one to +PI direction.
54  * Distances can be dealed as "meters", although when used inside the PTG-based navigation system, they are "pseudometers", normalized to the range [0,1].
55  */
56  std::vector<double> obstacles;
57  std::vector<mrpt::math::TPoint2D> targets; //!< Relative location (x,y) of target point(s). In the same units than `obstacles`. If many, last targets have higher priority.
58  double maxRobotSpeed; //!< Maximum robot speed, in the same units than `obstacles`, per second.
59  double maxObstacleDist; //!< Maximum expected value to be found in `obstacles`. Typically, values in `obstacles` larger or equal to this value mean there is no visible obstacle in that direction.
60  const mrpt::nav::ClearanceDiagram *clearance; //!< The computed clearance for each direction (optional in some implementations). Leave to default (NULL) if not needed.
61 
62  NavInput();
63  };
64 
65  /** Output for CAbstractHolonomicReactiveMethod::navigate() */
67  {
68  double desiredDirection; //!< The desired motion direction, in the range [-PI, PI]
69  double desiredSpeed; //!< The desired motion speed in that direction, from 0 up to NavInput::maxRobotSpeed
70 
71  /** The navigation method will create a log record and store it here via a smart pointer. Input value is ignored. */
72  CHolonomicLogFileRecordPtr logRecord;
73 
74  NavOutput();
75  };
76 
77 
78  /** Invokes the holonomic navigation algorithm itself. See the description of the input/output structures for details on each parameter. */
79  virtual void navigate(const NavInput & ni, NavOutput &no) = 0;
80 
81  CAbstractHolonomicReactiveMethod(const std::string &defaultCfgSectionName); //!< ctor
82  virtual ~CAbstractHolonomicReactiveMethod(); //!< virtual dtor
83 
84  /** Initialize the parameters of the navigator, reading from the default section name (see derived classes) or the one set via setConfigFileSectionName() */
85  virtual void initialize( const mrpt::utils::CConfigFileBase &c ) = 0;
86  virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const = 0; //!< saves all available parameters, in a forma loadable by `initialize()`
87  void setConfigFileSectionName(const std::string &sectName); //!< Defines the name of the section used in initialize()
88  std::string getConfigFileSectionName() const; //!< Gets the name of the section used in initialize()
89 
90  virtual double getTargetApproachSlowDownDistance() const = 0; //!< Returns the actual value of this parameter [m], as set via the children class options structure. \sa setTargetApproachSlowDownDistance()
91  virtual void setTargetApproachSlowDownDistance(const double dist) = 0; //!< Sets the actual value of this parameter [m]. \sa getTargetApproachSlowDownDistance()
92 
93  /** Class factory from class name, e.g. `"CHolonomicVFF"`, etc.
94  * \exception std::logic_error On invalid or missing parameters. */
95  static CAbstractHolonomicReactiveMethod * Create(const std::string &className) MRPT_NO_THROWS;
96 
97  void setAssociatedPTG(mrpt::nav::CParameterizedTrajectoryGenerator *ptg); //!< Optionally, sets the associated PTG, just in case a derived class requires this info (not required for methods where the robot kinematics are totally abstracted)
98  mrpt::nav::CParameterizedTrajectoryGenerator * getAssociatedPTG() const; //!< Returns the pointer set by setAssociatedPTG()
99 
100  void enableApproachTargetSlowDown(bool enable) { m_enableApproachTargetSlowDown = enable; }
101  protected:
102  mrpt::nav::CParameterizedTrajectoryGenerator *m_associatedPTG; //!< If applicable, this will contain the argument of the most recent call to setAssociatedPTG()
103  bool m_enableApproachTargetSlowDown; //!< Whether to decrease speed when approaching target
104 
105  private:
106  std::string m_cfgSectionName; //!< used in setConfigFileSectionName(), initialize()
107  };
109  /** @} */
110 
111  }
112  // Specializations MUST occur at the same namespace:
113  namespace utils
114  {
115  template <>
117  {
119  static void fill(bimap<enum_t,std::string> &m_map)
120  {
121  m_map.insert(nav::hmVIRTUAL_FORCE_FIELDS, "hmVIRTUAL_FORCE_FIELDS");
122  m_map.insert(nav::hmSEARCH_FOR_BEST_GAP, "hmSEARCH_FOR_BEST_GAP");
123  m_map.insert(nav::hmFULL_EVAL, "hmFULL_EVAL");
124  }
125  };
126  } // End of namespace
127 }
128 
129 
130 #endif
131 
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
A base class for holonomic reactive navigation methods.
std::string m_cfgSectionName
used in setConfigFileSectionName(), initialize()
virtual void setTargetApproachSlowDownDistance(const double dist)=0
Sets the actual value of this parameter [m].
mrpt::nav::CParameterizedTrajectoryGenerator * m_associatedPTG
If applicable, this will contain the argument of the most recent call to setAssociatedPTG()
virtual void initialize(const mrpt::utils::CConfigFileBase &c)=0
Initialize the parameters of the navigator, reading from the default section name (see derived classe...
virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const =0
saves all available parameters, in a forma loadable by initialize()
virtual void navigate(const NavInput &ni, NavOutput &no)=0
Invokes the holonomic navigation algorithm itself.
virtual double getTargetApproachSlowDownDistance() const =0
Returns the actual value of this parameter [m], as set via the children class options structure.
bool m_enableApproachTargetSlowDown
Whether to decrease speed when approaching target.
This is the base class for any user-defined PTG.
Clearance information for one particular PTG and one set of obstacles.
This class allows loading and storing values and vectors of different types from a configuration text...
The virtual base class which provides a unified interface for all persistent objects in MRPT.
Definition: CSerializable.h:40
A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std...
Definition: bimap.h:29
void insert(const KEY &k, const VALUE &v)
Insert a new pair KEY<->VALUE in the bi-map.
Definition: bimap.h:69
const GLubyte * c
Definition: glext.h:5590
GLsizei const GLchar ** string
Definition: glext.h:3919
THolonomicMethod
The implemented reactive navigation methods.
@ hmSEARCH_FOR_BEST_GAP
CHolonomicND.
@ hmVIRTUAL_FORCE_FIELDS
CHolonomicVFF.
@ hmFULL_EVAL
CHolonomicFullEval.
#define MRPT_NO_THROWS
C++11 noexcept: Used after member declarations.
Definition: mrpt_macros.h:72
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Input parameters for CAbstractHolonomicReactiveMethod::navigate()
double maxObstacleDist
Maximum expected value to be found in obstacles. Typically, values in obstacles larger or equal to th...
std::vector< mrpt::math::TPoint2D > targets
Relative location (x,y) of target point(s). In the same units than obstacles. If many,...
std::vector< double > obstacles
Distance to obstacles in polar coordinates, relative to the robot.
double maxRobotSpeed
Maximum robot speed, in the same units than obstacles, per second.
const mrpt::nav::ClearanceDiagram * clearance
The computed clearance for each direction (optional in some implementations). Leave to default (NULL)...
Output for CAbstractHolonomicReactiveMethod::navigate()
CHolonomicLogFileRecordPtr logRecord
The navigation method will create a log record and store it here via a smart pointer.
double desiredDirection
The desired motion direction, in the range [-PI, PI].
double desiredSpeed
The desired motion speed in that direction, from 0 up to NavInput::maxRobotSpeed.
static void fill(bimap< enum_t, std::string > &m_map)
Only specializations of this class are defined for each enum type of interest.
Definition: TEnumType.h:24



Page generated by Doxygen 1.9.1 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at mar 26 may 2026 13:12:03 CEST