sot-command.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * Florent Lamiraux
4  *
5  * CNRS
6  *
7  */
8 
9 #ifndef SOT_COMMAND_H
10 #define SOT_COMMAND_H
11 
14 #include <dynamic-graph/command.h>
15 
16 #include <boost/assign/list_of.hpp>
17 
18 namespace dynamicgraph {
19 namespace sot {
20 namespace command {
21 namespace classSot {
22 using ::dynamicgraph::command::Command;
23 using ::dynamicgraph::command::Value;
24 
25 // Command Push
26 class Push : public Command {
27  public:
28  virtual ~Push() {}
32  Push(Sot &entity, const std::string &docstring)
33  : Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
34  virtual Value doExecute() {
35  Sot &sot = static_cast<Sot &>(owner());
36  std::vector<Value> values = getParameterValues();
37  std::string taskName = values[0].value();
38 
39  TaskAbstract &task = PoolStorage::getInstance()->getTask(taskName);
40  sot.push(task);
41  // return void
42  return Value();
43  }
44 }; // class Push
45 
46 // Command Remove
47 class Remove : public Command {
48  public:
49  virtual ~Remove() {}
53  Remove(Sot &entity, const std::string &docstring)
54  : Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
55  virtual Value doExecute() {
56  Sot &sot = static_cast<Sot &>(owner());
57  std::vector<Value> values = getParameterValues();
58  std::string taskName = values[0].value();
59 
60  TaskAbstract &task = PoolStorage::getInstance()->getTask(taskName);
61  sot.remove(task);
62  // return void
63  return Value();
64  }
65 }; // class Remove
66 
67 // Command Up
68 class Up : public Command {
69  public:
70  virtual ~Up() {}
74  Up(Sot &entity, const std::string &docstring)
75  : Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
76  virtual Value doExecute() {
77  Sot &sot = static_cast<Sot &>(owner());
78  std::vector<Value> values = getParameterValues();
79  std::string taskName = values[0].value();
80 
81  TaskAbstract &task = PoolStorage::getInstance()->getTask(taskName);
82  sot.up(task);
83  // return void
84  return Value();
85  }
86 }; // class Remove
87 
88 // Command Down
89 class Down : public Command {
90  public:
91  virtual ~Down() {}
95  Down(Sot &entity, const std::string &docstring)
96  : Command(entity, boost::assign::list_of(Value::STRING), docstring) {}
97  virtual Value doExecute() {
98  Sot &sot = static_cast<Sot &>(owner());
99  std::vector<Value> values = getParameterValues();
100  std::string taskName = values[0].value();
101 
102  TaskAbstract &task = PoolStorage::getInstance()->getTask(taskName);
103  sot.down(task);
104  // return void
105  return Value();
106  }
107 }; // class Down
108 
109 // Command Display
110 class Display : public Command {
111  public:
112  virtual ~Display() {}
116  Display(Sot &entity, const std::string &docstring)
117  : Command(entity, std::vector<Value::Type>(), docstring) {}
118  virtual Value doExecute() {
119  std::stringstream returnString;
120  Sot &sot = static_cast<Sot &>(owner());
121  sot.display(returnString);
122 
123  // return the stack
124  return Value(returnString.str());
125  }
126 }; // class Display
127 
128 // Command List
129 class List : public Command {
130  public:
131  virtual ~List() {}
135  List(Sot &entity, const std::string &docstring)
136  : Command(entity, std::vector<Value::Type>(), docstring) {}
137  virtual Value doExecute() {
138  Sot &sot = static_cast<Sot &>(owner());
139  typedef Sot::StackType StackType;
140  const StackType &stack = sot.tasks();
141 
142  std::stringstream returnString;
143  returnString << "( ";
144  for (StackType::const_iterator it = stack.begin(); it != stack.end();
145  ++it) {
146  returnString << '"' << (*it)->getName() << "\", ";
147  }
148  returnString << ")";
149 
150  // return the stack
151  return Value(returnString.str());
152  }
153 }; // class List
154 
155 // Command Clear
156 class Clear : public Command {
157  public:
158  virtual ~Clear() {}
161  Clear(Sot &entity, const std::string &docstring)
162  : Command(entity, std::vector<Value::Type>(), docstring) {}
163  virtual Value doExecute() {
164  std::stringstream returnString;
165  Sot &sot = static_cast<Sot &>(owner());
166  sot.clear();
167  // return the stack
168  return Value();
169  }
170 }; // class Clear
171 
172 } // namespace classSot
173 } // namespace command
174 } /* namespace sot */
175 } /* namespace dynamicgraph */
176 
177 #endif // SOT_COMMAND_H
virtual void down(const TaskAbstract &task)
This method makes the task to swap with the task having the immediate inferior priority.
Definition: sot.cpp:282
Up(Sot &entity, const std::string &docstring)
Definition: sot-command.h:74
Remove(Sot &entity, const std::string &docstring)
Definition: sot-command.h:53
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...
Definition: sot.cpp:210
Display(Sot &entity, const std::string &docstring)
Definition: sot-command.h:116
Push(Sot &entity, const std::string &docstring)
Definition: sot-command.h:32
Eigen::Block< Mat > Type
std::list< TaskAbstract * > StackType
Defines a type for a list of tasks.
Definition: sot.hh:67
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...
Definition: sot.cpp:236
List(Sot &entity, const std::string &docstring)
Definition: sot-command.h:135
static PoolStorage * getInstance()
Definition: pool.cpp:147
list values
virtual void display(std::ostream &os) const
Definition: sot.cpp:648
Clear(Sot &entity, const std::string &docstring)
Definition: sot-command.h:161
virtual const StackType & tasks() const
Definition: sot.hh:110
This class implements the Stack of Task. It allows to deal with the priority of the controllers throu...
Definition: sot.hh:57
const std::vector< Value > & getParameterValues() const
virtual void up(const TaskAbstract &task)
This method makes the task to swap with the task having the immediate superior priority.
Definition: sot.cpp:259
virtual void clear(void)
Remove all the tasks from the stack.
Definition: sot.cpp:311
Down(Sot &entity, const std::string &docstring)
Definition: sot-command.h:95


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26