control-gr.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 /* SOT */
11 
12 #include <sot/core/debug.hh>
14  public:
16 };
18 /* --------------------------------------------------------------------- */
19 /* --------------------------------------------------------------------- */
20 /* --------------------------------------------------------------------- */
21 #include <dynamic-graph/factory.h>
22 
23 #include <sot/core/binary-op.hh>
24 #include <sot/core/control-gr.hh>
25 
26 using namespace dynamicgraph;
27 using namespace dynamicgraph::sot;
28 
30 
31 const double ControlGR::TIME_STEP_DEFAULT = .001;
32 
33 /* --------------------------------------------------------------------- */
34 /* --------------------------------------------------------------------- */
35 /* --------------------------------------------------------------------- */
36 
37 #define __SOT_ControlGR_INIT
38 
39 ControlGR::ControlGR(const std::string &name)
40  : Entity(name),
41  TimeStep(0),
42  matrixASIN(NULL, "ControlGR(" + name + ")::input(matrix)::matrixA"),
43  accelerationSIN(NULL,
44  "ControlGR(" + name + ")::input(vector)::acceleration"),
45  gravitySIN(NULL, "ControlGR(" + name + ")::input(vector)::gravity"),
46  controlSOUT(boost::bind(&ControlGR::computeControl, this, _1, _2),
47  matrixASIN << accelerationSIN << gravitySIN,
48  "ControlGR(" + name + ")::output(vector)::control") {
49  init(TimeStep);
51  << controlSOUT);
52 }
53 
54 /* --------------------------------------------------------------------- */
55 /* --------------------------------------------------------------------- */
56 /* --------------------------------------------------------------------- */
57 
58 void ControlGR::init(const double &Stept) {
59  TimeStep = Stept;
60 
61  return;
62 }
63 
64 /* --------------------------------------------------------------------- */
65 /* --------------------------------------------------------------------- */
66 /* --------------------------------------------------------------------- */
67 
68 void ControlGR::display(std::ostream &os) const {
69  os << "ControlGR " << getName();
70  try {
71  os << "control = " << controlSOUT;
72  } catch (const ExceptionSignal &e) {
73  }
74  os << " (" << TimeStep << ") ";
75 }
76 
77 /* --------------------------------------------------------------------- */
78 /* --------------------------------------------------------------------- */
79 /* --------------------------------------------------------------------- */
80 
81 double &ControlGR::setsize(size_type dimension)
82 
83 {
84  _dimension = (double)dimension;
85  return _dimension;
86 }
87 
89  sigtime_t t) {
90  sotDEBUGIN(15);
91 
92  const dynamicgraph::Matrix &matrixA = matrixASIN(t);
93  const dynamicgraph::Vector &acceleration = accelerationSIN(t);
95  dynamicgraph::Vector::Index size = acceleration.size();
96  tau.resize(size);
97  // tau*=0;
98  /* for(unsigned i = 0u; i < size; ++i)
99  {
100  tp = gravity(i);
101  tau(i) = acceleration;
102  tau(i) *= matrixA;
103  tau(i) += tp;
104  }*/
105 
106  tau = matrixA * acceleration;
107  sotDEBUG(15) << "torque = A*ddot(q)= " << matrixA * acceleration << std::endl;
108  tau += gravity;
109 
110  /*
111  tau(1) *= 0;
112  tau(7) *= 0;
113  tau(24) *=0;
114  tau(17)=0;*/
115 
116  sotDEBUG(15) << "matrixA =" << matrixA << std::endl;
117  sotDEBUG(15) << "acceleration =" << acceleration << std::endl;
118  sotDEBUG(15) << "gravity =" << gravity << std::endl;
119  sotDEBUG(15) << "gravity compensation torque =" << tau << std::endl;
120  sotDEBUGOUT(15);
121 
122  return tau;
123 }
dynamicgraph::sot::ControlGR::accelerationSIN
SignalPtr< dynamicgraph::Vector, sigtime_t > accelerationSIN
Definition: control-gr.hh:70
dynamicgraph::sot::ControlGR::init
void init(const double &step)
Definition: control-gr.cpp:58
dynamicgraph::sot::ControlGR::_dimension
double _dimension
Definition: control-gr.hh:66
binary-op.hh
dynamicgraph
ControlGR_initiator
ControlGR__INIT ControlGR_initiator
Definition: control-gr.cpp:17
dynamicgraph::sot::ControlGR
Definition: control-gr.hh:46
dynamicgraph::sot::ControlGR::matrixASIN
SignalPtr< dynamicgraph::Matrix, sigtime_t > matrixASIN
Definition: control-gr.hh:69
dynamicgraph::sot::ControlGR::TimeStep
double TimeStep
Definition: control-gr.hh:65
dynamicgraph::Entity
boost
dynamicgraph::sot::ControlGR::gravitySIN
SignalPtr< dynamicgraph::Vector, sigtime_t > gravitySIN
Definition: control-gr.hh:71
dynamicgraph::sot::ControlGR::computeControl
dynamicgraph::Vector & computeControl(dynamicgraph::Vector &tau, sigtime_t t)
Definition: control-gr.cpp:88
dynamicgraph::Matrix
Eigen::MatrixXd Matrix
dynamicgraph::sot::ControlGR::setsize
double & setsize(size_type dimension)
Definition: control-gr.cpp:81
dynamicgraph::sot::DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
dynamicgraph::Entity::getName
const std::string & getName() const
ControlGR__INIT
Definition: control-gr.cpp:13
ControlGR__INIT::ControlGR__INIT
ControlGR__INIT(void)
Definition: control-gr.cpp:15
debug.hh
tau
tau
dynamicgraph::sot::ControlGR::display
virtual void display(std::ostream &os) const
Definition: control-gr.cpp:68
sotDEBUGOUT
#define sotDEBUGOUT(level)
Definition: debug.hh:215
dynamicgraph::sigtime_t
int64_t sigtime_t
sotDEBUGIN
#define sotDEBUGIN(level)
Definition: debug.hh:214
size
FCL_REAL size() const
Index
std::size_t Index
dynamicgraph::sot::ControlGR::TIME_STEP_DEFAULT
static const double TIME_STEP_DEFAULT
Definition: control-gr.hh:55
dynamicgraph::size_type
Matrix::Index size_type
dynamicgraph::Vector
Eigen::VectorXd Vector
dynamicgraph::sot::ControlGR::ControlGR
ControlGR(const std::string &name)
Definition: control-gr.cpp:39
dynamicgraph::ExceptionSignal
dynamicgraph::sot::double
double
Definition: fir-filter.cpp:49
dynamicgraph::sot::ControlGR::controlSOUT
SignalTimeDependent< dynamicgraph::Vector, sigtime_t > controlSOUT
Definition: control-gr.hh:72
dynamicgraph::sot
control-gr.hh
t
Transform3f t
dynamicgraph::DebugTrace::openFile
static void openFile(const char *filename=DEBUG_FILENAME_DEFAULT)
gravity
gravity
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