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  sigtime_t 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  sigtime_t time) {
72  sotDEBUG(15) << "# In {" << endl;
73 
74  const dynamicgraph::Vector &errorDot = errorDotSIN(time);
76 
77  sotDEBUG(25) << " Task = " << task;
78  sotDEBUG(25) << " edot = " << errorDot;
79 
80  for (std::size_t i = 0; i < task.size(); ++i) {
81  task[i] = task[i].getSingleBound() - (beta * errorDot(i));
82  }
83 
84  sotDEBUG(15) << "# Out }" << endl;
85  return task;
86 }
87 
88 /* --- PARAMS --------------------------------------------------------------- */
89 /* --- PARAMS --------------------------------------------------------------- */
90 /* --- PARAMS --------------------------------------------------------------- */
91 #include <sot/core/pool.hh>
92 
93 void TaskPD::initCommand(void) {
94  using namespace command;
95  addCommand("setBeta",
96  makeDirectSetter(*this, &beta, docDirectSetter("beta", "double")));
97 }
dynamicgraph::sot::TaskPD::errorDotSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, sigtime_t > errorDotSOUT
Definition: task-pd.hh:60
dynamicgraph::sot::TaskPD::beta
double beta
Definition: task-pd.hh:47
factory.hh
task-pd.hh
dynamicgraph::sot::Task::computeTaskExponentialDecrease
VectorMultiBound & computeTaskExponentialDecrease(VectorMultiBound &errorRef, sigtime_t time)
Definition: task.cpp:233
dynamicgraph
dynamicgraph::sot::VectorMultiBound
std::vector< MultiBound > VectorMultiBound
Definition: multi-bound.hh:72
i
int i
dynamicgraph::SignalPtr::plug
virtual void plug(SignalBase< Time > *ref)
boost
dynamicgraph::sot::TaskPD::computeTaskModif
VectorMultiBound & computeTaskModif(VectorMultiBound &error, sigtime_t time)
Definition: task-pd.cpp:70
debug.hh
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::SignalTimeDependent::addDependency
virtual void addDependency(const SignalBase< Time > &signal)
dynamicgraph::sot::TaskPD::errorDotSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > errorDotSIN
Definition: task-pd.hh:61
docDirectSetter
std::string docDirectSetter(const std::string &name, const std::string &type)
dynamicgraph::Vector
Eigen::VectorXd Vector
dynamicgraph::sot::Task::errorSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, sigtime_t > errorSOUT
Definition: task.hh:113
dynamicgraph::sot::TaskPD::computeErrorDot
dynamicgraph::Vector & computeErrorDot(dynamicgraph::Vector &error, sigtime_t time)
Definition: task-pd.cpp:52
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(TaskPD, "TaskPD")
pool.hh
dynamicgraph::sot::TaskPD::initCommand
void initCommand(void)
Definition: task-pd.cpp:93
dynamicgraph::sot::TaskAbstract::taskSOUT
dynamicgraph::SignalTimeDependent< VectorMultiBound, sigtime_t > taskSOUT
Definition: task-abstract.hh:78
dynamicgraph::sot::Task
Class that defines the basic elements of a task.
Definition: task.hh:72
dynamicgraph::sot
makeDirectSetter
DirectSetter< E, T > * makeDirectSetter(E &entity, T *ptr, const std::string &docString)
dynamicgraph::Entity::addCommand
void addCommand(const std::string &name, command::Command *command)
all-commands.h
dynamicgraph::sot::TaskPD
Definition: task-pd.hh:41
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
n
Vec3f n
dynamicgraph::sot::TaskPD::previousError
dynamicgraph::Vector previousError
Definition: task-pd.hh:46
sotDEBUG
#define sotDEBUG(level)
Definition: debug.hh:168


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31