MRPT  1.9.9
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-2018, 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/comms/CSerialPort.h>
14 
15 namespace mrpt::hwdrivers
16 {
17 /** This class implements initialization and comunication methods to
18  * control a generic Pan and Tilt Unit, working in radians.
19  * \ingroup mrpt_hwdrivers_grp
20  */
21 class CPtuBase
22 {
23  /*************************** Atributes **********************/
24 
25  public:
27 
28  protected:
30 
31  /**************************** Methods ***********************/
32 
33  public:
34  /** Destructor */
35 
36  virtual ~CPtuBase(){};
37 
38  /** Search limit forward */
39 
40  virtual bool rangeMeasure() = 0;
41 
42  /** Specification of positions in absolute terms */
43 
44  virtual bool moveToAbsPos(char axis, double nRad) = 0;
45 
46  /** Query position in absolute terms */
47 
48  virtual bool absPosQ(char axis, double& nRad) = 0;
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) = 0;
64 
65  /** Query position in relative terms */
66 
67  virtual bool offPosQ(char axis, double& nRad) = 0;
68 
69  /** Query max movement limit of a axis in absolute terms */
70 
71  virtual bool maxPosQ(char axis, double& nRad) = 0;
72 
73  /** Query min movement limit of a axis in absolute terms */
74 
75  virtual bool minPosQ(char axis, double& nRad) = 0;
76 
77  /** Query if exist movement limits */
78 
79  virtual bool enableLimitsQ(bool& enable) = 0; // Query if exist some limit
80 
81  /** Enable/Disable movement limits */
82 
83  virtual bool enableLimits(bool set) = 0;
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) = 0;
105 
106  /** Wait the finish of the last position command to
107  * continue accept commands
108  */
109 
110  virtual bool aWait(void) = 0;
111 
112  /** Inmediately stop all */
113 
114  virtual bool haltAll() = 0;
115 
116  /** Inmediately stop */
117 
118  virtual bool halt(char axis) = 0;
119 
120  /** Specification of turn speed */
121 
122  virtual bool speed(char axis, double RadSec) = 0;
123 
124  /** Query turn speed */
125 
126  virtual bool speedQ(char axis, double& RadSec) = 0;
127 
128  /** Specification (de/a)celeration in turn */
129 
130  virtual bool aceleration(char axis, double RadSec2) = 0;
131 
132  /** Query (de/a)celeration in turn */
133 
134  virtual bool acelerationQ(char axis, double& RadSec2) = 0;
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) = 0;
141 
142  /** Query velocity to which start and finish
143  * the (de/a)celeration
144  */
145 
146  virtual bool baseSpeedQ(char axis, double& RadSec) = 0;
147 
148  /** Specification of velocity upper limit */
149 
150  virtual bool upperSpeed(char axis, double RadSec) = 0;
151 
152  /** Query velocity upper limit */
153 
154  virtual bool upperSpeedQ(char axis, double& RadSec) = 0;
155 
156  /** Specification of velocity lower limit */
157 
158  virtual bool lowerSpeed(char axis, double RadSec) = 0;
159 
160  /** Query velocity lower limit */
161 
162  virtual bool lowerSpeedQ(char axis, double& RadSec) = 0;
163 
164  /** Reset PTU to initial state */
165 
166  virtual bool reset(void) = 0;
167 
168  /** Save or restart default values */
169 
170  virtual bool save(void) = 0;
171 
172  /** Restore default values */
173 
174  virtual bool restoreDefaults(void) = 0;
175 
176  /** Restore factory default values */
177 
178  virtual bool restoreFactoryDefaults(void) = 0;
179 
180  /** Version and CopyRights */
181 
182  virtual bool version(char* nVersion) = 0;
183 
184  /** Number of version */
185 
186  virtual void nversion(double& nVersion) = 0;
187 
188  /** Query power mode */
189 
190  virtual bool powerModeQ(bool transit, char& mode) = 0;
191 
192  /** Specification of power mode */
193 
194  virtual bool powerMode(bool transit, char mode) = 0;
195 
196  /** Check if ptu is moving */
197 
198  virtual double status(double& rad) = 0;
199 
200  /** Set limits of movement */
201 
202  virtual bool setLimits(char axis, double& l, double& u) = 0;
203 
204  /* Change motion direction */
205 
206  virtual bool changeMotionDir() = 0;
207 
208  /**************************** State Queries ********************/
209 
210  /** Check errors, returns 0 if there are not errors or error code otherwise
211  * **/
212 
213  virtual int checkErrors() = 0;
214 
215  /** Clear errors **/
216 
217  virtual void clearErrors() = 0;
218 
219  /*************************** Other member methods *****************/
220 
221  /** PTU and serial port initialization */
222 
223  virtual bool init(const std::string& port) = 0;
224 
225  /** Close Connection with serial port */
226 
227  virtual void close() = 0;
228 
229  /** To obtains the mistake for use discrete values when the movement
230  * is expressed in radians. Parameters are the absolute position in
231  * radians and the axis desired
232  */
233 
234  virtual double radError(char axis, double nRadMoved) = 0;
235 
236  /** To obtain the discrete value for a number of radians */
237 
238  virtual long radToPos(char axis, double nRad) = 0;
239 
240  /** To obtain the number of radians for a discrete value */
241 
242  virtual double posToRad(char axis, long nPos) = 0;
243 
244  /** Performs a scan in the axis indicated and whit the precision desired.
245  * \param <axis> {Pan or Till}
246  * \param <tWait> {Wait time betwen commands}
247  * \param <initial> {initial position}
248  * \param <final> {final position}
249  * \param <RadPre> {radians precision for the scan}
250  */
251 
252  virtual bool scan(
253  char axis, int wait, float initial, float final, double RadPre) = 0;
254 
255  /** Query verbose mode */
256 
257  virtual bool verboseQ(bool& modo) = 0;
258 
259  /** Set verbose. \n
260  * \conde
261  * Example of response with FV (verbose) active:
262  * FV *
263  * PP * Current pan position is 0
264  * Example of response with FT (terse) active:
265  * FT *
266  * PP * 0
267  * \endcode
268  */
269 
270  virtual bool verbose(bool set) = 0;
271 
272  /** Query echo mode */
273 
274  virtual bool echoModeQ(bool& mode) = 0;
275 
276  /** Enable/Disable echo response with command. \n
277  * \code
278  * Example of use (EE supposed):
279  * PP * 22
280  * ED *
281  * <pp entered again, but not echoed>* 22
282  * \endcode
283  */
284 
285  virtual bool echoMode(bool mode) = 0;
286 
287  /** Query the pan and tilt resolution per position moved
288  * and initialize local atributes
289  */
290 
291  virtual bool resolution(void) = 0;
292 
293  /*************************** Methods for internal use ****************/
294 
295  private:
296  /** To transmition commands to the PTU */
297 
298  virtual bool transmit(const char* command) = 0;
299 
300  /** To receive the responseof the PTU */
301 
302  virtual bool receive(const char* command, char* response) = 0;
303 
304  /** Used to obtains a number of radians */
305 
306  virtual bool radQuerry(char axis, char command, double& nRad) = 0;
307 
308  /** Method used for asign a number of radians with a command */
309 
310  virtual bool radAsign(char axis, char command, double nRad) = 0;
311 
312 }; // End of class
313 
314 }
315 #endif
316 
317 
virtual bool upperSpeedQ(char axis, double &RadSec)=0
Query velocity upper limit.
virtual bool absPosQ(char axis, double &nRad)=0
Query position in absolute terms.
virtual bool aceleration(char axis, double RadSec2)=0
Specification (de/a)celeration in turn.
virtual bool enableLimits(bool set)=0
Enable/Disable movement limits.
virtual bool save(void)=0
Save or restart default values.
virtual ~CPtuBase()
Destructor.
Definition: CPtuBase.h:36
virtual bool lowerSpeedQ(char axis, double &RadSec)=0
Query velocity lower limit.
A communications serial port built as an implementation of a utils::CStream.
Definition: CSerialPort.h:41
virtual bool verbose(bool set)=0
Set verbose.
mrpt::comms::CSerialPort serPort
Definition: CPtuBase.h:29
virtual bool verboseQ(bool &modo)=0
Query verbose mode.
virtual bool inmediateExecution(bool set)=0
With I mode (default) instructs pan-tilt unit to immediately execute positional commands.
virtual bool scan(char axis, int wait, float initial, float final, double RadPre)=0
Performs a scan in the axis indicated and whit the precision desired.
This class implements initialization and comunication methods to control a generic Pan and Tilt Unit...
Definition: CPtuBase.h:21
virtual bool resolution(void)=0
Query the pan and tilt resolution per position moved and initialize local atributes.
virtual bool echoMode(bool mode)=0
Enable/Disable echo response with command.
Contains classes for various device interfaces.
virtual bool upperSpeed(char axis, double RadSec)=0
Specification of velocity upper limit.
virtual bool aWait(void)=0
Wait the finish of the last position command to continue accept commands.
virtual bool restoreDefaults(void)=0
Restore default values.
virtual bool moveToAbsPos(char axis, double nRad)=0
Specification of positions in absolute terms.
virtual bool restoreFactoryDefaults(void)=0
Restore factory default values.
virtual bool init(const std::string &port)=0
PTU and serial port initialization.
virtual bool moveToOffPos(char axis, double nRad)=0
Specify desired axis position as an offset from the current position.
virtual void close()=0
Close Connection with serial port.
virtual bool maxPosQ(char axis, double &nRad)=0
Query max movement limit of a axis in absolute terms.
virtual bool minPosQ(char axis, double &nRad)=0
Query min movement limit of a axis in absolute terms.
virtual double status(double &rad)=0
Check if ptu is moving.
virtual bool powerMode(bool transit, char mode)=0
Specification of power mode.
virtual bool setLimits(char axis, double &l, double &u)=0
Set limits of movement.
virtual bool changeMotionDir()=0
virtual bool baseSpeedQ(char axis, double &RadSec)=0
Query velocity to which start and finish the (de/a)celeration.
virtual double radError(char axis, double nRadMoved)=0
To obtains the mistake for use discrete values when the movement is expressed in radians.
virtual int checkErrors()=0
Check errors, returns 0 if there are not errors or error code otherwise.
virtual bool radQuerry(char axis, char command, double &nRad)=0
Used to obtains a number of radians.
virtual bool acelerationQ(char axis, double &RadSec2)=0
Query (de/a)celeration in turn.
GLsizei const GLchar ** string
Definition: glext.h:4101
GLint mode
Definition: glext.h:5669
virtual void clearErrors()=0
Clear errors.
virtual bool reset(void)=0
Reset PTU to initial state.
virtual bool powerModeQ(bool transit, char &mode)=0
Query power mode.
virtual bool rangeMeasure()=0
Search limit forward.
virtual bool halt(char axis)=0
Inmediately stop.
virtual bool transmit(const char *command)=0
To transmition commands to the PTU.
virtual bool haltAll()=0
Inmediately stop all.
virtual bool speedQ(char axis, double &RadSec)=0
Query turn speed.
virtual bool offPosQ(char axis, double &nRad)=0
Query position in relative terms.
virtual double posToRad(char axis, long nPos)=0
To obtain the number of radians for a discrete value.
virtual bool enableLimitsQ(bool &enable)=0
Query if exist movement limits.
virtual long radToPos(char axis, double nRad)=0
To obtain the discrete value for a number of radians.
virtual bool receive(const char *command, char *response)=0
To receive the responseof the PTU.
virtual bool lowerSpeed(char axis, double RadSec)=0
Specification of velocity lower limit.
virtual void nversion(double &nVersion)=0
Number of version.
virtual bool baseSpeed(char axis, double RadSec)=0
Specification of velocity to which start and finish the (de/a)celeration.
virtual bool version(char *nVersion)=0
Version and CopyRights.
virtual bool radAsign(char axis, char command, double nRad)=0
Method used for asign a number of radians with a command.
virtual bool speed(char axis, double RadSec)=0
Specification of turn speed.
virtual bool echoModeQ(bool &mode)=0
Query echo mode.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020