src
tools
event.cpp
Go to the documentation of this file.
1
// Copyright (c) 2017, Joseph Mirabel
2
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3
4
#include <dynamic-graph/factory.h>
5
6
#include <
sot/core/event.hh
>
7
8
namespace
dynamicgraph
{
9
namespace
sot {
10
11
bool
&
Event::check
(
bool
&ret,
const
int
&time) {
12
const
bool
&val =
conditionSIN
(time);
13
ret = (val !=
lastVal_
);
14
bool
up = (!
lastVal_
&& val);
15
if
(up) {
16
timeSinceUp_
= 0;
17
}
else
if
(val) {
18
++
timeSinceUp_
;
19
}
20
// If repetition is activated, trigger again after given number of iterations
21
bool
trigger = up || (
repeatAfterNIterations_
> 0 &&
22
timeSinceUp_
>=
repeatAfterNIterations_
);
23
if
(ret) {
24
lastVal_
= val;
25
}
26
if
(trigger) {
27
for
(Triggers_t::const_iterator _s =
triggers
.begin(); _s !=
triggers
.end();
28
++_s)
29
(*_s)->recompute(time);
30
timeSinceUp_ = 0;
31
}
32
return
ret;
33
}
34
35
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
(
Event
,
"Event"
);
36
}
// namespace sot
37
}
// namespace dynamicgraph
event.hh
dynamicgraph::sot::DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeaturePosture, "FeaturePosture")
dynamicgraph::sot::Event::timeSinceUp_
int timeSinceUp_
Definition:
event.hh:121
dynamicgraph::sot::Event::triggers
Triggers_t triggers
Definition:
event.hh:117
dynamicgraph::sot::Event
Definition:
event.hh:44
dynamicgraph::sot::Event::repeatAfterNIterations_
int repeatAfterNIterations_
Definition:
event.hh:121
dynamicgraph::sot::Event::conditionSIN
SignalPtr< bool, int > conditionSIN
Definition:
event.hh:118
dynamicgraph::sot::Event::lastVal_
bool lastVal_
Definition:
event.hh:120
dynamicgraph::sot::Event::check
bool & check(bool &ret, const int &time)
Definition:
event.cpp:11
dynamicgraph
sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26