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


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