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



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013