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