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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019