Main MRPT website > C++ reference for MRPT 1.9.9
CMultiObjectiveMotionOptimizerBase.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-2018, 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 
14 #include <mrpt/rtti/CObject.h>
16 
17 namespace mrpt
18 {
19 namespace nav
20 {
21 /** Virtual base class for multi-objective motion choosers, as used for reactive
22  *navigation engines.
23  *\sa CReactiveNavigationSystem, CReactiveNavigationSystem3D
24  * \ingroup nav_reactive
25  */
27 {
29  public:
30  /** Class factory from C++ class name */
32  const std::string& className) noexcept;
33 
34  struct TResultInfo
35  {
36  /** For each candidate (vector indices), the numerical evaluation of all
37  * scores defined in TParamsBase::formula_score.
38  * A value of 0 in all scores, or an empty map, means unsuitable
39  * candidate. */
40  std::vector<std::map<std::string, double>> score_values;
41 
42  /** The final evaluation score for each candidate */
43  std::vector<double> final_evaluation;
44  /** Optionally, debug logging info will be stored here by the
45  * implementor classes */
46  std::vector<std::string> log_entries;
47  };
48 
49  /** The main entry point for the class: returns the 0-based index of the
50  * best of the N motion candidates in `movs`.
51  * If no valid one is found, `-1` will be returned.
52  */
53  int decide(
54  const std::vector<mrpt::nav::TCandidateMovementPTG>& movs,
55  TResultInfo& extra_info);
56 
57  virtual void loadConfigFile(const mrpt::config::CConfigFileBase& c) = 0;
58  virtual void saveConfigFile(mrpt::config::CConfigFileBase& c) const = 0;
59 
60  /** Common params for all children */
62  {
63  TParamsBase();
64 
65  /** A list of `name` -> mathematical expression (in the format of the
66  * exprtk library) for
67  * the list of "score" factors to evaluate.
68  */
69  std::map<std::string, std::string> formula_score;
70 
71  /** A list of exprtk expressions for conditions that any candidate
72  * movement must
73  * fulfill in order to get through the evaluation process. *All* assert
74  * conditions must be satisfied.
75  */
76  std::vector<std::string> movement_assert;
77 
78  /** List of score names (as defined in the key of `formula_score`) that
79  * must be normalized
80  * across all candidates, such that the maximum value is 1. */
81  std::vector<std::string> scores_to_normalize;
82 
83  virtual void loadFromConfigFile(
85  const std::string& section) override; // See base docs
86  virtual void saveToConfigFile(
88  const std::string& section) const override; // See base docs
89  };
90 
91  /** Resets the object state; use if the parameters change, so they are
92  * re-read and applied. */
93  virtual void clear();
94 
95  protected:
97 
98  private:
99  // This virtual method is called by decide().
100  virtual int impl_decide(
101  const std::vector<mrpt::nav::TCandidateMovementPTG>& movs,
102  TResultInfo& extra_info) = 0;
103 
105 
106  /** score names -> score compiled expressions */
107  std::map<std::string, mrpt::expr::CRuntimeCompiledExpression> m_score_exprs;
108  std::vector<mrpt::expr::CRuntimeCompiledExpression> m_movement_assert_exprs;
109  std::map<std::string, double> m_expr_vars;
110 };
111 }
112 }
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:252
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:46
mrpt::nav::CMultiObjectiveMotionOptimizerBase::Ptr
std::shared_ptr< CMultiObjectiveMotionOptimizerBase > Ptr
Definition: CMultiObjectiveMotionOptimizerBase.h:28
mrpt::nav::CMultiObjectiveMotionOptimizerBase::m_movement_assert_exprs
std::vector< mrpt::expr::CRuntimeCompiledExpression > m_movement_assert_exprs
Definition: CMultiObjectiveMotionOptimizerBase.h:108
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase
Common params for all children.
Definition: CMultiObjectiveMotionOptimizerBase.h:61
c
const GLubyte * c
Definition: glext.h:6313
mrpt::nav::CMultiObjectiveMotionOptimizerBase::saveConfigFile
virtual void saveConfigFile(mrpt::config::CConfigFileBase &c) const =0
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TResultInfo
Definition: CMultiObjectiveMotionOptimizerBase.h:34
TCandidateMovementPTG.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
CRuntimeCompiledExpression.h
mrpt::nav::CMultiObjectiveMotionOptimizerBase::m_params_base
TParamsBase & m_params_base
Definition: CMultiObjectiveMotionOptimizerBase.h:104
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:69
source
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
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:44
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::loadFromConfigFile
virtual 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:261
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
The virtual base class of all MRPT classes with a unified RTTI system.
Definition: CObject.h:142
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:40
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:28
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:26
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::TParamsBase
TParamsBase()
Definition: CMultiObjectiveMotionOptimizerBase.cpp:245
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:81
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:76
mrpt::nav::CMultiObjectiveMotionOptimizerBase::m_expr_vars
std::map< std::string, double > m_expr_vars
Definition: CMultiObjectiveMotionOptimizerBase.h:109
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TResultInfo::final_evaluation
std::vector< double > final_evaluation
The final evaluation score for each candidate.
Definition: CMultiObjectiveMotionOptimizerBase.h:43
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:107
mrpt::nav::CMultiObjectiveMotionOptimizerBase::TParamsBase::saveToConfigFile
virtual 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:320
params
GLenum const GLfloat * params
Definition: glext.h:3534



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST