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-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 
14 #include <mrpt/utils/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::utils::CConfigFileBase& c) = 0;
58  virtual void saveConfigFile(mrpt::utils::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::math::CRuntimeCompiledExpression> m_score_exprs;
108  std::vector<mrpt::math::CRuntimeCompiledExpression> m_movement_assert_exprs;
109  std::map<std::string, double> m_expr_vars;
110 };
111 }
112 }
std::map< std::string, mrpt::math::CRuntimeCompiledExpression > m_score_exprs
score names -> score compiled expressions
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 ...
std::vector< mrpt::math::CRuntimeCompiledExpression > m_movement_assert_exprs
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 CSerializable classes definition:
Definition: CObject.h:249
std::shared_ptr< CMultiObjectiveMotionOptimizerBase > Ptr
std::vector< std::map< std::string, double > > score_values
For each candidate (vector indices), the numerical evaluation of all scores defined in TParamsBase::f...
This class allows loading and storing values and vectors of different types from a configuration text...
static CMultiObjectiveMotionOptimizerBase::Ptr Factory(const std::string &className) noexcept
Class factory from C++ class name.
const GLubyte * c
Definition: glext.h:6313
virtual 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. ...
GLsizei const GLchar ** string
Definition: glext.h:4101
virtual void saveConfigFile(mrpt::utils::CConfigFileBase &c) const =0
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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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::vector< std::string > movement_assert
A list of exprtk expressions for conditions that any candidate movement must fulfill in order to get ...
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
The virtual base class of all MRPT classes with a unified RTTI system.
Definition: CObject.h:147
virtual void loadConfigFile(const mrpt::utils::CConfigFileBase &c)=0
CMultiObjectiveMotionOptimizerBase(TParamsBase &params)
GLenum const GLfloat * params
Definition: glext.h:3534
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
virtual int impl_decide(const std::vector< mrpt::nav::TCandidateMovementPTG > &movs, TResultInfo &extra_info)=0
virtual 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.



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