GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tests/task/test_gain.cpp Lines: 16 16 100.0 %
Date: 2023-03-13 12:09:37 Branches: 22 44 50.0 %

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
14
#include <dynamic-graph/linear-algebra.h>
15
#include <dynamic-graph/signal.h>
16
17
#include <iostream>
18
#include <sot/core/gain-adaptive.hh>
19
using namespace std;
20
using namespace dynamicgraph::sot;
21
using namespace dynamicgraph;
22
23
class DummyClass {
24
 public:
25
  dynamicgraph::Vector err;
26
27
2
  dynamicgraph::Vector &getError(dynamicgraph::Vector &res, int t) {
28
2
    cout << "Dummy::getError [" << t << "] " << endl;
29
2
    return res = err;
30
  }
31
};
32
33
DummyClass dummy;
34
35
/* -------------------------------------------------------------------------- */
36
/* --- INCLUDES ------------------------------------------------------------- */
37
/* -------------------------------------------------------------------------- */
38
39
1
int main(void) {
40
1
  dummy.err.resize(3);
41
1
  dummy.err.fill(3);
42
43

1
  GainAdaptive *gain = new GainAdaptive("gain", 4, 1, 5);
44
45

2
  Signal<dynamicgraph::Vector, int> errSig("test");
46


1
  errSig.setFunction(boost::bind(&DummyClass::getError, dummy, _1, _2));
47
48
1
  gain->errorSIN.plug(&errSig);
49

1
  cout << "Appel of errSig and display of the result." << endl;
50

1
  cout << errSig(0) << endl;
51
52
1
  Signal<double, int> &gainSig = gain->gainSOUT;
53
54

1
  cout << "Compute gain from Gain Signal and display." << endl;
55

1
  cout << gainSig(0) << endl;
56
57
1
  return 0;
58
}