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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020