ocra-recipes
Doxygen documentation for the ocra-recipes repository
TaskState.h
Go to the documentation of this file.
1 #ifndef TASK_STATE_H
2 #define TASK_STATE_H
3 
4 #include <Eigen/Core>
5 #include <Eigen/Lgsm>
6 #include <ocra/util/Macros.h>
9 #include <yarp/os/Bottle.h>
10 
11 namespace ocra {
12 
13 
14 class TaskState {
16 
17 private:
18  Eigen::Displacementd position;
19  Eigen::Twistd velocity;
20  Eigen::Twistd acceleration;
21 
22  Eigen::VectorXd q;
23  Eigen::VectorXd qd;
24  Eigen::VectorXd qdd;
25  Eigen::VectorXd torque;
26 
27  Eigen::Wrenchd wrench;
28 
29 
30  bool containsPosition;
31  bool containsVelocity;
32  bool containsAcceleration;
33  bool containsQ;
34  bool containsQd;
35  bool containsQdd;
36  bool containsTorque;
37  bool containsWrench;
38 
39  static const int TASK_STATE_BOTTLE = 12345;
40 
41 public:
42  TaskState();
43  virtual ~TaskState();
44 
45  Eigen::Displacementd getPosition() const;
46  Eigen::Twistd getVelocity() const;
47  Eigen::Twistd getAcceleration() const;
48  Eigen::VectorXd getQ() const;
49  Eigen::VectorXd getQd() const;
50  Eigen::VectorXd getQdd() const;
51  Eigen::VectorXd getTorque() const;
52  Eigen::Wrenchd getWrench() const;
53 
54  void setPosition(const Eigen::Displacementd& newPosition);
55  void setVelocity(const Eigen::Twistd& newVelocity);
56  void setAcceleration(const Eigen::Twistd& newAcceleration);
57  void setQ(const Eigen::VectorXd& newQ);
58  void setQd(const Eigen::VectorXd& newQd);
59  void setQdd(const Eigen::VectorXd& newQdd);
60  void setTorque(const Eigen::VectorXd& newTorque);
61  void setWrench(const Eigen::Wrenchd& newWrench);
62 
63  bool hasPosition() const ;
64  bool hasVelocity() const ;
65  bool hasAcceleration() const ;
66  bool hasQ() const ;
67  bool hasQd() const ;
68  bool hasQdd() const ;
69  bool hasTorque() const ;
70  bool hasWrench() const ;
71 
72 
73  bool extractFromBottle(const yarp::os::Bottle& bottle, int& sizeOfOptions);
74  void putIntoBottle(yarp::os::Bottle& bottle) const;
75 
76 
77 
78  friend std::ostream& operator<<(std::ostream &out, const TaskState& state)
79  {
80  if(state.hasPosition())
81  out << "getPosition():\n" << state.getPosition() << std::endl << std::endl;
82 
83  if(state.hasVelocity())
84  out << "getVelocity():\n" << state.getVelocity() << std::endl << std::endl;
85 
86  if(state.hasAcceleration())
87  out << "getAcceleration():\n" << state.getAcceleration() << std::endl << std::endl;
88 
89  if(state.hasQ())
90  out << "getQ():\n" << state.getQ() << std::endl << std::endl;
91 
92  if(state.hasQd())
93  out << "getQd():\n" << state.getQd() << std::endl << std::endl;
94 
95  if(state.hasQdd())
96  out << "getQdd():\n" << state.getQdd() << std::endl << std::endl;
97 
98  if(state.hasTorque())
99  out << "getTorque():\n" << state.getTorque() << std::endl << std::endl;
100 
101  if(state.hasWrench())
102  out << "getWrench():\n" << state.getWrench() << std::endl << std::endl;
103 
104 
105  return out;
106  }
107 
108 };
109 
110 } // namespace ocra
111 #endif // TASK_STATE_H
virtual ~TaskState()
Definition: TaskState.cpp:26
void setPosition(const Eigen::Displacementd &newPosition)
Definition: TaskState.cpp:79
void setTorque(const Eigen::VectorXd &newTorque)
Definition: TaskState.cpp:121
bool hasVelocity() const
Definition: TaskState.cpp:139
void setAcceleration(const Eigen::Twistd &newAcceleration)
Definition: TaskState.cpp:93
bool hasPosition() const
Definition: TaskState.cpp:134
bool hasQ() const
Definition: TaskState.cpp:149
Eigen::VectorXd getQdd() const
Definition: TaskState.cpp:61
void setVelocity(const Eigen::Twistd &newVelocity)
Definition: TaskState.cpp:86
void putIntoBottle(yarp::os::Bottle &bottle) const
Definition: TaskState.cpp:230
bool hasQd() const
Definition: TaskState.cpp:154
bool extractFromBottle(const yarp::os::Bottle &bottle, int &sizeOfOptions)
Definition: TaskState.cpp:174
#define DEFINE_CLASS_POINTER_TYPEDEFS(Class)
Definition: Macros.h:8
Eigen::VectorXd getQd() const
Definition: TaskState.cpp:55
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
bool hasAcceleration() const
Definition: TaskState.cpp:144
Eigen::VectorXd getQ() const
Definition: TaskState.cpp:49
bool hasTorque() const
Definition: TaskState.cpp:164
void setQd(const Eigen::VectorXd &newQd)
Definition: TaskState.cpp:107
Eigen::VectorXd getTorque() const
Definition: TaskState.cpp:67
bool hasWrench() const
Definition: TaskState.cpp:169
void setQdd(const Eigen::VectorXd &newQdd)
Definition: TaskState.cpp:114
Eigen::Wrenchd getWrench() const
Definition: TaskState.cpp:73
bool hasQdd() const
Definition: TaskState.cpp:159
void setWrench(const Eigen::Wrenchd &newWrench)
Definition: TaskState.cpp:128
Eigen::Twistd getAcceleration() const
Definition: TaskState.cpp:43
void setQ(const Eigen::VectorXd &newQ)
Definition: TaskState.cpp:100
Eigen::Displacementd getPosition() const
Definition: TaskState.cpp:31
Eigen::Twistd getVelocity() const
Definition: TaskState.cpp:37
friend std::ostream & operator<<(std::ostream &out, const TaskState &state)
Definition: TaskState.h:78