MRPT  2.0.4
CAbstractHolonomicReactiveMethod.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 #include <mrpt/math/TPoint2D.h>
17 
19 
20 namespace mrpt::nav
21 {
22 /** \addtogroup nav_holo Holonomic navigation methods
23  * \ingroup mrpt_nav_grp
24  * @{ */
25 
26 /** A base class for holonomic reactive navigation methods.
27  * \sa CHolonomicVFF,CHolonomicND,CHolonomicFullEval, CReactiveNavigationSystem
28  */
31 {
33  public:
34  /** Input parameters for CAbstractHolonomicReactiveMethod::navigate() */
35  struct NavInput
36  {
37  /** Distance to obstacles in polar coordinates, relative to the robot.
38  * First index refers to -PI direction, and last one to +PI direction.
39  * Distances can be dealed as "meters", although when used inside the
40  * PTG-based navigation system, they are "pseudometers", normalized to
41  * the range [0,1].
42  */
43  std::vector<double> obstacles;
44  /** Relative location (x,y) of target point(s). In the same units than
45  * `obstacles`. If many, last targets have higher priority. */
46  std::vector<mrpt::math::TPoint2D> targets;
47  /** Maximum robot speed, in the same units than `obstacles`, per second.
48  */
49  double maxRobotSpeed{1.0};
50  /** Maximum expected value to be found in `obstacles`. Typically, values
51  * in `obstacles` larger or equal to this value mean there is no visible
52  * obstacle in that direction. */
53  double maxObstacleDist{1.0};
54  /** The computed clearance for each direction (optional in some
55  * implementations). Leave to default (NULL) if not needed. */
57 
58  NavInput();
59  };
60 
61  /** Output for CAbstractHolonomicReactiveMethod::navigate() */
62  struct NavOutput
63  {
64  /** The desired motion direction, in the range [-PI, PI] */
65  double desiredDirection{0};
66  /** The desired motion speed in that direction, from 0 up to
67  * NavInput::maxRobotSpeed */
68  double desiredSpeed{0};
69 
70  /** The navigation method will create a log record and store it here via
71  * a smart pointer. Input value is ignored. */
73 
74  NavOutput();
75  };
76 
78  const std::string& className) noexcept;
79 
80  /** Invokes the holonomic navigation algorithm itself. See the description
81  * of the input/output structures for details on each parameter. */
82  virtual void navigate(const NavInput& ni, NavOutput& no) = 0;
83 
84  /** ctor */
85  CAbstractHolonomicReactiveMethod(const std::string& defaultCfgSectionName);
86  /** virtual dtor */
88 
89  /** Initialize the parameters of the navigator, reading from the default
90  * section name (see derived classes) or the one set via
91  * setConfigFileSectionName() */
92  virtual void initialize(const mrpt::config::CConfigFileBase& c) = 0;
93  /** saves all available parameters, in a forma loadable by `initialize()` */
94  virtual void saveConfigFile(mrpt::config::CConfigFileBase& c) const = 0;
95  /** Defines the name of the section used in initialize() */
96  void setConfigFileSectionName(const std::string& sectName);
97  /** Gets the name of the section used in initialize() */
98  std::string getConfigFileSectionName() const;
99 
100  /** Returns the actual value of this parameter [m], as set via the children
101  * class options structure. \sa setTargetApproachSlowDownDistance() */
102  virtual double getTargetApproachSlowDownDistance() const = 0;
103  /** Sets the actual value of this parameter [m]. \sa
104  * getTargetApproachSlowDownDistance() */
105  virtual void setTargetApproachSlowDownDistance(const double dist) = 0;
106 
107  /** Class factory from class name, e.g. `"CHolonomicVFF"`, etc.
108  * \exception std::logic_error On invalid or missing parameters. */
110  const std::string& className) noexcept;
111 
112  /** Optionally, sets the associated PTG, just in case a derived class
113  * requires this info (not required for methods where the robot kinematics
114  * are totally abstracted) */
116  /** Returns the pointer set by setAssociatedPTG() */
118 
120  {
122  }
123 
124  protected:
125  /** If applicable, this will contain the argument of the most recent call to
126  * setAssociatedPTG() */
128  /** Whether to decrease speed when approaching target */
130 
131  private:
132  /** used in setConfigFileSectionName(), initialize() */
133  std::string m_cfgSectionName;
134 };
135 /** @} */
136 } // namespace mrpt::nav
void setAssociatedPTG(mrpt::nav::CParameterizedTrajectoryGenerator *ptg)
Optionally, sets the associated PTG, just in case a derived class requires this info (not required fo...
std::vector< double > obstacles
Distance to obstacles in polar coordinates, relative to the robot.
A base class for holonomic reactive navigation methods.
CAbstractHolonomicReactiveMethod(const std::string &defaultCfgSectionName)
ctor
Clearance information for one particular PTG and one set of obstacles.
bool m_enableApproachTargetSlowDown
Whether to decrease speed when approaching target.
~CAbstractHolonomicReactiveMethod() override
virtual dtor
std::vector< mrpt::math::TPoint2D > targets
Relative location (x,y) of target point(s).
#define DEFINE_VIRTUAL_SERIALIZABLE(class_name)
This declaration must be inserted in virtual CSerializable classes definition:
double maxRobotSpeed
Maximum robot speed, in the same units than obstacles, per second.
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 void saveConfigFile(mrpt::config::CConfigFileBase &c) const =0
saves all available parameters, in a forma loadable by initialize()
double desiredDirection
The desired motion direction, in the range [-PI, PI].
CHolonomicLogFileRecord::Ptr logRecord
The navigation method will create a log record and store it here via a smart pointer.
double maxObstacleDist
Maximum expected value to be found in obstacles.
double desiredSpeed
The desired motion speed in that direction, from 0 up to NavInput::maxRobotSpeed. ...
const mrpt::nav::ClearanceDiagram * clearance
The computed clearance for each direction (optional in some implementations).
mrpt::nav::CParameterizedTrajectoryGenerator * m_associatedPTG
If applicable, this will contain the argument of the most recent call to setAssociatedPTG() ...
virtual void initialize(const mrpt::config::CConfigFileBase &c)=0
Initialize the parameters of the navigator, reading from the default section name (see derived classe...
static CAbstractHolonomicReactiveMethod::Ptr Factory(const std::string &className) noexcept
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:30
std::string getConfigFileSectionName() const
Gets the name of the section used in initialize()
virtual double getTargetApproachSlowDownDistance() const =0
Returns the actual value of this parameter [m], as set via the children class options structure...
std::string m_cfgSectionName
used in setConfigFileSectionName(), initialize()
virtual void navigate(const NavInput &ni, NavOutput &no)=0
Invokes the holonomic navigation algorithm itself.
Input parameters for CAbstractHolonomicReactiveMethod::navigate()
Output for CAbstractHolonomicReactiveMethod::navigate()
void setConfigFileSectionName(const std::string &sectName)
Defines the name of the section used in initialize()
virtual void setTargetApproachSlowDownDistance(const double dist)=0
Sets the actual value of this parameter [m].
static CAbstractHolonomicReactiveMethod * Create(const std::string &className) noexcept
Class factory from class name, e.g.
mrpt::nav::CParameterizedTrajectoryGenerator * getAssociatedPTG() const
Returns the pointer set by setAssociatedPTG()



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020