RcsPySim
A robot control and simulation library
AMDynamicalSystemActivation.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (c) 2020, Fabio Muratore, Honda Research Institute Europe GmbH, and
3  Technical University of Darmstadt.
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8  1. Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10  2. Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13  3. Neither the name of Fabio Muratore, Honda Research Institute Europe GmbH,
14  or Technical University of Darmstadt, nor the names of its contributors may
15  be used to endorse or promote products derived from this software without
16  specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  DISCLAIMED. IN NO EVENT SHALL FABIO MURATORE, HONDA RESEARCH INSTITUTE EUROPE GMBH,
22  OR TECHNICAL UNIVERSITY OF DARMSTADT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  POSSIBILITY OF SUCH DAMAGE.
29 *******************************************************************************/
30 
31 #ifndef _AMDYNAMICALSYSTEMACTIVATION_H_
32 #define _AMDYNAMICALSYSTEMACTIVATION_H_
33 
34 #include "ActionModel.h"
35 #include "DynamicalSystem.h"
36 
37 namespace Rcs
38 {
39 
40 /*! Action model controlling the activations of multiple tasks. Each task is defined by a DynamicalSystem.
41  * For every task, there is one activation variable as part of the action space.
42  * The activation is a value between 0 and 1, where 0 means to ignore the task
43  * completely. The activation values do not need to sum to 1.
44  */
46 {
47 public:
48 
49  /*! Constructor
50  * @param[in] wrapped ActionModel defining the output space of the tasks (takes ownership)
51  * @param[in] ds List of dynamical systems (takes ownership)
52  * @param[in] tcm Mode that determines how the different tasks a.k.a. movement primitives are combined
53  */
55  ActionModel* wrapped, std::vector<DynamicalSystem*> ds, TaskCombinationMethod tcm);
56 
58 
59  // not copy- or movable - klocwork doesn't pick up the inherited ones. RCSPYSIM_NOCOPY_NOMOVE(AMDynamicalSystemActivation)
60 
61  virtual ActionModel* clone(RcsGraph* newGraph) const;
62 
63  //! Get the number of DS, i.e. entries in the dynamicalSystems vector, owned by the action model
64  virtual unsigned int getDim() const;
65 
66  virtual void getMinMax(double* min, double* max) const;
67 
68  virtual std::vector<std::string> getNames() const;
69 
70  virtual void computeCommand(MatNd* q_des, MatNd* q_dot_des, MatNd* T_des, const MatNd* action, double dt);
71 
72  virtual void reset();
73 
74  virtual void getStableAction(MatNd* action) const;
75 
76  Eigen::VectorXd getX() const;
77 
78  Eigen::VectorXd getXdot() const;
79 
80  virtual ActionModel* getWrappedActionModel() const;
81 
82  //! Get a vector of the owned dynamical systems.
83  const std::vector<DynamicalSystem*>& getDynamicalSystems() const;
84 
85  MatNd* getActivation() const;
86 
87  static TaskCombinationMethod checkTaskCombinationMethod(std::string tcmName);
88 
89  const char* getTaskCombinationMethodName() const;
90 
91 protected:
92  //! Wrapped action model
94  //! List of dynamical systems
95  std::vector<DynamicalSystem*> dynamicalSystems;
96  //! Current state in task space
97  Eigen::VectorXd x;
98  //! Current velocity in task space
99  Eigen::VectorXd x_dot;
100  //! The activation resulting from the action and the task combination method (used for logging)
101  MatNd* activation;
102  //! Way to combine the tasks' contribution
104 };
105 
106 } /* namespace Rcs */
107 
108 #endif /* _AMDYNAMICALSYSTEMACTIVATION_H_ */
virtual std::vector< std::string > getNames() const
virtual void getStableAction(MatNd *action) const
Eigen::VectorXd x
Current state in task space.
virtual unsigned int getDim() const
Get the number of DS, i.e. entries in the dynamicalSystems vector, owned by the action model...
static TaskCombinationMethod checkTaskCombinationMethod(std::string tcmName)
TaskCombinationMethod taskCombinationMethod
Way to combine the tasks&#39; contribution.
TaskCombinationMethod
Definition: ActionModel.h:46
std::vector< DynamicalSystem * > dynamicalSystems
List of dynamical systems.
ActionModel * wrapped
Wrapped action model.
virtual ActionModel * getWrappedActionModel() const
MatNd * activation
The activation resulting from the action and the task combination method (used for logging) ...
virtual void computeCommand(MatNd *q_des, MatNd *q_dot_des, MatNd *T_des, const MatNd *action, double dt)
AMDynamicalSystemActivation(ActionModel *wrapped, std::vector< DynamicalSystem *> ds, TaskCombinationMethod tcm)
virtual void getMinMax(double *min, double *max) const
Eigen::VectorXd x_dot
Current velocity in task space.
ActionModel * clone() const
Definition: ActionModel.h:72
const std::vector< DynamicalSystem * > & getDynamicalSystems() const
Get a vector of the owned dynamical systems.