Main MRPT website
>
C++ reference for MRPT 1.4.0
mrpt
hwdrivers
CPtuBase.h
Go to the documentation of this file.
1
/* +---------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+---------------------------------------------------------------------------+ */
9
10
#ifndef CPtuBase_H
11
#define CPtuBase_H
12
13
#include <
mrpt/hwdrivers/CSerialPort.h
>
14
15
namespace
mrpt
16
{
17
namespace
hwdrivers
18
{
19
/** This class implements initialization and comunication methods to
20
* control a generic Pan and Tilt Unit, working in radians.
21
* \ingroup mrpt_hwdrivers_grp
22
*/
23
class
HWDRIVERS_IMPEXP
CPtuBase
24
{
25
26
/*************************** Atributes **********************/
27
28
public
:
29
30
double
tiltResolution
,panResolution;
31
32
protected
:
33
34
CSerialPort
serPort
;
35
36
/**************************** Methods ***********************/
37
38
public
:
39
40
/** Destructor */
41
42
virtual
~CPtuBase
() {};
43
44
/** Search limit forward */
45
46
virtual
bool
rangeMeasure()=0;
47
48
/** Specification of positions in absolute terms */
49
50
virtual
bool
moveToAbsPos(
char
axis,
double
nRad)=0;
51
52
/** Query position in absolute terms */
53
54
virtual
bool
absPosQ(
char
axis,
double
&nRad)=0;
55
56
/** Specify desired axis position as an offset from the current position. \n
57
* This method recives the number of radians to move.
58
* \code
59
* Example of use:
60
* TT-500 *
61
* A *
62
* TO * Current Tilt position is -500
63
* TO500 *
64
* A *
65
* TT * Current Pan position is 1000
66
* \endcode
67
*/
68
69
virtual
bool
moveToOffPos(
char
axis,
double
nRad)=0;
70
71
/** Query position in relative terms */
72
73
virtual
bool
offPosQ(
char
axis,
double
&nRad)=0;
74
75
/** Query max movement limit of a axis in absolute terms */
76
77
virtual
bool
maxPosQ(
char
axis,
double
&nRad)=0;
78
79
/** Query min movement limit of a axis in absolute terms */
80
81
virtual
bool
minPosQ(
char
axis,
double
&nRad)=0;
82
83
/** Query if exist movement limits */
84
85
virtual
bool
enableLimitsQ(
bool
&enable)=0;
// Query if exist some limit
86
87
/** Enable/Disable movement limits */
88
89
virtual
bool
enableLimits(
bool
set)=0;
90
91
/** With I mode (default) instructs pan-tilt unit to immediately
92
* execute positional commands. \n
93
* In S mode instructs pan-tilt unit to execute positional commands
94
* only when an Await Position Command Completion command is executed
95
* or when put into Immediate Execution Mode. \n
96
* \code
97
* Example of use of S mode:
98
* DR *
99
* S *
100
* PP1500 *
101
* TP-900 *
102
* PP * Current Pan position is 0
103
* TP * Current Tilt position is 0
104
* A *
105
* PP * Current Pan position is 1500
106
* TP * Current Tilt position is -900
107
* \endcode
108
*/
109
110
virtual
bool
inmediateExecution(
bool
set)=0;
111
112
/** Wait the finish of the last position command to
113
* continue accept commands
114
*/
115
116
virtual
bool
aWait(
void
)=0;
117
118
/** Inmediately stop all */
119
120
virtual
bool
haltAll()=0;
121
122
/** Inmediately stop */
123
124
virtual
bool
halt(
char
axis)=0;
125
126
/** Specification of turn speed */
127
128
virtual
bool
speed(
char
axis,
double
RadSec)=0;
129
130
/** Query turn speed */
131
132
virtual
bool
speedQ(
char
axis,
double
&RadSec)=0;
133
134
/** Specification (de/a)celeration in turn */
135
136
virtual
bool
aceleration(
char
axis,
double
RadSec2)=0;
137
138
/** Query (de/a)celeration in turn */
139
140
virtual
bool
acelerationQ(
char
axis,
double
&RadSec2)=0;
141
142
/** Specification of velocity to which start and finish
143
* the (de/a)celeration
144
*/
145
146
virtual
bool
baseSpeed(
char
axis,
double
RadSec)=0;
147
148
/** Query velocity to which start and finish
149
* the (de/a)celeration
150
*/
151
152
virtual
bool
baseSpeedQ(
char
axis,
double
&RadSec)=0;
153
154
/** Specification of velocity upper limit */
155
156
virtual
bool
upperSpeed(
char
axis,
double
RadSec)=0;
157
158
/** Query velocity upper limit */
159
160
virtual
bool
upperSpeedQ(
char
axis,
double
&RadSec)=0;
161
162
/** Specification of velocity lower limit */
163
164
virtual
bool
lowerSpeed(
char
axis,
double
RadSec)=0;
165
166
/** Query velocity lower limit */
167
168
virtual
bool
lowerSpeedQ(
char
axis,
double
&RadSec)=0;
169
170
/** Reset PTU to initial state */
171
172
virtual
bool
reset(
void
)=0;
173
174
/** Save or restart default values */
175
176
virtual
bool
save(
void
)=0;
177
178
/** Restore default values */
179
180
virtual
bool
restoreDefaults(
void
)=0;
181
182
/** Restore factory default values */
183
184
virtual
bool
restoreFactoryDefaults(
void
)=0;
185
186
/** Version and CopyRights */
187
188
virtual
bool
version(
char
* nVersion)=0;
189
190
/** Number of version */
191
192
virtual
void
nversion(
double
&nVersion)=0;
193
194
/** Query power mode */
195
196
virtual
bool
powerModeQ(
bool
transit,
char
&mode)=0;
197
198
/** Specification of power mode */
199
200
virtual
bool
powerMode(
bool
transit,
char
mode)=0;
201
202
/** Check if ptu is moving */
203
204
virtual
double
status(
double
&rad)=0;
205
206
/** Set limits of movement */
207
208
virtual
bool
setLimits(
char
axis,
double
&l,
double
&u)=0;
209
210
/* Change motion direction */
211
212
virtual
bool
changeMotionDir()=0;
213
214
215
/**************************** State Queries ********************/
216
217
/** Check errors, returns 0 if there are not errors or error code otherwise **/
218
219
virtual
int
checkErrors()=0;
220
221
/** Clear errors **/
222
223
virtual
void
clearErrors()=0;
224
225
226
/*************************** Other member methods *****************/
227
228
/** PTU and serial port initialization */
229
230
virtual
bool
init(
const
std::string &port)=0;
231
232
/** Close conection with serial port */
233
234
virtual
void
close()=0;
235
236
/** To obtains the mistake for use discrete values when the movement
237
* is expressed in radians. Parameters are the absolute position in
238
* radians and the axis desired
239
*/
240
241
virtual
double
radError(
char
axis,
double
nRadMoved)=0;
242
243
/** To obtain the discrete value for a number of radians */
244
245
virtual
long
radToPos(
char
axis,
double
nRad)=0;
246
247
/** To obtain the number of radians for a discrete value */
248
249
virtual
double
posToRad(
char
axis,
long
nPos)=0;
250
251
/** Performs a scan in the axis indicated and whit the precision desired.
252
* \param <axis> {Pan or Till}
253
* \param <tWait> {Wait time betwen commands}
254
* \param <initial> {initial position}
255
* \param <final> {final position}
256
* \param <RadPre> {radians precision for the scan}
257
*/
258
259
virtual
bool
scan(
char
axis,
int
wait,
float
initial,
float
final
,
double
RadPre)=0;
260
261
/** Query verbose mode */
262
263
virtual
bool
verboseQ(
bool
&modo)=0;
264
265
/** Set verbose. \n
266
* \conde
267
* Example of response with FV (verbose) active:
268
* FV *
269
* PP * Current pan position is 0
270
* Example of response with FT (terse) active:
271
* FT *
272
* PP * 0
273
* \endcode
274
*/
275
276
virtual
bool
verbose(
bool
set)=0;
277
278
/** Query echo mode */
279
280
virtual
bool
echoModeQ(
bool
&mode)=0;
281
282
/** Enable/Disable echo response with command. \n
283
* \code
284
* Example of use (EE supposed):
285
* PP * 22
286
* ED *
287
* <pp entered again, but not echoed>* 22
288
* \endcode
289
*/
290
291
virtual
bool
echoMode(
bool
mode)=0;
292
293
/** Query the pan and tilt resolution per position moved
294
* and initialize local atributes
295
*/
296
297
virtual
bool
resolution(
void
)=0;
298
299
300
/*************************** Methods for internal use ****************/
301
302
private
:
303
304
/** To transmition commands to the PTU */
305
306
virtual
bool
transmit(
const
char
* command)=0;
307
308
/** To receive the responseof the PTU */
309
310
virtual
bool
receive(
const
char
* command,
char
* response)=0;
311
312
/** Used to obtains a number of radians */
313
314
virtual
bool
radQuerry(
char
axis,
char
command,
double
&nRad)=0;
315
316
/** Method used for asign a number of radians with a command */
317
318
virtual
bool
radAsign(
char
axis,
char
command,
double
nRad)=0;
319
320
321
};
// End of class
322
323
}
// End of namespace
324
325
}
// End of namespace
326
327
#endif
mrpt::hwdrivers::CPtuBase::tiltResolution
double tiltResolution
Definition:
CPtuBase.h:30
CSerialPort.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition:
CParticleFilter.h:16
mrpt::hwdrivers::CPtuBase::serPort
CSerialPort serPort
Definition:
CPtuBase.h:34
mrpt::hwdrivers::CPtuBase
This class implements initialization and comunication methods to control a generic Pan and Tilt Unit,...
Definition:
CPtuBase.h:23
mrpt::hwdrivers::CSerialPort
A communications serial port built as an implementation of a utils::CStream.
Definition:
CSerialPort.h:43
HWDRIVERS_IMPEXP
#define HWDRIVERS_IMPEXP
Definition:
hwdrivers_impexp.h:82
mrpt::hwdrivers::CPtuBase::~CPtuBase
virtual ~CPtuBase()
Destructor.
Definition:
CPtuBase.h:42
Page generated by
Doxygen 1.8.17
for MRPT 1.4.0 SVN: at Sat Jan 18 22:37:07 UTC 2020