sot-core  4.11.8
Hierarchical task solver plug-in for dynamic-graph.
sot.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 #ifndef __SOT_SOT_HH
11 #define __SOT_SOT_HH
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
18 #include <dynamic-graph/linear-algebra.h>
19 
20 /* Classes standards. */
21 #include <list> /* Classe std::list */
22 
23 /* SOT */
24 #include <dynamic-graph/entity.h>
25 
26 #include <sot/core/flags.hh>
28 
29 /* --------------------------------------------------------------------- */
30 /* --- API ------------------------------------------------------------- */
31 /* --------------------------------------------------------------------- */
32 
33 #ifndef SOTSOT_CORE_EXPORT
34 #if defined(WIN32)
35 #if defined(sot_EXPORTS)
36 #define SOTSOT_CORE_EXPORT __declspec(dllexport)
37 #else
38 #define SOTSOT_CORE_EXPORT __declspec(dllimport)
39 #endif
40 #else
41 #define SOTSOT_CORE_EXPORT
42 #endif
43 #endif
44 
45 /* --------------------------------------------------------------------- */
46 /* --- CLASS ----------------------------------------------------------- */
47 /* --------------------------------------------------------------------- */
48 
49 namespace dynamicgraph {
50 namespace sot {
51 
57 class SOTSOT_CORE_EXPORT Sot : public Entity {
58  public:
60  static const std::string CLASS_NAME;
61 
62  public:
64  virtual const std::string &getClassName() const { return CLASS_NAME; }
65 
67  typedef std::list<TaskAbstract *> StackType;
68 
69  protected:
73 
76  unsigned int nbJoints;
77 
81 
89 
90  public:
92  static const double INVERSION_THRESHOLD_DEFAULT; // = 1e-4;
93 
94  /* static const double DIRECTIONAL_THRESHOLD_DEFAULT = 1e-2; */
95  /* static const bool USE_CONTI_INVERSE_DEFAULT = false; */
96 
98  static void taskVectorToMlVector(const VectorMultiBound &taskVector,
99  Vector &err);
100 
101  public:
103  Sot(const std::string &name);
104  ~Sot(void) { /* TODO!! */
105  }
106 
110  virtual const StackType &tasks() const { return stack; }
111 
116  virtual void push(TaskAbstract &task);
121  virtual TaskAbstract &pop(void);
122 
124  virtual bool exist(const TaskAbstract &task);
125 
129  virtual void remove(const TaskAbstract &task);
130 
133  virtual void removeDependency(const TaskAbstract &key);
134 
137  virtual void up(const TaskAbstract &task);
138 
141  virtual void down(const TaskAbstract &task);
142 
144  virtual void clear(void);
151  virtual void defineNbDof(const unsigned int &nbDof);
152  virtual const unsigned int &getNbDof() const { return nbJoints; }
153 
155  public: /* --- CONTROL --- */
162  virtual dynamicgraph::Vector &computeControlLaw(dynamicgraph::Vector &control,
163  const int &time);
164 
167  public: /* --- DISPLAY --- */
172  virtual void display(std::ostream &os) const;
174  SOTSOT_CORE_EXPORT friend std::ostream &operator<<(std::ostream &os,
175  const Sot &sot);
177  public: /* --- SIGNALS --- */
185  SignalPtr<dynamicgraph::Vector, int> q0SIN;
191  SignalPtr<dynamicgraph::Matrix, int> proj0SIN;
194  SignalPtr<double, int> inversionThresholdSIN;
196  SignalTimeDependent<dynamicgraph::Vector, int> controlSOUT;
201  virtual std::ostream &writeGraph(std::ostream &os) const;
202 };
203 } // namespace sot
204 } // namespace dynamicgraph
205 
206 #endif /* #ifndef __SOT_SOT_HH */
This class implements the Stack of Task. It allows to deal with the priority of the controllers throu...
Definition: sot.hh:57
SignalPtr< double, int > inversionThresholdSIN
This signal allow to change the threshold for the damped pseudo-inverse on-line.
Definition: sot.hh:194
virtual void push(TaskAbstract &task)
Push the task in the stack. It has a lowest priority than the previous ones. If this is the first tas...
virtual void remove(const TaskAbstract &task)
Remove a task regardless to its position in the stack. It removes also the signals connected to the o...
unsigned int nbJoints
Store the number of joints to be used in the command computed by the stack of tasks.
Definition: sot.hh:76
double maxControlIncrementSquaredNorm
Maximum allowed squared norm of control increment. A task whose control increment is above this value...
Definition: sot.hh:88
virtual void removeDependency(const TaskAbstract &key)
This method removes the output signals depending on this task.
virtual const unsigned int & getNbDof() const
Definition: sot.hh:152
SignalPtr< dynamicgraph::Matrix, int > proj0SIN
A matrix K whose columns are a base of the desired velocity. In other words, where is the free para...
Definition: sot.hh:191
SOTSOT_CORE_EXPORT friend std::ostream & operator<<(std::ostream &os, const Sot &sot)
static void taskVectorToMlVector(const VectorMultiBound &taskVector, Vector &err)
Number of joints by default.
virtual void up(const TaskAbstract &task)
This method makes the task to swap with the task having the immediate superior priority.
virtual void defineNbDof(const unsigned int &nbDof)
This method defines the part of the state vector which correspond to the free flyer of the robot.
virtual dynamicgraph::Vector & computeControlLaw(dynamicgraph::Vector &control, const int &time)
Compute the control law.
virtual std::ostream & writeGraph(std::ostream &os) const
This method write the priority between tasks in the output stream os.
bool enablePostureTaskAcceleration
Option to disable the computation of the SVD for the last task if this task is a Task with a single F...
Definition: sot.hh:80
SignalTimeDependent< dynamicgraph::Vector, int > controlSOUT
Allow to get the result of the computed control law.
Definition: sot.hh:196
virtual const StackType & tasks() const
Definition: sot.hh:110
~Sot(void)
Definition: sot.hh:104
virtual void display(std::ostream &os) const
virtual TaskAbstract & pop(void)
Pop the task from the stack. This method removes the task with the smallest priority in the task....
virtual bool exist(const TaskAbstract &task)
This method allows to know if a task exists or not.
virtual void down(const TaskAbstract &task)
This method makes the task to swap with the task having the immediate inferior priority.
std::list< TaskAbstract * > StackType
Defines a type for a list of tasks.
Definition: sot.hh:67
static const std::string CLASS_NAME
Specify the name of the class entity.
Definition: sot.hh:60
static const double INVERSION_THRESHOLD_DEFAULT
Threshold to compute the dumped pseudo inverse.
Definition: sot.hh:92
StackType stack
This field is a list of controllers managed by the stack of tasks.
Definition: sot.hh:72
virtual const std::string & getClassName() const
Returns the name of this class.
Definition: sot.hh:64
virtual void clear(void)
Remove all the tasks from the stack.
SignalPtr< dynamicgraph::Vector, int > q0SIN
Intrinsec velocity of the robot, that is used to initialized the recurence of the SOT (e....
Definition: sot.hh:185
Sot(const std::string &name)
Default constructor.
Definition: task-abstract.hh:51
std::vector< MultiBound > VectorMultiBound
Definition: multi-bound.hh:71
Definition: abstract-sot-external-interface.hh:17
#define SOTSOT_CORE_EXPORT
Definition: sot.hh:41