Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpRingLight.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Ring light management.
32
*/
33
38
39
#include <visp3/core/vpConfig.h>
40
41
#if defined(VISP_HAVE_MODULE_IO) && defined(VISP_HAVE_PARPORT)
42
43
#include <fcntl.h>
44
#include <sys/ioctl.h>
45
#include <sys/stat.h>
46
#include <sys/time.h>
47
#include <sys/types.h>
48
#include <unistd.h>
49
50
#include <visp3/core/vpDebug.h>
51
#include <visp3/core/vpTime.h>
52
#include <visp3/robot/vpRingLight.h>
53
54
BEGIN_VISP_NAMESPACE
69
vpRingLight::vpRingLight
() : parport() {
off
(); }
70
79
vpRingLight::~vpRingLight
() {
off
(); }
80
88
void
vpRingLight::pulse
()
89
{
90
// Data set by the parallel port:
91
// - D1: need to send a 500us pulse width
92
// - D2: 0 }
93
// - D3: 0 } To control the light throw the NE555
94
// D2 and D3 are used to select the multiplexer output.
95
// Light must be connected to output 1+,1-
96
97
// To activates the light we send a pulse
98
int
mask_mode_pulse_d2 = 0x00;
// D2 is low
99
int
mask_pulse_d1 = 0x02;
// we send a pulse on D1 : L, H, L
100
unsigned
char
data = 0x00;
101
// data = parport.getData(); // actual value of the data bus
102
// vpTRACE("Actual data 0x%x = %d\n", data, data);
103
104
data = data | mask_pulse_d1 | mask_mode_pulse_d2;
105
// vpTRACE("Send 0x%x = %d\n", data, data);
106
parport.sendData(data);
// send a 0-1 pulse
107
108
// Wait 500 micro seconds
109
struct
timeval ti, tc;
// Initial and current time
110
struct
timeval tempo;
111
tempo.tv_usec = 500;
112
gettimeofday(&ti, 0L);
113
do
{
114
gettimeofday(&tc, 0L);
115
}
while
(tc.tv_usec < ti.tv_usec + tempo.tv_usec);
116
117
data = data & (~mask_pulse_d1);
118
// vpTRACE("Send 0x%x = %d\n", data, data);
119
parport.sendData(data);
// send a 1-0 pulse
120
}
121
131
void
vpRingLight::pulse
(
double
time)
132
{
133
// Data set by the parallel port:
134
// - D1: a pulse with duration fixed by time
135
// - D2: 0 }
136
// - D3: 1 } To control the light directly throw the pulse coming from D1
137
// D2 and D3 are used to select the multiplexer output.
138
// Light must be connected to output 1+,1-
139
140
// To activates the light we send a pulse
141
int
mask_mode_pulse_d3 = 0x08;
// D3 is hight, D2 is low
142
int
mask_pulse_d1 = 0x02;
// we send a pulse on D1 : L, H, L
143
unsigned
char
data = 0x00;
144
// data = parport.getData(); // actual value of the data bus
145
// vpTRACE("Actual data 0x%x = %d\n", data, data);
146
147
data = data | mask_pulse_d1 | mask_mode_pulse_d3;
148
// vpTRACE("Send 0x%x = %d\n", data, data);
149
parport.sendData(data);
// send a 0-1 pulse
150
151
// Wait 500 micro seconds
152
struct
timeval ti, tc;
// Initial and current time
153
gettimeofday(&ti, 0);
154
do
{
155
gettimeofday(&tc, 0);
156
}
while
(tc.tv_usec < ti.tv_usec + time * 1000);
157
158
data = data & (~mask_pulse_d1);
159
// vpTRACE("Send 0x%x = %d\n", data, data);
160
parport.sendData(data);
// send a 1-0 pulse
161
}
162
169
void
vpRingLight::on
()
170
{
171
// Data set by the parallel port:
172
// - D1: 0 to turn OFF, 1 to turn ON
173
// - D2: 1 }
174
// - D3: 0 } To control the light throw D1
175
// D2 and D3 are used to select the multiplexer output.
176
// Light must be connected to output 1+,1-
177
178
// To activates the light we send a pulse
179
int
mask_mode_onoff_d2 = 0x04;
// D2 is Hight
180
int
mask_on_d1 = 0x02;
// D1 is Hight to turn the light on
181
unsigned
char
data = 0x00;
182
// data = parport.getData(); // actual value of the data bus
183
184
data = data | mask_on_d1 | mask_mode_onoff_d2;
185
// vpTRACE("Send 0x%x = %d\n", data, data);
186
parport.sendData(data);
187
}
188
195
void
vpRingLight::off
()
196
{
197
// Data set by the parallel port:
198
// - D1: 0 to turn OFF, 1 to turn ON
199
// - D2: 1 }
200
// - D3: 0 } To control the light throw D1
201
// D2 and D3 are used to select the multiplexer output.
202
// Light must be connected to output 1+,1-
203
204
// To activates the light we send a pulse
205
int
mask_mode_onoff_d2 = 0x04;
// D2 is Hight
206
int
mask_off_d1 = 0x00;
// D1 is Low to turn the light off
207
unsigned
char
data = 0x00;
208
// data = parport.getData(); // actual value of the data bus
209
210
data = data | mask_off_d1 | mask_mode_onoff_d2;
211
// vpTRACE("Send 0x%x = %d\n", data, data);
212
parport.sendData(data);
213
}
214
END_VISP_NAMESPACE
215
#elif !defined(VISP_BUILD_SHARED_LIBS)
216
// Work around to avoid warning: libvisp_robot.a(vpRingLight.cpp.o) has no symbols
217
void
dummy_vpRingLight() { }
218
#endif
vpRingLight::pulse
void pulse()
Definition
vpRingLight.cpp:88
vpRingLight::off
void off()
Definition
vpRingLight.cpp:195
vpRingLight::on
void on()
Definition
vpRingLight.cpp:169
vpRingLight::vpRingLight
vpRingLight()
Definition
vpRingLight.cpp:69
vpRingLight::~vpRingLight
virtual ~vpRingLight()
Definition
vpRingLight.cpp:79
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
robot
src
light
vpRingLight.cpp
Generated by
1.17.0