tsot.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 /* -------------------------------------------------------------------------- */
13 #include <iostream>
14 // #include <sot/core/sot-h.hh>
16 
17 #include <sot/core/debug.hh>
21 #include <sot/core/task.hh>
22 
23 using namespace std;
24 using namespace dynamicgraph::sot;
25 
26 double drand(void) { return 2 * ((double)rand()) / RAND_MAX - 1; }
28  for (int i = 0; i < J.rows(); ++i)
29  for (int j = 0; j < J.cols(); ++j) J(i, j) = drand();
30  return J;
31 }
32 
33 int main(void) {
34  sotDEBUGF("# In {");
35 
36  srand(12);
37  dynamicgraph::Matrix Jq(6, 6);
38  Jq.setIdentity();
39 
40  dynamicgraph::Vector p1xy(2);
41  p1xy(0) = 1.;
42  p1xy(1) = -2;
43 
44  sotDEBUGF("Create feature");
46  FeatureVisualPoint *p1des = new FeatureVisualPoint("p1des");
47 
48  p1->articularJacobianSIN.setReference(&Jq);
49  p1->selectionSIN = Flags(true);
50  p1->setReference(p1des);
51  p1->xySIN = p1xy;
52 
53  p1des->xySIN = dynamicgraph::Vector(2);
54 
55  sotDEBUGF("Create Task");
56  // sotDEBUG(0) << dynamicgraph::MATLAB;
57 
58  Task *task = new Task("task");
59  task->addFeature(*p1);
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) << "J" << task->jacobianSOUT(2);
73  sotDEBUG(0) << "e" << task->errorSOUT(2) << endl;
74 
75  sotDEBUGF("# Out }");
76 
77  return 0;
78 }
dynamicgraph::SignalTimeDependent::displayDependencies
std::ostream & displayDependencies(std::ostream &os, const int depth=-1, std::string space="", std::string next1="", std::string next2="") const
main
int main(void)
Definition: tsot.cpp:33
dynamicgraph::sot::Task::controlSelectionSIN
dynamicgraph::SignalPtr< Flags, sigtime_t > controlSelectionSIN
Definition: task.hh:112
dynamicgraph::sot::GainAdaptive::errorSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > errorSIN
Definition: gain-adaptive.hh:119
dynamicgraph::sot::Task::controlGainSIN
dynamicgraph::SignalPtr< double, sigtime_t > controlGainSIN
Definition: task.hh:110
feature-visual-point.hh
dynamicgraph::sot::FeatureVisualPoint::xySIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, sigtime_t > xySIN
Definition: feature-visual-point.hh:58
dynamicgraph::sot::sotDEBUGF
void sotDEBUGF(const size_type, const char *,...)
Definition: debug.hh:182
J
J
i
int i
dynamicgraph::SignalPtr::plug
virtual void plug(SignalBase< Time > *ref)
drand
double drand(void)
Definition: tsot.cpp:26
task.hh
dynamicgraph::Matrix
Eigen::MatrixXd Matrix
feature-abstract.hh
debug.hh
dynamicgraph::sot::GainAdaptive::gainSOUT
dynamicgraph::SignalTimeDependent< double, sigtime_t > gainSOUT
Definition: gain-adaptive.hh:120
dynamicgraph::sot::TaskAbstract::jacobianSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Matrix, sigtime_t > jacobianSOUT
Definition: task-abstract.hh:80
dynamicgraph::Vector
Eigen::VectorXd Vector
dynamicgraph::sot::Task::errorSOUT
dynamicgraph::SignalTimeDependent< dynamicgraph::Vector, sigtime_t > errorSOUT
Definition: task.hh:113
p1
tuple p1
dynamicgraph::sot::FeatureVisualPoint
Class that defines 2D visualPoint visual feature.
Definition: feature-visual-point.hh:46
linear-algebra.h
dynamicgraph::sot::double
double
Definition: fir-filter.cpp:49
dynamicgraph::sot::GainAdaptive
Definition: gain-adaptive.hh:53
dynamicgraph::sot::Task
Class that defines the basic elements of a task.
Definition: task.hh:72
gain-adaptive.hh
dynamicgraph::sot
dynamicgraph::sot::Flags
Definition: flags.hh:33
rand
def rand(n)
dynamicgraph::sot::Task::addFeature
void addFeature(FeatureAbstract &s)
Definition: task.cpp:109
mrand
dynamicgraph::Matrix & mrand(dynamicgraph::Matrix &J)
Definition: tsot.cpp:27
dynamicgraph::sot::Task::dampingGainSINOUT
dynamicgraph::SignalPtr< double, sigtime_t > dampingGainSINOUT
Definition: task.hh:111
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:32