task-pd.cpp
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 /* --------------------------------------------------------------------- */
11 /* --- INCLUDE --------------------------------------------------------- */
12 /* --------------------------------------------------------------------- */
13 
14 /* SOT */
16 
17 #include <sot/core/debug.hh>
18 #include <sot/core/task-pd.hh>
19 
20 using namespace std;
21 using namespace dynamicgraph::sot;
22 using namespace dynamicgraph;
23 
24 #include <sot/core/factory.hh>
25 
27 
28 /* --------------------------------------------------------------------- */
29 /* --- CLASS ----------------------------------------------------------- */
30 /* --------------------------------------------------------------------- */
31 
32 TaskPD::TaskPD(const std::string &n)
33  : Task(n),
34  previousError(),
35  beta(1),
36  errorDotSOUT(boost::bind(&TaskPD::computeErrorDot, this, _1, _2),
37  errorSOUT,
38  "sotTaskPD(" + n + ")::output(vector)::errorDotOUT"),
39  errorDotSIN(NULL, "sotTaskPD(" + n + ")::input(vector)::errorDot") {
40  taskSOUT.setFunction(boost::bind(&TaskPD::computeTaskModif, this, _1, _2));
42 
44  initCommand();
46 }
47 
48 /* --- COMPUTATION ---------------------------------------------------------- */
49 /* --- COMPUTATION ---------------------------------------------------------- */
50 /* --- COMPUTATION ---------------------------------------------------------- */
51 
53  int time) {
54  sotDEBUG(15) << "# In {" << endl;
55 
56  const dynamicgraph::Vector &errCur = errorSOUT(time);
57  if (previousError.size() == errCur.size()) {
58  errorDot = errCur;
59  errorDot -= previousError;
60  previousError = errCur;
61  } else {
62  errorDot.resize(errCur.size());
63  errorDot.setZero();
64  previousError = errCur;
65  }
66  sotDEBUG(15) << "# Out }" << endl;
67  return errorDot;
68 }
69 
71  sotDEBUG(15) << "# In {" << endl;
72 
73  const dynamicgraph::Vector &errorDot = errorDotSIN(time);
75 
76  sotDEBUG(25) << " Task = " << task;
77  sotDEBUG(25) << " edot = " << errorDot;
78 
79  for (unsigned int i = 0; i < task.size(); ++i) {
80  task[i] = task[i].getSingleBound() - (beta * errorDot(i));
81  }
82 
83  sotDEBUG(15) << "# Out }" << endl;
84  return task;
85 }
86 
87 /* --- PARAMS --------------------------------------------------------------- */
88 /* --- PARAMS --------------------------------------------------------------- */
89 /* --- PARAMS --------------------------------------------------------------- */
90 #include <sot/core/pool.hh>
91 
92 void TaskPD::initCommand(void) {
93  using namespace command;
94  addCommand("setBeta",
95  makeDirectSetter(*this, &beta, docDirectSetter("beta", "double")));
96 }
Eigen::VectorXd Vector
Vec3f n
int i
void signalRegistration(const SignalArray< int > &signals)
dynamicgraph::SignalTimeDependent< VectorMultiBound, int > taskSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, int > errorDotSOUT
Definition: task-pd.hh:58
std::vector< MultiBound > VectorMultiBound
Definition: multi-bound.hh:71
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(TaskPD, "TaskPD")
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, int > errorSOUT
Definition: task.hh:111
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > errorDotSIN
Definition: task-pd.hh:59
VectorMultiBound & computeTaskModif(VectorMultiBound &error, int time)
Definition: task-pd.cpp:70
VectorMultiBound & computeTaskExponentialDecrease(VectorMultiBound &errorRef, int time)
Definition: task.cpp:232
virtual void plug(SignalBase< Time > *ref)
virtual void addDependency(const SignalBase< Time > &signal)
#define sotDEBUG(level)
Definition: debug.hh:165
dynamicgraph::Vector & computeErrorDot(dynamicgraph::Vector &error, int time)
Definition: task-pd.cpp:52
Class that defines the basic elements of a task.
Definition: task.hh:72
void addCommand(const std::string &name, command::Command *command)
std::string docDirectSetter(const std::string &name, const std::string &type)
virtual void setFunction(boost::function2< T &, T &, Time > t, Mutex *mutexref=NULL)
DirectSetter< E, T > * makeDirectSetter(E &entity, T *ptr, const std::string &docString)
dynamicgraph::Vector previousError
Definition: task-pd.hh:46


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