-
Notifications
You must be signed in to change notification settings - Fork 13
/
Task.hpp
97 lines (73 loc) · 3.26 KB
/
Task.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef TASK_HPP
#define TASK_HPP
#include "TaskConfig.hpp"
#include "RobotModel.hpp"
#include <base/Eigen.hpp>
#include <base/Time.hpp>
#include <base/NamedVector.hpp>
#include <memory>
namespace wbc{
/**
* @brief Abstract class to represent a generic task for a WBC optimization problem.
*/
class Task {
public:
/** @brief Default constructor */
Task();
/** @brief Resizes all members */
Task(const TaskConfig& _config, uint n_robot_joints);
~Task();
/**
* @brief Reset task variables to initial values
*/
void reset();
/**
* @brief Update Task matrices and vectors
*/
virtual void update(RobotModelPtr robot_model) = 0;
/**
* @brief Check if the task is in timeout and set the timeout flag accordingly. A task is in timeout if
* - No reference value has been set yet
* - A timeout value is configured (config.timeout > 0) and no reference value arrived during the timeout period
*/
void checkTimeout();
/**
* @brief Set task weights.
* @param weights Weight vector. Size has to be same as number of task variables and all entries have to be >= 0
*/
void setWeights(const base::VectorXd& weights);
/**
* @brief Set task activation.
* @param activation Value has to be between 0 and 1. Can be used to activate(1)/deactivate(0) the task.
*/
void setActivation(const double activation);
/** Last time the task reference values was updated.*/
base::Time time;
/** Configuration of this task. See TaskConfig.hpp for more details*/
TaskConfig config;
/** Reference input for this task. Can be either joint or a Cartesian space variables. If the latter is the case
* they have to be expressed in in ref_frame coordinates! See TaskConfig.hpp for more details.*/
base::VectorXd y_ref;
/** Reference value for this task. Can be either joint or a Cartesian space variables. In the former case, y_ref_root will be
* equal to y_ref, in the latter case, y_ref_root will be y_ref transformed into the robot root/base frame.*/
base::VectorXd y_ref_root;
/** Task weights. Size has to be same as number of task variables and all entries have to be >= 0.
* A zero entry means that the reference of the corresponding task variable will be ignored while computing the solution, for example
* when controlling the Cartesian pose, the last 3 entries can be set to zero in order to ignore the orientarion and only control the position*/
base::VectorXd weights;
/** Task weights. In case of joint tasks, weights_root will be equal to weights. In case of Cartesian tasks, weights_root will be equal to
* weights, transformed into the robot's base/root frame*/
base::VectorXd weights_root;
/** Task activation. Has to be between 0 and 1. Will be multiplied with the task weights. Can be used to (smoothly) switch on/off the tasks */
double activation;
/** Can be 0 or 1. Will be multiplied with the task weights. If no new reference values arrives for more than
* config.timeout time, this value will be set to zero*/
int timeout;
/** Task matrix */
base::MatrixXd A;
/** Weighted task matrix */
base::MatrixXd Aw;
};
using TaskPtr = std::shared_ptr<Task> ;
} // namespace wbc
#endif