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 (ExceptionSignal e) {
73  }
74  os << " (" << TimeStep << ") ";
75 }
76 
77 /* --------------------------------------------------------------------- */
78 /* --------------------------------------------------------------------- */
79 /* --------------------------------------------------------------------- */
80 
81 double &ControlGR::setsize(int dimension)
82 
83 {
84  _dimension = dimension;
85  return _dimension;
86 }
87 
89  int 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::Vector & computeControl(dynamicgraph::Vector &tau, int t)
Definition: control-gr.cpp:88
Eigen::VectorXd Vector
gravity
void signalRegistration(const SignalArray< int > &signals)
#define sotDEBUGOUT(level)
Definition: debug.hh:212
static void openFile(const char *filename=DEBUG_FILENAME_DEFAULT)
#define sotDEBUGIN(level)
Definition: debug.hh:211
ControlGR__INIT ControlGR_initiator
Definition: control-gr.cpp:17
SignalPtr< dynamicgraph::Vector, int > gravitySIN
Definition: control-gr.hh:71
SignalPtr< dynamicgraph::Vector, int > accelerationSIN
Definition: control-gr.hh:70
ControlGR__INIT(void)
Definition: control-gr.cpp:15
double & setsize(int dimension)
Definition: control-gr.cpp:81
SignalPtr< dynamicgraph::Matrix, int > matrixASIN
Definition: control-gr.hh:69
#define sotDEBUG(level)
Definition: debug.hh:165
virtual void display(std::ostream &os) const
Definition: control-gr.cpp:68
FCL_REAL size() const
const std::string & getName() const
Eigen::MatrixXd Matrix
SignalTimeDependent< dynamicgraph::Vector, int > controlSOUT
Definition: control-gr.hh:72
Transform3f t
std::size_t Index
void init(const double &step)
Definition: control-gr.cpp:58
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(ControlGR, "ControlGR")


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