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
CObject.h
mrpt::nav::CMultiObjectiveMotionOptimizerBase::Factory
static CMultiObjectiveMotionOptimizerBase::Ptr Factory(const std::string &className) noexcept
Class factory from C++ class name.
Definition: CMultiObjectiveMotionOptimizerBase.cpp:223
DEFINE_VIRTUAL_MRPT_OBJECT
#define DEFINE_VIRTUAL_MRPT_OBJECT(class_name)
This declaration must be inserted in virtual CObject classes definition:
Definition: CObject.h:293
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TResultInfo::log_entries
std::vector< std::string > log_entries
Optionally, debug logging info will be stored here by the implementor classes.
Definition: CMultiObjectiveMotionOptimizerBase.h:44
mrpt::nav::CMultiObjectiveMotionOptimizerBase::Ptr
std::shared_ptr< CMultiObjectiveMotionOptimizerBase > Ptr
Definition: CMultiObjectiveMotionOptimizerBase.h:26
mrpt::nav::CMultiObjectiveMotionOptimizerBase::m_movement_assert_exprs
std::vector< mrpt::expr::CRuntimeCompiledExpression > m_movement_assert_exprs
Definition: CMultiObjectiveMotionOptimizerBase.h:106
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase
Common params for all children.
Definition: CMultiObjectiveMotionOptimizerBase.h:60
mrpt::nav::CMultiObjectiveMotionOptimizerBase::saveConfigFile
virtual void saveConfigFile(mrpt::config::CConfigFileBase &c) const =0
mrpt::nav
Definition: CAbstractHolonomicReactiveMethod.h:21
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TResultInfo
Definition: CMultiObjectiveMotionOptimizerBase.h:33
TCandidateMovementPTG.h
CRuntimeCompiledExpression.h
mrpt::nav::CMultiObjectiveMotionOptimizerBase::m_params_base
TParamsBase & m_params_base
Definition: CMultiObjectiveMotionOptimizerBase.h:102
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::formula_score
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...
Definition: CMultiObjectiveMotionOptimizerBase.h:67
CConfigFileBase.h
mrpt::nav::CMultiObjectiveMotionOptimizerBase::decide
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 ...
Definition: CMultiObjectiveMotionOptimizerBase.cpp:27
mrpt::nav::CMultiObjectiveMotionOptimizerBase::CMultiObjectiveMotionOptimizerBase
CMultiObjectiveMotionOptimizerBase(TParamsBase &params)
mrpt::config::CConfigFileBase
This class allows loading and storing values and vectors of different types from a configuration text...
Definition: config/CConfigFileBase.h:45
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::loadFromConfigFile
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.
Definition: CMultiObjectiveMotionOptimizerBase.cpp:260
mrpt::nav::CMultiObjectiveMotionOptimizerBase::clear
virtual void clear()
Resets the object state; use if the parameters change, so they are re-read and applied.
Definition: CMultiObjectiveMotionOptimizerBase.cpp:221
mrpt::rtti::CObject
Virtual base to provide a compiler-independent RTTI system.
Definition: CObject.h:178
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TResultInfo::score_values
std::vector< std::map< std::string, double > > score_values
For each candidate (vector indices), the numerical evaluation of all scores defined in TParamsBase::f...
Definition: CMultiObjectiveMotionOptimizerBase.h:38
mrpt::config::CLoadableOptions
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
Definition: config/CLoadableOptions.h:27
mrpt::nav::CMultiObjectiveMotionOptimizerBase::impl_decide
virtual int impl_decide(const std::vector< mrpt::nav::TCandidateMovementPTG > &movs, TResultInfo &extra_info)=0
mrpt::nav::CMultiObjectiveMotionOptimizerBase
Virtual base class for multi-objective motion choosers, as used for reactive navigation engines.
Definition: CMultiObjectiveMotionOptimizerBase.h:25
params
mrpt::vision::TStereoCalibParams params
Definition: chessboard_stereo_camera_calib_unittest.cpp:24
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::TParamsBase
TParamsBase()
Definition: CMultiObjectiveMotionOptimizerBase.cpp:244
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::scores_to_normalize
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...
Definition: CMultiObjectiveMotionOptimizerBase.h:79
CLoadableOptions.h
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::movement_assert
std::vector< std::string > movement_assert
A list of exprtk expressions for conditions that any candidate movement must fulfill in order to get ...
Definition: CMultiObjectiveMotionOptimizerBase.h:74
mrpt::nav::CMultiObjectiveMotionOptimizerBase::m_expr_vars
std::map< std::string, double > m_expr_vars
Definition: CMultiObjectiveMotionOptimizerBase.h:107
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TResultInfo::final_evaluation
std::vector< double > final_evaluation
The final evaluation score for each candidate.
Definition: CMultiObjectiveMotionOptimizerBase.h:41
mrpt::nav::CMultiObjectiveMotionOptimizerBase::loadConfigFile
virtual void loadConfigFile(const mrpt::config::CConfigFileBase &c)=0
mrpt::nav::CMultiObjectiveMotionOptimizerBase::m_score_exprs
std::map< std::string, mrpt::expr::CRuntimeCompiledExpression > m_score_exprs
score names -> score compiled expressions
Definition: CMultiObjectiveMotionOptimizerBase.h:105
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::saveToConfigFile
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.
Definition: CMultiObjectiveMotionOptimizerBase.cpp:319



Page generated by Doxygen 1.8.18 for MRPT 2.0.4 at Thu Sep 24 07:14:18 UTC 2020