tests
signal
test_signal.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 <
dynamic-graph/all-signals.h
>
14
#include <
dynamic-graph/linear-algebra.h
>
15
16
#include <iostream>
17
using namespace
std;
18
using namespace
dynamicgraph
;
19
20
class
DummyClass
{
21
public
:
22
dynamicgraph::Vector
&
fun
(
dynamicgraph::Vector
&res,
double
j) {
23
res
.resize(3);
24
res
.fill(j);
25
return
res
;
26
}
27
};
28
29
dynamicgraph::Vector
test_data
(6);
30
Signal<dynamicgraph::Vector, double>
sig
(
"sigtest"
);
31
DummyClass
dummy
;
32
33
dynamicgraph::Vector
&
fun
(
dynamicgraph::Vector
&res,
double
/*j*/
) {
34
return
res
=
test_data
;
35
}
36
37
int
main
(
void
) {
38
test_data
.fill(1);
39
cout <<
"test_data: "
<<
test_data
<< endl;
40
41
sig
.setConstant(
test_data
);
42
cout <<
"Constant: "
<<
sig
.access(1.) << endl;
43
test_data
*= 2;
44
cout <<
"Constant: "
<<
sig
(1.) << endl;
45
46
sig
.setReference(&
test_data
);
47
cout <<
"Reference: "
<<
sig
(1.) << endl;
48
test_data
*= 2;
49
cout <<
"Reference: "
<<
sig
(1.) << endl;
50
51
sig
.setFunction(&
fun
);
52
cout <<
"Function: "
<<
sig
(1.) << endl;
53
test_data
*= 2;
54
cout <<
"Function: "
<<
sig
(1.) << endl;
55
56
// boost::function2<int,int,double> onClick = (&DummyClass::fun, &dummy,
57
// _1,_2) ; boost::function<> onClick = boost::bind(&DummyClass::fun,
58
// &dummy);
59
sig
.setFunction(boost::bind(&
DummyClass::fun
, &
dummy
, _1, _2));
60
cout <<
"Function: "
<<
sig
(1.5) << endl;
61
test_data
*= 2;
62
cout <<
"Function: "
<<
sig
(1.34) << endl;
63
64
// sig.setFunction(&DummyClass::fun, dummy);
65
// cout << "Function: " << sig(1.5) <<endl;
66
// test_data*=2;
67
// cout << "Function: " << sig(12.34) <<endl;
68
69
return
0;
70
}
DummyClass
Definition:
test_dep.cpp:21
dynamicgraph::Signal
test_data
dynamicgraph::Vector test_data(6)
dynamicgraph
fun
dynamicgraph::Vector & fun(dynamicgraph::Vector &res, double)
Definition:
test_signal.cpp:33
sig
Signal< dynamicgraph::Vector, double > sig("sigtest")
res
res
dummy
DummyClass dummy
Definition:
test_signal.cpp:31
all-signals.h
dynamicgraph::Vector
Eigen::VectorXd Vector
main
int main(void)
Definition:
test_signal.cpp:37
DummyClass::fun
T & fun(T &res, int t)
linear-algebra.h
sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:32