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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST