test_task.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 /* --- INCLUDES ------------------------------------------------------------- */
12 /* -------------------------------------------------------------------------- */
14 
15 #include <iostream>
16 #include <sot/core/debug.hh>
20 #include <sot/core/sot.hh>
21 #include <sot/core/task.hh>
22 using namespace std;
23 using namespace dynamicgraph::sot;
24 
25 double drand(void) { return 2 * ((double)rand()) / RAND_MAX - 1; }
27  for (int i = 0; i < J.rows(); ++i)
28  for (int j = 0; j < J.cols(); ++j) J(i, j) = drand();
29  return J;
30 }
31 
32 int main(void) {
33  srand(12);
34  dynamicgraph::Matrix Jq(6, 6);
35  Jq.setIdentity();
36 
37  dynamicgraph::Vector p1xy(6);
38  p1xy(0) = 1.;
39  p1xy(1) = -2;
40  p1xy(2) = 1.;
41  p1xy(3) = 1.;
42  p1xy(4) = -2;
43  p1xy(5) = 1.;
44 
45  sotDEBUGF("Create feature");
47  FeatureVisualPoint *p1des = new FeatureVisualPoint("p1d");
48 
50  p1->selectionSIN = Flags(true);
51  p1->setReference(p1des);
52  p1->xySIN = p1xy;
53 
54  p1des->xySIN = dynamicgraph::Vector(6);
55 
56  sotDEBUGF("Create Task");
57  // sotDEBUG(0) << dynamicgraph::MATLAB;
58 
59  Task *task = new Task("t");
60  task->addFeature(*p1);
61 
62  GainAdaptive *lambda = new GainAdaptive("g");
63  lambda->errorSIN.plug(&task->errorSOUT);
64 
65  task->controlGainSIN.plug(&lambda->gainSOUT);
66  task->dampingGainSINOUT = .1;
67  task->controlSelectionSIN = Flags(true);
68 
69  task->jacobianSOUT.display(cout) << endl;
70  task->jacobianSOUT.displayDependencies(cout) << endl;
71 
72  // sotDEBUG(0) << dynamicgraph::MATLAB << "J"<< task->jacobianSOUT(2);
73  sotDEBUG(0) << "e" << task->errorSOUT(2) << endl;
74 
75  return 0;
76 }
dynamicgraph::Matrix & mrand(dynamicgraph::Matrix &J)
Definition: test_task.cpp:26
double drand(void)
Definition: test_task.cpp:25
Eigen::VectorXd Vector
virtual std::ostream & display(std::ostream &os) const
dynamicgraph::SignalPtr< dynamicgraph::Matrix, int > articularJacobianSIN
SignalPtr< Flags, int > selectionSIN
This vector specifies which dimension are used to perform the computation. For instance let us assume...
tuple p1
int i
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > errorSIN
dynamicgraph::SignalPtr< double, int > controlGainSIN
Definition: task.hh:108
void addFeature(FeatureAbstract &s)
Definition: task.cpp:108
virtual void setReference(const T *t, typename Signal< T, Time >::Mutex *m=NULL)
dynamicgraph::SignalPtr< Flags, int > controlSelectionSIN
Definition: task.hh:110
dynamicgraph::SignalTimeDependent< double, int > gainSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, int > errorSOUT
Definition: task.hh:111
int main(void)
Definition: test_task.cpp:32
def rand(n)
Class that defines 2D visualPoint visual feature.
virtual void plug(SignalBase< Time > *ref)
virtual void setReference(FeatureAbstract *sdes)=0
dynamicgraph::SignalPtr< double, int > dampingGainSINOUT
Definition: task.hh:109
dynamicgraph::SignalTimeDependent< dynamicgraph::Matrix, int > jacobianSOUT
#define sotDEBUG(level)
Definition: debug.hh:165
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > xySIN
Eigen::MatrixXd Matrix
void sotDEBUGF(const int, const char *,...)
Definition: debug.hh:179
Class that defines the basic elements of a task.
Definition: task.hh:72
std::ostream & displayDependencies(std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const


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