MRPT  2.0.4
CMultiObjectiveMotionOptimizerBase.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 
15 #include <mrpt/rtti/CObject.h>
16 
17 namespace mrpt::nav
18 {
19 /** Virtual base class for multi-objective motion choosers, as used for reactive
20  *navigation engines.
21  *\sa CReactiveNavigationSystem, CReactiveNavigationSystem3D
22  * \ingroup nav_reactive
23  */
25 {
27  public:
28  /** Class factory from C++ class name */
30  const std::string& className) noexcept;
31 
32  struct TResultInfo
33  {
34  /** For each candidate (vector indices), the numerical evaluation of all
35  * scores defined in TParamsBase::formula_score.
36  * A value of 0 in all scores, or an empty map, means unsuitable
37  * candidate. */
38  std::vector<std::map<std::string, double>> score_values;
39 
40  /** The final evaluation score for each candidate */
41  std::vector<double> final_evaluation;
42  /** Optionally, debug logging info will be stored here by the
43  * implementor classes */
44  std::vector<std::string> log_entries;
45  };
46 
47  /** The main entry point for the class: returns the 0-based index of the
48  * best of the N motion candidates in `movs`.
49  * If no valid one is found, `-1` will be returned.
50  */
51  int decide(
52  const std::vector<mrpt::nav::TCandidateMovementPTG>& movs,
53  TResultInfo& extra_info);
54 
55  virtual void loadConfigFile(const mrpt::config::CConfigFileBase& c) = 0;
56  virtual void saveConfigFile(mrpt::config::CConfigFileBase& c) const = 0;
57 
58  /** Common params for all children */
60  {
61  TParamsBase();
62 
63  /** A list of `name` -> mathematical expression (in the format of the
64  * exprtk library) for
65  * the list of "score" factors to evaluate.
66  */
67  std::map<std::string, std::string> formula_score;
68 
69  /** A list of exprtk expressions for conditions that any candidate
70  * movement must
71  * fulfill in order to get through the evaluation process. *All* assert
72  * conditions must be satisfied.
73  */
74  std::vector<std::string> movement_assert;
75 
76  /** List of score names (as defined in the key of `formula_score`) that
77  * must be normalized
78  * across all candidates, such that the maximum value is 1. */
79  std::vector<std::string> scores_to_normalize;
80 
81  void loadFromConfigFile(
82  const mrpt::config::CConfigFileBase& source,
83  const std::string& section) override; // See base docs
84  void saveToConfigFile(
86  const std::string& section) const override; // See base docs
87  };
88 
89  /** Resets the object state; use if the parameters change, so they are
90  * re-read and applied. */
91  virtual void clear();
92 
93  protected:
95 
96  private:
97  // This virtual method is called by decide().
98  virtual int impl_decide(
99  const std::vector<mrpt::nav::TCandidateMovementPTG>& movs,
100  TResultInfo& extra_info) = 0;
101 
103 
104  /** score names -> score compiled expressions */
105  std::map<std::string, mrpt::expr::CRuntimeCompiledExpression> m_score_exprs;
106  std::vector<mrpt::expr::CRuntimeCompiledExpression> m_movement_assert_exprs;
107  std::map<std::string, double> m_expr_vars;
108 };
109 } // namespace mrpt::nav
std::vector< std::string > log_entries
Optionally, debug logging info will be stored here by the implementor classes.
int decide(const std::vector< mrpt::nav::TCandidateMovementPTG > &movs, TResultInfo &extra_info)
The main entry point for the class: returns the 0-based index of the best of the N motion candidates ...
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
std::vector< double > final_evaluation
The final evaluation score for each candidate.
virtual void clear()
Resets the object state; use if the parameters change, so they are re-read and applied.
#define DEFINE_VIRTUAL_MRPT_OBJECT(class_name)
This declaration must be inserted in virtual CObject classes definition:
Definition: CObject.h:293
mrpt::vision::TStereoCalibParams params
Virtual base to provide a compiler-independent RTTI system.
Definition: CObject.h:177
std::vector< std::map< std::string, double > > score_values
For each candidate (vector indices), the numerical evaluation of all scores defined in TParamsBase::f...
virtual void loadConfigFile(const mrpt::config::CConfigFileBase &c)=0
This class allows loading and storing values and vectors of different types from a configuration text...
void saveToConfigFile(mrpt::config::CConfigFileBase &cfg, const std::string &section) const override
This method saves the options to a ".ini"-like file or memory-stored string list. ...
static CMultiObjectiveMotionOptimizerBase::Ptr Factory(const std::string &className) noexcept
Class factory from C++ class name.
std::vector< mrpt::expr::CRuntimeCompiledExpression > m_movement_assert_exprs
std::map< std::string, std::string > formula_score
A list of name -> mathematical expression (in the format of the exprtk library) for the list of "scor...
Virtual base class for multi-objective motion choosers, as used for reactive navigation engines...
std::vector< std::string > scores_to_normalize
List of score names (as defined in the key of formula_score) that must be normalized across all candi...
std::map< std::string, mrpt::expr::CRuntimeCompiledExpression > m_score_exprs
score names -> score compiled expressions
std::vector< std::string > movement_assert
A list of exprtk expressions for conditions that any candidate movement must fulfill in order to get ...
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
CMultiObjectiveMotionOptimizerBase(TParamsBase &params)
virtual void saveConfigFile(mrpt::config::CConfigFileBase &c) const =0
virtual int impl_decide(const std::vector< mrpt::nav::TCandidateMovementPTG > &movs, TResultInfo &extra_info)=0



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