-
Notifications
You must be signed in to change notification settings - Fork 1
/
OpenSotTask.h
129 lines (78 loc) · 3.07 KB
/
OpenSotTask.h
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef OPENSOTTASKADAPTER_H
#define OPENSOTTASKADAPTER_H
#include "OpenSotUtils.h"
#include <cartesian_interface/sdk/problem/Task.h>
#include <cartesian_interface/problem/Constraint.h>
#include <cartesian_interface/CartesianInterface.h>
#include <cartesian_interface/Context.h>
#include <cartesian_interface/sdk/opensot/Plugin.h>
#include <OpenSoT/tasks/Aggregated.h>
#include <OpenSoT/constraints/Aggregated.h>
#include <OpenSoT/utils/Affine.h>
using TaskPtr = OpenSoT::tasks::Aggregated::TaskPtr;
using ConstraintPtr = OpenSoT::constraints::Aggregated::ConstraintPtr;
namespace XBot { namespace Cartesian {
class OpenSotTaskAdapter :
public virtual TaskObserver
{
public:
typedef std::shared_ptr<OpenSotTaskAdapter> Ptr;
OpenSotTaskAdapter(TaskDescription::Ptr task,
Context::ConstPtr context);
virtual OpenSoT::OptvarHelper::VariableVector getRequiredVariables() const;
virtual bool initialize(const OpenSoT::OptvarHelper& vars);
virtual TaskPtr constructTask() = 0;
virtual void update(double time, double period);
virtual void processSolution(const Eigen::VectorXd& solution);
TaskPtr getOpenSotTask();
TaskDescriptionImpl::Ptr getTaskDescription() const;
virtual bool onWeightChanged() override;
virtual bool onActivationStateChanged() override;
virtual ~OpenSotTaskAdapter() override = default;
static Ptr MakeInstance(TaskDescription::Ptr task,
Context::ConstPtr context);
protected:
virtual const Eigen::MatrixXd& getOpenSotWeight() const;
static OpenSoT::OptvarHelper DefaultVars();
OpenSoT::OptvarHelper _vars;
ModelInterface::ConstPtr _model;
TaskDescriptionImpl::Ptr _ci_task;
Context::ConstPtr _ctx;
private:
TaskPtr _opensot_task;
TaskPtr _sub_task;
Eigen::VectorXd _task_err;
};
class OpenSotConstraintAdapter :
public TaskObserver
{
public:
typedef std::shared_ptr<OpenSotConstraintAdapter> Ptr;
OpenSotConstraintAdapter(ConstraintDescription::Ptr constr,
Context::ConstPtr context);
virtual OpenSoT::OptvarHelper::VariableVector getRequiredVariables() const;
virtual bool initialize(const OpenSoT::OptvarHelper& vars);
virtual ConstraintPtr constructConstraint() = 0;
virtual void update(double time, double period);
virtual void processSolution(const Eigen::VectorXd& solution);
ConstraintPtr getOpenSotConstraint();
ConstraintDescription::Ptr getConstraintDescription() const;
virtual ~OpenSotConstraintAdapter() override = default;
static Ptr MakeInstance(ConstraintDescription::Ptr constr,
Context::ConstPtr context);
protected:
static OpenSoT::OptvarHelper DefaultVars();
ModelInterface::ConstPtr _model;
OpenSoT::OptvarHelper _vars;
ConstraintDescription::Ptr _ci_constr;
Context::ConstPtr _ctx;
private:
ConstraintPtr _opensot_constr;
ConstraintPtr _sub_constr;
};
struct BadVariables : std::runtime_error
{
using runtime_error::runtime_error;
};
} }
#endif // OPENSOTTASKADAPTER_H