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