joint-limitator.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 #include <sot/core/debug.hh>
12 #include <sot/core/factory.hh>
14 
15 using namespace std;
16 using namespace dynamicgraph::sot;
17 using namespace dynamicgraph;
19 
21 
22 JointLimitator::JointLimitator(const string &fName)
23  : Entity(fName),
24  jointSIN(NULL, "JointLimitator(" + name + ")::input(vector)::joint"),
25  upperJlSIN(NULL, "JointLimitator(" + name + ")::input(vector)::upperJl"),
26  lowerJlSIN(NULL, "JointLimitator(" + name + ")::input(vector)::lowerJl"),
27  controlSIN(NULL,
28  "JointLimitator(" + name + ")::input(vector)::controlIN"),
29  controlSOUT(boost::bind(&JointLimitator::computeControl, this, _1, _2),
30  jointSIN << upperJlSIN << lowerJlSIN << controlSIN,
31  "JointLimitator(" + name + ")::output(vector)::control"),
32  widthJlSINTERN(boost::bind(&JointLimitator::computeWidthJl, this, _1, _2),
33  upperJlSIN << lowerJlSIN,
34  "JointLimitator(" + name + ")::input(vector)::widthJl")
35 
36 {
39 }
40 
42  const sigtime_t &time) {
43  sotDEBUGIN(15);
44 
45  const dynamicgraph::Vector UJL = upperJlSIN.access(time);
46  const dynamicgraph::Vector LJL = lowerJlSIN.access(time);
47  const dynamicgraph::Vector::Index SIZE = UJL.size();
48  res.resize(SIZE);
49 
50  for (size_type i = 0; i < SIZE; ++i) {
51  res(i) = UJL(i) - LJL(i);
52  }
53 
54  sotDEBUGOUT(15);
55  return res;
56 }
57 
59  sigtime_t time) {
60  sotDEBUGIN(15);
61 
62  const dynamicgraph::Vector &q = jointSIN.access(time);
63  const dynamicgraph::Vector &UJL = upperJlSIN.access(time);
64  const dynamicgraph::Vector &LJL = lowerJlSIN.access(time);
65  const dynamicgraph::Vector &uIN = controlSIN.access(time);
66 
67  dynamicgraph::Vector::Index controlSize = uIN.size();
68  uOUT.resize(controlSize);
69  uOUT.setZero();
70 
71  dynamicgraph::Vector::Index offset = q.size() - uIN.size();
72  assert(offset >= 0);
73 
74  for (size_type i = 0; i < controlSize; ++i) {
75  double qnext = q(i + offset) + uIN(i) * 0.005;
76  if ((i + offset < 6) || // do not take into account of freeflyer
77  ((qnext < UJL(i + offset)) && (qnext > LJL(i + offset)))) {
78  uOUT(i) = uIN(i);
79  }
80  sotDEBUG(25) << i << ": " << qnext << " in? [" << LJL(i) << "," << UJL(i)
81  << "]" << endl;
82  }
83 
84  sotDEBUGOUT(15);
85  return uOUT;
86 }
87 
88 void JointLimitator::display(std::ostream &os) const {
89  os << "JointLimitator <" << name << "> ... TODO";
90 }
dynamicgraph::sot::JointLimitator
Filter control vector to avoid exceeding joint maximum values.
Definition: joint-limitator.hh:38
factory.hh
dynamicgraph
dynamicgraph::sot::JointLimitator::upperJlSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > upperJlSIN
Definition: joint-limitator.hh:55
i
int i
dynamicgraph::Entity
dynamicgraph::sot::JointLimitator::jointSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > jointSIN
Definition: joint-limitator.hh:54
boost
dynamicgraph::sot::JointLimitator::widthJlSINTERN
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, sigtime_t > widthJlSINTERN
Definition: joint-limitator.hh:61
dynamicgraph::Entity::name
std::string name
dynamicgraph::sot::JointLimitator::computeWidthJl
dynamicgraph::Vector & computeWidthJl(dynamicgraph::Vector &res, const sigtime_t &time)
Definition: joint-limitator.cpp:41
size_type
dynamicgraph::size_type size_type
Definition: joint-limitator.cpp:18
dynamicgraph::sot::JointLimitator::lowerJlSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > lowerJlSIN
Definition: joint-limitator.hh:56
debug.hh
dynamicgraph::sot::JointLimitator::computeControl
virtual dynamicgraph::Vector & computeControl(dynamicgraph::Vector &res, sigtime_t time)
Definition: joint-limitator.cpp:58
dynamicgraph::sot::JointLimitator::display
virtual void display(std::ostream &os) const
Definition: joint-limitator.cpp:88
res
res
dynamicgraph::SignalPtr::access
virtual const T & access(const Time &t)
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition: debug.hh:215
dynamicgraph::sigtime_t
int64_t sigtime_t
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(JointLimitator, "JointLimitator")
sotDEBUGIN
#define sotDEBUGIN(level)
Definition: debug.hh:214
Index
std::size_t Index
joint-limitator.hh
q
q
dynamicgraph::size_type
Matrix::Index size_type
dynamicgraph::Vector
Eigen::VectorXd Vector
exception-feature.hh
dynamicgraph::sot
dynamicgraph::sot::JointLimitator::controlSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > controlSIN
Definition: joint-limitator.hh:57
dynamicgraph::sot::JointLimitator::controlSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, sigtime_t > controlSOUT
Definition: joint-limitator.hh:59
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
compile.name
name
Definition: compile.py:23
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