RcsPySim
A robot control and simulation library
AMIKControllerActivation.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 _AMIKCONTROLLERACTIVATION_H_
32 #define _AMIKCONTROLLERACTIVATION_H_
33 
34 #include <TaskGenericIK.h>
35 #include "../config/PropertySource.h"
36 #include "ActionModelIK.h"
37 
38 namespace Rcs
39 {
40 
41 /*! Action model controlling the activations of multiple tasks. Each task is defined by a Rcs IK controller task.
42  * For every task, there is one activation variable as part of the action space.
43  * The activation is a value between 0 and 1, where 0 means to ignore the task
44  * completely. The activation values do not need to sum to 1.
45  */
47 {
48 public:
49 
50  /*! Constructor
51  * @param[in] tcm Mode that determines how the different tasks a.k.a. movement primitives are combined
52  */
53  explicit AMIKControllerActivation(RcsGraph* graph, TaskCombinationMethod tcm);
54 
55  virtual ~AMIKControllerActivation();
56 
57  // not copy- or movable - klocwork doesn't pick up the inherited ones. RCSPYSIM_NOCOPY_NOMOVE(AMControllerActivation)
58 
59  //! Add Rcs controller tasks that are always active. Do this after adding the regular tasks.
60  void addAlwaysActiveTask(Task* task);
61 
62  //! Get the number of tasks multiplied by their individual dimension, owned by the action model, except the always active tasks
63  virtual unsigned int getDim() const;
64 
65  virtual void getMinMax(double* min, double* max) const;
66 
67  virtual std::vector<std::string> getNames() const;
68 
69  void reset();
70 
71  virtual void computeCommand(MatNd* q_des, MatNd* q_dot_des, MatNd* T_des, const MatNd* action, double dt);
72 
73  virtual void getStableAction(MatNd* action) const;
74 
75  MatNd* getActivation() const;
76 
77  MatNd* getXdes() const;
78 
79  void setXdes(const MatNd* x_des);
80 
81  void setXdesFromTaskSpec(std::vector<PropertySource*>& taskSpec);
82 
83  static TaskCombinationMethod checkTaskCombinationMethod(std::string tcmName);
84 
85  const char* getTaskCombinationMethodName() const;
86 
87 protected:
88  //! The goal in task space
89  MatNd* x_des;
90  //! Store the cumulative number of task dimensions which are always active
91  unsigned int dimAlwaysActiveTasks;
92  //! The activation resulting from the action and the task combination method (used for logging)
93  MatNd* activation;
94  //! Way to combine the tasks' contribution
96 };
97 
98 } /* namespace Rcs */
99 
100 #endif /* _AMIKCONTROLLERACTIVATION_H_ */
MatNd * x_des
The goal in task space.
unsigned int dimAlwaysActiveTasks
Store the cumulative number of task dimensions which are always active.
MatNd * activation
The activation resulting from the action and the task combination method (used for logging) ...
const char * getTaskCombinationMethodName() const
TaskCombinationMethod
Definition: ActionModel.h:46
virtual std::vector< std::string > getNames() const
virtual unsigned int getDim() const
Get the number of tasks multiplied by their individual dimension, owned by the action model...
virtual void getStableAction(MatNd *action) const
static TaskCombinationMethod checkTaskCombinationMethod(std::string tcmName)
virtual void computeCommand(MatNd *q_des, MatNd *q_dot_des, MatNd *T_des, const MatNd *action, double dt)
AMIKControllerActivation(RcsGraph *graph, TaskCombinationMethod tcm)
TaskCombinationMethod taskCombinationMethod
Way to combine the tasks&#39; contribution.
void addAlwaysActiveTask(Task *task)
Add Rcs controller tasks that are always active. Do this after adding the regular tasks...
virtual void getMinMax(double *min, double *max) const
RcsGraph * graph
Definition: ActionModel.h:194
void setXdesFromTaskSpec(std::vector< PropertySource *> &taskSpec)