Main Page
+
Namespaces
Namespace List
+
Namespace Members
All
Functions
+
Classes
Class List
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
o
p
r
s
t
u
v
w
x
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
o
p
r
s
t
w
x
~
+
Variables
_
a
b
c
d
g
h
l
m
p
r
s
t
u
v
Typedefs
+
Files
File List
+
File Members
All
Functions
Variables
Typedefs
Enumerations
Enumerator
common
include
turnIndicatorMode.h
Go to the documentation of this file.
1
/*
2
* Copyright 2021 Mojin Robotics GmbH https://www.mojin-robotics.de
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
18
19
#ifndef TURNINDICATORMODE_H
20
#define TURNINDICATORMODE_H
21
22
#include <
mode.h
>
23
24
class
TurnIndicatorMode
:
public
Mode
25
{
26
public
:
27
TurnIndicatorMode
(
color::rgba
color
,
size_t
num_leds,
int
dir,
int
priority = 0,
double
freq = 0.25,
int
pulses = 0,
double
timeout = 0)
28
:
Mode
(priority, freq, pulses, timeout),
_num_leds
(num_leds)
29
{
30
_inc
= (1. /
UPDATE_RATE_HZ
) *
_freq
;
31
32
_color
= color;
33
_colors
.assign(
_num_leds
,
color::rgba
());
34
_colors
[0] = color;
35
_pos
= 0;
36
_dir
= dir;
37
if
(
_num_leds
%2 == 0)
38
{
39
_center_pos
=
_num_leds
/2 - 1;
40
if
(
_dir
< 0)
41
_center_pos
--;
42
}
43
else
44
_center_pos
=
_num_leds
/2;
45
46
_pos
=
_center_pos
;
47
_keep_counter
= 20;
48
}
49
50
void
execute
()
51
{
52
if
(
_timer_inc
>= 1.0)
53
{
54
//if we exeeded the array keep the colors for a few steps
55
//and reset afterwards
56
if
(
_pos
== -1 ||
_pos
==
_num_leds
)
57
{
58
_keep_counter
--;
59
if
(
_keep_counter
== 0)
60
{
61
_keep_counter
= 20;
62
_pos
=
_center_pos
;
63
_colors
.assign(
_num_leds
,
color::rgba
());
64
}
65
}
66
else
67
{
68
_colors
[
_pos
] =
_color
;
69
_pos
+=
_dir
;
70
}
71
72
m_sigColorsReady
(
_colors
);
73
74
_timer_inc
= 0.0;
75
}
76
else
77
_timer_inc
+=
_inc
;
78
}
79
80
std::string
getName
(){
return
std::string(
"TurnIndicatorMode"
); }
81
82
private
:
83
double
_timer_inc
;
84
double
_inc
;
85
double
_pos
;
86
double
_dir
;
87
int
_keep_counter
;
88
int
_center_pos
;
89
int
_num_leds
;
90
};
91
92
#endif
TurnIndicatorMode::_timer_inc
double _timer_inc
Definition:
turnIndicatorMode.h:83
TurnIndicatorMode::_dir
double _dir
Definition:
turnIndicatorMode.h:86
Mode::_color
color::rgba _color
Definition:
mode.h:121
Mode::_colors
std::vector< color::rgba > _colors
Definition:
mode.h:122
Mode
Definition:
mode.h:26
Mode::UPDATE_RATE_HZ
static const unsigned int UPDATE_RATE_HZ
Definition:
mode.h:126
TurnIndicatorMode
Definition:
turnIndicatorMode.h:24
TurnIndicatorMode::getName
std::string getName()
Definition:
turnIndicatorMode.h:80
TurnIndicatorMode::_keep_counter
int _keep_counter
Definition:
turnIndicatorMode.h:87
TurnIndicatorMode::TurnIndicatorMode
TurnIndicatorMode(color::rgba color, size_t num_leds, int dir, int priority=0, double freq=0.25, int pulses=0, double timeout=0)
Definition:
turnIndicatorMode.h:27
TurnIndicatorMode::execute
void execute()
Definition:
turnIndicatorMode.h:50
Mode::_freq
double _freq
Definition:
mode.h:114
TurnIndicatorMode::_inc
double _inc
Definition:
turnIndicatorMode.h:84
Mode::m_sigColorsReady
boost::signals2::signal< void(std::vector< color::rgba > &colors)> m_sigColorsReady
Definition:
mode.h:129
TurnIndicatorMode::_num_leds
int _num_leds
Definition:
turnIndicatorMode.h:89
TurnIndicatorMode::_pos
double _pos
Definition:
turnIndicatorMode.h:85
color::rgba
Definition:
colorUtils.h:26
mode.h
color
Definition:
colorUtils.h:24
TurnIndicatorMode::_center_pos
int _center_pos
Definition:
turnIndicatorMode.h:88
cob_light
Author(s): Benjamin Maidel
autogenerated on Thu Nov 17 2022 03:17:28