Main MRPT website > C++ reference for MRPT 1.5.3
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  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, NAV_IMPEXP)
19  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(CHolonomicFullEval, CAbstractHolonomicReactiveMethod, NAV_IMPEXP )
20 
21  /** \addtogroup nav_holo Holonomic navigation methods
22  * \ingroup mrpt_nav_grp
23  * @{ */
24 
25  /** Full evaluation of all possible directions within the discrete set of input directions.
26  *
27  * These are the optional parameters of the method which can be set by means of a configuration file passed to the constructor or to CHolonomicFullEval::initialize() or directly in \a CHolonomicFullEval::options
28  *
29  * \code
30  * # Section name can be changed via setConfigFileSectionName()
31  * [FULL_EVAL_CONFIG]
32  * factorWeights = 1.0 1.0 1.0 0.05 1.0
33  * factorNormalizeOrNot = 0 0 0 0 1
34  * // 0: Clearness in direction
35  * // 1: Closest approach to target along straight line (Euclidean)
36  * // 2: Distance of end collision-free point to target (Euclidean)
37  * // 3: Hysteresis
38  * // 4: Clearness to nearest obstacle along path
39  * TARGET_SLOW_APPROACHING_DISTANCE = 0.20 // Start to reduce speed when closer than this to target [m]
40  * TOO_CLOSE_OBSTACLE = 0.02 // Directions with collision-free distances below this threshold are not elegible.
41  * HYSTERESIS_SECTOR_COUNT = 5 // Range of "sectors" (directions) for hysteresis over successive timesteps
42  * PHASE1_FACTORS = 0 1 2 // Indices of the factors above to be considered in phase 1
43  * PHASE2_FACTORS = 3 4 // Indices of the factors above to be considered in phase 2
44  * PHASE1_THRESHOLD = 0.75 // Phase1 scores must be above this relative range threshold [0,1] to be considered in phase 2 (Default:`0.75`)
45  * \endcode
46  *
47  * \sa CAbstractHolonomicReactiveMethod,CReactiveNavigationSystem
48  */
50  {
52  public:
53  /** Initialize the parameters of the navigator, from some configuration file, or default values if set to NULL */
54  CHolonomicFullEval( const mrpt::utils::CConfigFileBase *INI_FILE = NULL );
55 
56  // See base class docs
57  void navigate(const NavInput & ni, NavOutput &no) MRPT_OVERRIDE;
58 
59  virtual void initialize(const mrpt::utils::CConfigFileBase &INI_FILE) MRPT_OVERRIDE; // See base class docs
60  virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const MRPT_OVERRIDE; // See base class docs
61 
62  /** Algorithm options */
64  {
65  double TOO_CLOSE_OBSTACLE; //!< Directions with collision-free distances below this threshold are not elegible.
66  double TARGET_SLOW_APPROACHING_DISTANCE; //!< Start to reduce speed when closer than this to target [m]
67  double OBSTACLE_SLOW_DOWN_DISTANCE; //!< Start to reduce speed when clearance is below this value ([0,1] ratio wrt obstacle reference/max distance)
68  double HYSTERESIS_SECTOR_COUNT; //!< Range of "sectors" (directions) for hysteresis over successive timesteps
69  std::vector<double> factorWeights; //!< See docs above
70  std::vector<int32_t> factorNormalizeOrNot; //!< 0/1 to normalize factors.
71  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 (Defaults: `PHASE1_FACTORS=0 1 2`, `PHASE2_FACTORS=`3 4`)
72  std::vector<double> PHASE_THRESHOLDS; //!< Phase 1,2,N-1... scores must be above this relative range threshold [0,1] to be considered in phase 2 (Default:`0.75`)
73 
74  bool LOG_SCORE_MATRIX; //!< (default:false, to save space)
75 
76  double clearance_threshold_ratio; //!< Ratio [0,1], times path_count, gives the minimum number of paths at each side of a target direction to be accepted as desired direction
77  double gap_width_ratio_threshold; //!< Ratio [0,1], times path_count, gives the minimum gap width to accept a direct motion towards target.
78 
79  TOptions();
80  void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source,const std::string &section) MRPT_OVERRIDE; // See base docs
81  void saveToConfigFile(mrpt::utils::CConfigFileBase &cfg ,const std::string &section) const MRPT_OVERRIDE; // See base docs
82  };
83 
84  TOptions options; //!< Parameters of the algorithm (can be set manually or loaded from CHolonomicFullEval::initialize or options.loadFromConfigFile(), etc.)
85 
86  double getTargetApproachSlowDownDistance() const MRPT_OVERRIDE { return options.TARGET_SLOW_APPROACHING_DISTANCE; }
87  void setTargetApproachSlowDownDistance(const double dist) MRPT_OVERRIDE { options.TARGET_SLOW_APPROACHING_DISTANCE = dist; }
88 
89  private:
90  unsigned int m_last_selected_sector;
91  unsigned int direction2sector(const double a, const unsigned int N);
92  mrpt::math::CMatrixD m_dirs_scores; //!< Individual scores for each direction: (i,j), i (row) are directions, j (cols) are scores. Not all directions may have evaluations, in which case a "-1" value will be found.
93 
94  virtual void postProcessDirectionEvaluations(std::vector<double> &dir_evals, const NavInput & ni, unsigned int trg_idx); // If desired, override in a derived class to manipulate the final evaluations of each directions
95 
97  {
98  unsigned int best_k;
99  double best_eval;
100  std::vector<std::vector<double> > phase_scores;
101  EvalOutput();
102  };
103 
104  void evalSingleTarget(unsigned int target_idx, const NavInput & ni, EvalOutput &eo); //!< Evals one single target of the potentially many of them in NavInput
105  }; // end of CHolonomicFullEval
106 
108 
109  /** A class for storing extra information about the execution of CHolonomicFullEval navigation.
110  * \sa CHolonomicFullEval, CHolonomicLogFileRecord
111  */
113  {
115  public:
117 
118  /** Member data */
119  int32_t selectedSector;
120  double evaluation;
121  mrpt::math::CMatrixD dirs_scores; //!< Individual scores for each direction: (i,j), i (row) are directions, j (cols) are scores. Not all directions may have evaluations, in which case a "-1" value will be found.
122  int32_t selectedTarget; //!< Normally = 0. Can be >0 if multiple targets passed simultaneously.
123 
124  const mrpt::math::CMatrixD * getDirectionScores() const MRPT_OVERRIDE { return &dirs_scores; }
125  };
127 
128  /** @} */
129  } // end namespace
130 }
131 
double gap_width_ratio_threshold
Ratio [0,1], times path_count, gives the minimum gap width to accept a direct motion towards target...
A class for storing extra information about the execution of CHolonomicFullEval navigation.
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:30
double TOO_CLOSE_OBSTACLE
Directions with collision-free distances below this threshold are not elegible.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
A base class for holonomic reactive navigation methods.
double TARGET_SLOW_APPROACHING_DISTANCE
Start to reduce speed when closer than this to target [m].
int32_t selectedTarget
Normally = 0. Can be >0 if multiple targets passed simultaneously.
std::vector< int32_t > factorNormalizeOrNot
0/1 to normalize factors.
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... scores must be above this relative range threshold [0,1] to be considered in phase 2...
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...
#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...
double getTargetApproachSlowDownDistance() const MRPT_OVERRIDE
Returns the actual value of this parameter [m], as set via the children class options structure...
A base class for log records for different holonomic navigation methods.
std::vector< double > factorWeights
See docs above.
Full evaluation of all possible directions within the discrete set of input directions.
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...
mrpt::math::CMatrixD m_dirs_scores
Individual scores for each direction: (i,j), i (row) are directions, j (cols) are scores...
double HYSTERESIS_SECTOR_COUNT
Range of "sectors" (directions) for hysteresis over successive timesteps.
Input parameters for CAbstractHolonomicReactiveMethod::navigate()
void setTargetApproachSlowDownDistance(const double dist) MRPT_OVERRIDE
Sets the actual value of this parameter [m].
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
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...
bool LOG_SCORE_MATRIX
(default:false, to save space)
const mrpt::math::CMatrixD * getDirectionScores() const MRPT_OVERRIDE



Page generated by Doxygen 1.8.13 for MRPT 1.5.3 at Tue Aug 22 01:03:35 UTC 2017