Directory: | ./ |
---|---|
File: | tests/task/test_task.cpp |
Date: | 2024-12-13 12:22:33 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 31 | 36 | 86.1% |
Branches: | 41 | 86 | 47.7% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Copyright 2010, | ||
3 | * François Bleibel, | ||
4 | * Olivier Stasse, | ||
5 | * | ||
6 | * CNRS/AIST | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | /* -------------------------------------------------------------------------- */ | ||
11 | /* --- INCLUDES ------------------------------------------------------------- */ | ||
12 | /* -------------------------------------------------------------------------- */ | ||
13 | #include <dynamic-graph/linear-algebra.h> | ||
14 | |||
15 | #include <iostream> | ||
16 | #include <sot/core/debug.hh> | ||
17 | #include <sot/core/feature-abstract.hh> | ||
18 | #include <sot/core/feature-visual-point.hh> | ||
19 | #include <sot/core/gain-adaptive.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; } | |
26 | ✗ | dynamicgraph::Matrix &mrand(dynamicgraph::Matrix &J) { | |
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 | 1 | int main(void) { | |
33 | 1 | srand(12); | |
34 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dynamicgraph::Matrix Jq(6, 6); |
35 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | Jq.setIdentity(); |
36 | |||
37 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | dynamicgraph::Vector p1xy(6); |
38 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1xy(0) = 1.; |
39 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1xy(1) = -2; |
40 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1xy(2) = 1.; |
41 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1xy(3) = 1.; |
42 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1xy(4) = -2; |
43 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1xy(5) = 1.; |
44 | |||
45 | 1 | sotDEBUGF("Create feature"); | |
46 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
1 | FeatureVisualPoint *p1 = new FeatureVisualPoint("p1"); |
47 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
1 | FeatureVisualPoint *p1des = new FeatureVisualPoint("p1d"); |
48 | |||
49 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1->articularJacobianSIN.setReference(&Jq); |
50 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | p1->selectionSIN = Flags(true); |
51 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1->setReference(p1des); |
52 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | p1->xySIN = p1xy; |
53 | |||
54 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | p1des->xySIN = dynamicgraph::Vector(6); |
55 | |||
56 | 1 | sotDEBUGF("Create Task"); | |
57 | // sotDEBUG(0) << dynamicgraph::MATLAB; | ||
58 | |||
59 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
1 | Task *task = new Task("t"); |
60 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | task->addFeature(*p1); |
61 | |||
62 |
3/6✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
|
1 | GainAdaptive *lambda = new GainAdaptive("g"); |
63 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | lambda->errorSIN.plug(&task->errorSOUT); |
64 | |||
65 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | task->controlGainSIN.plug(&lambda->gainSOUT); |
66 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | task->dampingGainSINOUT = .1; |
67 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | task->controlSelectionSIN = Flags(true); |
68 | |||
69 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | task->jacobianSOUT.display(cout) << endl; |
70 |
5/10✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
1 | 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 | 1 | return 0; | |
76 | 1 | } | |
77 |