Main MRPT website > C++ reference for MRPT 1.9.9
CHolonomicFullEval.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 #pragma once
10 
13 
14 namespace mrpt
15 {
16 namespace nav
17 {
18 /** \addtogroup nav_holo Holonomic navigation methods
19  * \ingroup mrpt_nav_grp
20  * @{ */
21 
22 /** Full evaluation of all possible directions within the discrete set of input
23  * directions.
24  *
25  * These are the optional parameters of the method which can be set by means of
26  * a configuration file passed to the constructor or to
27  * CHolonomicFullEval::initialize() or directly in \a
28  * CHolonomicFullEval::options
29  *
30  * \code
31  * # Section name can be changed via setConfigFileSectionName()
32  * [FULL_EVAL_CONFIG]
33  * factorWeights = 1.0 1.0 1.0 0.05 1.0
34  * factorNormalizeOrNot = 0 0 0 0 1
35  * // 0: Clearness in direction
36  * // 1: Closest approach to target along straight line (Euclidean)
37  * // 2: Distance of end collision-free point to target (Euclidean)
38  * // 3: Hysteresis
39  * // 4: Clearness to nearest obstacle along path
40  * TARGET_SLOW_APPROACHING_DISTANCE = 0.20 // Start to reduce speed when
41  * closer than this to target [m]
42  * TOO_CLOSE_OBSTACLE = 0.02 // Directions with collision-free
43  * distances below this threshold are not elegible.
44  * HYSTERESIS_SECTOR_COUNT = 5 // Range of "sectors" (directions)
45  * for hysteresis over successive timesteps
46  * PHASE1_FACTORS = 0 1 2 // Indices of the factors above to
47  * be considered in phase 1
48  * PHASE2_FACTORS = 3 4 // Indices of the factors above to
49  * be considered in phase 2
50  * PHASE1_THRESHOLD = 0.75 // Phase1 scores must be above this
51  * relative range threshold [0,1] to be considered in phase 2 (Default:`0.75`)
52  * \endcode
53  *
54  * \sa CAbstractHolonomicReactiveMethod,CReactiveNavigationSystem
55  */
57 {
59  public:
60  /** Initialize the parameters of the navigator, from some configuration
61  * file, or default values if set to nullptr */
62  CHolonomicFullEval(const mrpt::utils::CConfigFileBase* INI_FILE = nullptr);
63 
64  // See base class docs
65  void navigate(const NavInput& ni, NavOutput& no) override;
66 
67  virtual void initialize(const mrpt::utils::CConfigFileBase& INI_FILE)
68  override; // See base class docs
69  virtual void saveConfigFile(
70  mrpt::utils::CConfigFileBase& c) const override; // See base class docs
71 
72  /** Algorithm options */
74  {
75  /** Directions with collision-free distances below this threshold are
76  * not elegible. */
78  /** Start to reduce speed when closer than this to target [m] */
80  /** Start to reduce speed when clearance is below this value ([0,1]
81  * ratio wrt obstacle reference/max distance) */
83  /** Range of "sectors" (directions) for hysteresis over successive
84  * timesteps */
86  /** See docs above */
87  std::vector<double> factorWeights;
88  /** 0/1 to normalize factors. */
89  std::vector<int32_t> factorNormalizeOrNot;
90  /** Factor indices [0,4] for the factors to consider in each phase
91  * 1,2,...N of the movement decision (Defaults: `PHASE1_FACTORS=0 1 2`,
92  * `PHASE2_FACTORS=`3 4`) */
93  std::vector<std::vector<int32_t>> PHASE_FACTORS;
94  /** Phase 1,2,N-1... scores must be above this relative range threshold
95  * [0,1] to be considered in phase 2 (Default:`0.75`) */
96  std::vector<double> PHASE_THRESHOLDS;
97 
98  /** (default:false, to save space) */
100 
101  /** Ratio [0,1], times path_count, gives the minimum number of paths at
102  * each side of a target direction to be accepted as desired direction
103  */
105  /** Ratio [0,1], times path_count, gives the minimum gap width to
106  * accept a direct motion towards target. */
108 
109  TOptions();
110  void loadFromConfigFile(
112  const std::string& section) override; // See base docs
113  void saveToConfigFile(
115  const std::string& section) const override; // See base docs
116  };
117 
118  /** Parameters of the algorithm (can be set manually or loaded from
119  * CHolonomicFullEval::initialize or options.loadFromConfigFile(), etc.) */
121 
122  double getTargetApproachSlowDownDistance() const override
123  {
125  }
126  void setTargetApproachSlowDownDistance(const double dist) override
127  {
129  }
130 
131  private:
133  unsigned int direction2sector(const double a, const unsigned int N);
134  /** Individual scores for each direction: (i,j), i (row) are directions, j
135  * (cols) are scores. Not all directions may have evaluations, in which case
136  * a "-1" value will be found. */
138 
139  virtual void postProcessDirectionEvaluations(
140  std::vector<double>& dir_evals, const NavInput& ni,
141  unsigned int trg_idx); // If desired, override in a derived class to
142  // manipulate the final evaluations of each
143  // directions
144 
145  struct EvalOutput
146  {
147  unsigned int best_k;
148  double best_eval;
149  std::vector<std::vector<double>> phase_scores;
150  EvalOutput();
151  };
152 
153  /** Evals one single target of the potentially many of them in NavInput */
154  void evalSingleTarget(
155  unsigned int target_idx, const NavInput& ni, EvalOutput& eo);
156 }; // end of CHolonomicFullEval
157 
158 /** A class for storing extra information about the execution of
159  * CHolonomicFullEval navigation.
160  * \sa CHolonomicFullEval, CHolonomicLogFileRecord
161  */
163 {
165  public:
167 
168  /** Member data */
170  double evaluation;
171  /** Individual scores for each direction: (i,j), i (row) are directions, j
172  * (cols) are scores. Not all directions may have evaluations, in which case
173  * a "-1" value will be found. */
175  /** Normally = 0. Can be >0 if multiple targets passed simultaneously. */
177 
178  const mrpt::math::CMatrixD* getDirectionScores() const override
179  {
180  return &dirs_scores;
181  }
182 };
183 
184 /** @} */
185 } // end namespace
186 }
unsigned int direction2sector(const double a, const unsigned int N)
double gap_width_ratio_threshold
Ratio [0,1], times path_count, gives the minimum gap width to accept a direct motion towards target...
double getTargetApproachSlowDownDistance() const override
Returns the actual value of this parameter [m], as set via the children class options structure...
virtual void postProcessDirectionEvaluations(std::vector< double > &dir_evals, const NavInput &ni, unsigned int trg_idx)
A class for storing extra information about the execution of CHolonomicFullEval navigation.
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:25
double TOO_CLOSE_OBSTACLE
Directions with collision-free distances below this threshold are not elegible.
CHolonomicFullEval(const mrpt::utils::CConfigFileBase *INI_FILE=nullptr)
Initialize the parameters of the navigator, from some configuration file, or default values if set to...
A base class for holonomic reactive navigation methods.
double TARGET_SLOW_APPROACHING_DISTANCE
Start to reduce speed when closer than this to target [m].
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const override
saves all available parameters, in a forma loadable by initialize()
std::vector< int32_t > factorNormalizeOrNot
0/1 to normalize factors.
const mrpt::math::CMatrixD * getDirectionScores() const override
double clearance_threshold_ratio
Ratio [0,1], times path_count, gives the minimum number of paths at each side of a target direction t...
std::vector< double > PHASE_THRESHOLDS
Phase 1,2,N-1...
This class allows loading and storing values and vectors of different types from a configuration text...
TOptions options
Parameters of the algorithm (can be set manually or loaded from CHolonomicFullEval::initialize or opt...
double OBSTACLE_SLOW_DOWN_DISTANCE
Start to reduce speed when clearance is below this value ([0,1] ratio wrt obstacle reference/max dist...
const GLubyte * c
Definition: glext.h:6313
A base class for log records for different holonomic navigation methods.
void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg, const std::string &section) const override
This method saves the options to a ".ini"-like file or memory-stored string list. ...
std::vector< double > factorWeights
See docs above.
void evalSingleTarget(unsigned int target_idx, const NavInput &ni, EvalOutput &eo)
Evals one single target of the potentially many of them in NavInput.
GLsizei const GLchar ** string
Definition: glext.h:4101
Full evaluation of all possible directions within the discrete set of input directions.
__int32 int32_t
Definition: rptypes.h:46
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void navigate(const NavInput &ni, NavOutput &no) override
Invokes the holonomic navigation algorithm itself.
mrpt::math::CMatrixD m_dirs_scores
Individual scores for each direction: (i,j), i (row) are directions, j (cols) are scores...
void setTargetApproachSlowDownDistance(const double dist) override
Sets the actual value of this parameter [m].
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
double HYSTERESIS_SECTOR_COUNT
Range of "sectors" (directions) for hysteresis over successive timesteps.
Input parameters for CAbstractHolonomicReactiveMethod::navigate()
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
Output for CAbstractHolonomicReactiveMethod::navigate()
mrpt::math::CMatrixD dirs_scores
Individual scores for each direction: (i,j), i (row) are directions, j (cols) are scores...
std::vector< std::vector< double > > phase_scores
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
std::vector< std::vector< int32_t > > PHASE_FACTORS
Factor indices [0,4] for the factors to consider in each phase 1,2,...N of the movement decision (Def...
virtual void initialize(const mrpt::utils::CConfigFileBase &INI_FILE) override
Initialize the parameters of the navigator, reading from the default section name (see derived classe...
bool LOG_SCORE_MATRIX
(default:false, to save space)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019