PTUFree.h
Go to the documentation of this file.
1 #ifndef __PTU_FREE_INCLUDED__
2 #define __PTU_FREE_INCLUDED__
3 //#include <serial/serial.h>
4 //#include "ros/ros.h"
5 //#include <boost/asio/io_service.hpp>
6 //#include <boost/asio/serial_port.hpp>
7 #include <boost/asio.hpp>
8 #include <boost/lexical_cast.hpp>
9 #include <vector>
10 #include "limits.h"
11 
12 #define ERROR LONG_MIN
13 #define DISABLED ( LONG_MIN + 1 )
14 #define ENABELED ( LONG_MIN + 2 )
15 #define FACTORY_LIMITS_ENABLED ( LONG_MIN + 3 )
16 #define USER_DEFINED_LIMITS_ENABLED ( LONG_MIN + 4 )
17 #define LIMITS_DISABLED ( LONG_MIN + 5 )
18 #define USER_DEFINED_PAN_LIMIT_ENABLED ( LONG_MIN + 6 )
19 #define IMMEDIATE_POSITION_EXECUTION_MODE ( LONG_MIN + 7 )
20 #define SLAVED_POSITION_EXECUTION_MODE ( LONG_MIN + 8 )
21 #define HALT_PAN_ONLY ( LONG_MIN + 9 )
22 #define HALT_TILT_ONLY ( LONG_MIN + 10 )
23 #define HALT_BOTH ( LONG_MIN + 11 )
24 #define INDEPENDENT_SPEED_MODE ( LONG_MIN + 12 )
25 #define PURE_VELOCITY_CONTROL_MODE ( LONG_MIN + 13 )
26 #define NO_RESET_MODE ( LONG_MIN + 14 )
27 #define PAN_ONLY_RESET_MODE ( LONG_MIN + 15 )
28 #define TILT_ONLY_RESET_MODE ( LONG_MIN + 16 )
29 #define BOTH_RESET_MODE ( LONG_MIN + 17 )
30 #define REGULAR_HOLD_POWER_MODE ( LONG_MIN + 18 )
31 #define LOW_HOLD_POWER_MODE ( LONG_MIN + 19 )
32 #define OFF_HOLD_POWER_MODE ( LONG_MIN + 20 )
33 #define HIGH_MOVE_POWER_MODE ( LONG_MIN + 21 )
34 #define REGULAR_MOVE_POWER_MODE ( LONG_MIN + 22 )
35 #define LOW_MOVE_POWER_MODE ( LONG_MIN + 23 )
36 
37 #define ERROR_CODES_BELOW ( LONG_MIN + 24)
38 
39 
40 
41 
42 namespace ptu_free {
46  class PTUFree {
47  public:
48 
52  PTUFree();
53 
58  PTUFree(boost::asio::io_service& io);
59 
65  bool setBaudRate(int baud);
66 
73  bool setNewSerialConnection(std::string port, int baud);
74 
78  void closeSerialConnection();
79 
85  std::string communicate(std::string request);
86 
91  std::string readPTUResponse();
92 
100  std::vector<std::string> evaluateResponse(std::string response);
101 
107  bool setDesiredPanPositionAbsolute(short int position);
108 
114  bool setDesiredPanPositionRelative(short int position_offset);
115 
121  bool setDesiredPanSpeedAbsolute(short int speed);
122 
128  bool setDesiredPanSpeedRelative(short int speed_offset);
134  bool setDesiredPanAccelerationAbsolute(short int acceleration);
140  bool setDesiredPanUpperSpeedLimit(short int upper_speed_limit);
146  bool setDesiredPanLowerSpeedLimit(short int lower_speed_limit);
152  bool setPanBaseSpeed(short int base_speed);
157  long getCurrentPanPosition();
162  long getCurrentPanSpeed();
167  long getPanUpperSpeedLimit();
172  long getPanLowerSpeedLimit();
177  double getPanResolution();
182  long getDesiredPanPosition();
187  long getDesiredPanSpeed();
192  long getPanAcceleartion();
197  long getPanBaseSpeed();
203  bool setDesiredTiltPositionAbsolute(short int position);
204 
210  bool setDesiredTiltPositionRelative(short int position_offset);
211 
217  bool setDesiredTiltSpeedAbsolute(short int speed);
218 
224  bool setDesiredTiltSpeedRelative(short int speed_offset);
230  bool setDesiredTiltAccelerationAbsolute(short int acceleration);
236  bool setDesiredTiltUpperSpeedLimit(short int upper_speed_limit);
242  bool setDesiredTiltLowerSpeedLimit(short int lower_speed_limit);
248  bool setTiltBaseSpeed(short int base_speed);
253  long getCurrentTiltPosition();
258  long getCurrentTiltSpeed();
263  long getTiltUpperSpeedLimit();
268  long getTiltLowerSpeedLimit();
273  double getTiltResolution();
278  long getDesiredTiltPosition();
283  long getDesiredTiltSpeed();
288  long getTiltAcceleartion();
293  long getTiltBaseSpeed();
294 
300  bool setPositionLimitEnforcementMode(long enable);
301 
307  bool setMinimumPanPositionLimit(short int position);
308 
314  bool setMaximumPanPositionLimit(short int position);
315 
321  bool setMinimumTiltPositionLimit(short int position);
322 
328  bool setMaximumTiltPositionLimit(short int position);
329 
335 
341 
347 
353 
359 
365 
371 
377 
383 
389 
395 
401 
407 
413  bool setPositionExecutionMode(long mode);
414 
420 
426 
432  bool halt(long axis);
433 
440  bool setDesiredPanTiltPositionAbsoluteSlaved(short int pan, short int tilt);
441 
449  bool setPreset(int preset_index, short int pan, short int tilt);
450 
456  bool setPreset(int preset_index);
457 
463  bool gotoPreset(int preset_index);
464 
469  bool clearPreset();
470 
476  bool setSpeedControlMode(long mode);
477 
482  long getSpeedControlMode();
483 
488  bool reset();
489 
495  bool setResetMode(long mode);
496 
502  bool saveDefault();
503 
508  bool restoreDefault();
509 
514  bool restoreFactoryDefault();
515 
521  bool setPanStationaryPowerMode(long mode);
522 
528  bool setTiltStationaryPowerMode(long mode);
529 
535 
541 
547  bool setPanInMotionPowerMode(long mode);
548 
554  bool setTiltInMotionPowerMode(long mode);
555 
561 
567 
571  void test();
572 
577  bool isOpen();
578 
579  private:
580  boost::asio::io_service ptu_io_service;
581  boost::asio::io_service timer_io_service;
582  boost::asio::serial_port ptu_port;
589  std::string getErrorString(boost::system::error_code error);
590  };
591 }
592 #endif
long getFactoryMaximumPanPositionLimit()
getFactoryMaximumPanPositionLimit Method to get the factory defined maximum pan position.
Definition: PTUFree.cpp:744
void test()
test Method to test the methods of this program, for DEBUG/DEVELOPMENT purpose, changes PTU settings ...
Definition: PTUFree.cpp:1633
long getCurrentPanSpeed()
getCurrentPanSpeed Method that queries the current pan speed
Definition: PTUFree.cpp:265
bool setDesiredTiltUpperSpeedLimit(short int upper_speed_limit)
setDesiredTiltUpperSpeedLimit Method that sets the upper speed limit for tilt (position/second). WARNING: Takes extremly long or does not work on every ptu
Definition: PTUFree.cpp:444
bool setDesiredPanSpeedAbsolute(short int speed)
setDesiredPanSpeedAbsolute Method that sets absolute pan speed (position/second)
Definition: PTUFree.cpp:165
bool setDesiredTiltPositionRelative(short int position_offset)
setDesiredTiltPositionRelative Method that sets current tilt position by offset (current pos + offset...
Definition: PTUFree.cpp:388
long getUserMinimumTiltPositionLimit()
getUserMinimumTiltPositionLimit Method to get the user defined minimum tilt position. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:714
long getCurrentUsedMaximumTiltPositionLimit()
getCurrentUsedMaximumTiltPositionLimit Method to get the currently used maximum tilt position...
Definition: PTUFree.cpp:789
long getSpeedControlMode()
getSpeedControlMode Method to get the currently used sped control mode of the ptu.
Definition: PTUFree.cpp:1020
long getDesiredTiltSpeed()
getDesiredTiltSpeed Method that queries the desired tilt speed
Definition: PTUFree.cpp:569
bool setResetMode(long mode)
setResetMode Method to set the reset mode of the ptu. Saved to EEPROM, do not use too often...
Definition: PTUFree.cpp:1052
double getTiltResolution()
getTiltResolution Method that queries the tilt resolution (seconds/arc per position). Divide by 3600 to get Degree.
Definition: PTUFree.cpp:543
bool setDesiredTiltPositionAbsolute(short int position)
setDesiredTiltPositionAbsolute Method that sets absolute tilt position
Definition: PTUFree.cpp:375
bool setDesiredPanLowerSpeedLimit(short int lower_speed_limit)
setDesiredPanLowerSpeedLimit Method that sets the lower speed limit for pan (position/second). WARNING: Takes extremly long or does not work on every ptu
Definition: PTUFree.cpp:224
long getCurrentUsedMinimumPanPositionLimit()
getCurrentUsedMinimumPanPositionLimit Method to get the currently used minimum pan position...
Definition: PTUFree.cpp:753
std::string readPTUResponse()
readPTUResponse Method that reads from the PTU until delimitor (&#39; &#39;) appears. Then the read data is r...
Definition: PTUFree.cpp:79
long getFactoryMaximumTiltPositionLimit()
getFactoryMaximumTiltPositionLimit Method to get the factory defined maximum tilt position...
Definition: PTUFree.cpp:750
long getTiltAcceleartion()
getTiltAcceleartion Method that queries the tilt acceleration (no current or desired here) ...
Definition: PTUFree.cpp:582
long getPanInMotionPowerMode()
getPanInMotionPowerMode Method to get the move power mode for pan axis.
Definition: PTUFree.cpp:1264
void closeSerialConnection()
closeSerialConnection Closes currently used serial port
Definition: PTUFree.cpp:67
bool isOpen()
isOpen Method to determine if used port is open or closed.
Definition: PTUFree.cpp:2401
long factory_pan_max
Definition: PTUFree.h:585
long factory_tilt_max
Definition: PTUFree.h:587
long getCurrentTiltSpeed()
getCurrentTiltSpeed Method that queries the current tilt speed
Definition: PTUFree.cpp:501
bool setTiltBaseSpeed(short int base_speed)
setTiltBaseSpeed Method that sets the base speed for tilt (position/second)
Definition: PTUFree.cpp:473
long getTiltUpperSpeedLimit()
getTiltUpperSpeedLimit Method that queries the tilt upper speed limit WARNING: This Method consumes e...
Definition: PTUFree.cpp:517
long getUserMaximumTiltPositionLimit()
getUserMaximumTiltPositionLimit Method to get the user defined maximum tilt position. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:728
std::string getErrorString(boost::system::error_code error)
Definition: PTUFree.cpp:1305
long getCurrentUsedMinimumTiltPositionLimit()
getCurrentUsedMinimumTiltPositionLimit Method to get the currently used minimum tilt position...
Definition: PTUFree.cpp:777
long getDesiredPanSpeed()
getDesiredPanSpeed Method that queries the desired pan speed
Definition: PTUFree.cpp:333
long getUserMaximumPanPositionLimit()
getUserMaximumPanPositionLimit Method to get the user defined maximum pan position. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:700
bool setDesiredPanUpperSpeedLimit(short int upper_speed_limit)
setDesiredPanUpperSpeedLimit Method that sets the upper speed limit for pan (position/second). WARNING: Takes extremly long or does not work on every ptu
Definition: PTUFree.cpp:208
bool setNewSerialConnection(std::string port, int baud)
setNewSerialConnection Establishes a new connection via serial port specified by &#39;port&#39; to a target d...
Definition: PTUFree.cpp:27
bool setPanStationaryPowerMode(long mode)
setPanStationaryPowerMode Method to set the stationary power mode for pan axis.
Definition: PTUFree.cpp:1120
PTUFree()
PTUFree Constructor for PTUFree object. Not connected to any port.
Definition: PTUFree.cpp:5
long getTiltStationaryPowerMode()
getTiltStationaryPowerMode Method to get the stationary power mode for tilt axis. ...
Definition: PTUFree.cpp:1192
bool setDesiredPanAccelerationAbsolute(short int acceleration)
setDesiredPanAccelerationAbsolute Method that sets the absolute pan acceleration (position/second^2) ...
Definition: PTUFree.cpp:193
long getFactoryMinimumTiltPositionLimit()
getFactoryMinimumTiltPositionLimit Method to get the factory defined minimum tilt position...
Definition: PTUFree.cpp:747
long getPositionLimitEnforcementMode()
getPositionLimitEnforcementMode Method to get the currently used position limit enforcement mode...
Definition: PTUFree.cpp:804
bool setMaximumPanPositionLimit(short int position)
setMaximumPanPositionLimit Method that is used to set a user defined maximum pan position limit...
Definition: PTUFree.cpp:648
std::vector< std::string > evaluateResponse(std::string response)
evaluateResponse Method that preprocesses the answer of the PTU. Splits the PTU to a maximum of 3 par...
Definition: PTUFree.cpp:99
std::string communicate(std::string request)
communicate Method to send a command &#39;request&#39; to the serial port (and the device) and recieve the an...
Definition: PTUFree.cpp:71
long factory_pan_min
Definition: PTUFree.h:584
bool clearPreset()
clearPreset Method to delete all existing presets. WARNING: Does not work on older PTUs and is not te...
Definition: PTUFree.cpp:983
bool setDesiredTiltSpeedRelative(short int speed_offset)
setDesiredTiltSpeedRelative Method that sets the desired tilt speed relative to the CURRENT (not the ...
Definition: PTUFree.cpp:416
bool setDesiredTiltAccelerationAbsolute(short int acceleration)
setDesiredTiltAccelerationAbsolute Method that sets the absolute tilt acceleration (position/second^2...
Definition: PTUFree.cpp:429
bool setPreset(int preset_index, short int pan, short int tilt)
setPreset Method that allows to associate a pan and tilt position with a preset index. Moves to the pan and tilt position and saves the position as a preset. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:936
bool setDesiredPanPositionRelative(short int position_offset)
setDesiredPanPositionRelative Method that sets current pan position by offset (current pos + offset =...
Definition: PTUFree.cpp:152
bool setPanBaseSpeed(short int base_speed)
setPanBaseSpeed Method that sets the base speed for pan (position/second)
Definition: PTUFree.cpp:237
bool setPositionExecutionMode(long mode)
setPositionExecutionMode Method to set the position execution mode.
Definition: PTUFree.cpp:825
long getTiltInMotionPowerMode()
getTiltInMotionPowerMode Method to get the move power mode for tilt axis.
Definition: PTUFree.cpp:1284
long getPanLowerSpeedLimit()
getPanLowerSpeedLimit Method that queries the pan lower speed limit. WARNING: This Method consumes ei...
Definition: PTUFree.cpp:294
bool setSpeedControlMode(long mode)
setSpeedControlMode Method to set the sped control mode of the ptu.
Definition: PTUFree.cpp:996
long getPanAcceleartion()
getPanAcceleartion Method that queries the pan acceleration (no current or desired here) ...
Definition: PTUFree.cpp:346
bool setMinimumPanPositionLimit(short int position)
setMinimumPanPositionLimit Method that is used to set a user defined minimum pan position limit...
Definition: PTUFree.cpp:636
bool gotoPreset(int preset_index)
gotoPreset Method that moves the ptu to a existing preset of pan and tilt corrdiantes. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:969
long getPanUpperSpeedLimit()
getPanUpperSpeedLimit Method that queries the pan upper speed limit WARNING: This Method consumes eit...
Definition: PTUFree.cpp:281
long position_execution_mode
Definition: PTUFree.h:588
long getTiltBaseSpeed()
getTiltBaseSpeed Returns the current tilt base speed
Definition: PTUFree.cpp:595
long getDesiredPanPosition()
getDesiredPanPosition Method that queries the desired pan position
Definition: PTUFree.cpp:320
boost::asio::io_service timer_io_service
Definition: PTUFree.h:581
long getCurrentPanPosition()
getCurrentPanPosition Method that queries the current pan position
Definition: PTUFree.cpp:252
bool setDesiredPanSpeedRelative(short int speed_offset)
setDesiredPanSpeedRelative Method that sets the desired pan speed relative to the CURRENT (not the de...
Definition: PTUFree.cpp:180
bool halt(long axis)
halt Method that halts movement on specified axis.
Definition: PTUFree.cpp:872
bool restoreFactoryDefault()
restoreFactoryDefault Method to set default settings to factory defaults. Saved to EEPROM...
Definition: PTUFree.cpp:1107
double getPanResolution()
getPanResolution Method that queries the pan resolution (seconds/arc per position). Divide by 3600 to get Degree.
Definition: PTUFree.cpp:307
long getPanBaseSpeed()
getPanBaseSpeed Returns the current pan base speed
Definition: PTUFree.cpp:359
bool awaitPositionCommandCompletion()
awaitPositionCommandCompletion Method to wait for the completion of the last issued pan and tilt posi...
Definition: PTUFree.cpp:859
bool restoreDefault()
restoreDefault Method to restore default settings. WARNING: Not tested.
Definition: PTUFree.cpp:1094
long getPanStationaryPowerMode()
getPanStationaryPowerMode Method to get the stationary power mode for pan axis.
Definition: PTUFree.cpp:1172
long getTiltLowerSpeedLimit()
getTiltLowerSpeedLimit Method that queries the tilt lower speed limit. WARNING: This Method consumes ...
Definition: PTUFree.cpp:530
bool setDesiredPanTiltPositionAbsoluteSlaved(short int pan, short int tilt)
setDesiredPanTiltPositionAbsoluteSlaved Method that allows a movement of pan and tilt axis to specifi...
Definition: PTUFree.cpp:900
long getFactoryMinimumPanPositionLimit()
getFactoryMinimumPanPositionLimit Method to get the factory defined minimum pan position.
Definition: PTUFree.cpp:741
bool setBaudRate(int baud)
setBaudRate Sets the baud rate for the serial port that is used. Only use of serial connection is est...
Definition: PTUFree.cpp:12
long getCurrentUsedMaximumPanPositionLimit()
getCurrentUsedMaximumPanPositionLimit Method to get the currently used maximum pan position...
Definition: PTUFree.cpp:765
bool setMinimumTiltPositionLimit(short int position)
setMinimumTiltPositionLimit Method that is used to set a user defined minimum tilt position limit...
Definition: PTUFree.cpp:660
boost::asio::io_service ptu_io_service
Definition: PTUFree.h:580
bool setPositionLimitEnforcementMode(long enable)
setPositionLimitEnforcementMode Method to set the position limit enforcement mode. Warning: USER_DEFINED_LIMITS_ENABLED does not work on older PTUs and setting of this value is not tested.
Definition: PTUFree.cpp:610
bool timeout_occured
Definition: PTUFree.h:583
bool setDesiredPanPositionAbsolute(short int position)
setDesiredPanPositionAbsolute Method that sets absolute pan position
Definition: PTUFree.cpp:139
bool saveDefault()
saveDefault Method to save the current axis settings as default at power up. Note: This class sets th...
Definition: PTUFree.cpp:1081
bool setDesiredTiltLowerSpeedLimit(short int lower_speed_limit)
setDesiredTiltLowerSpeedLimit Method that sets the lower speed limit for tilt (position/second). WARNING: Takes extremly long or does not work on every ptu
Definition: PTUFree.cpp:460
boost::asio::serial_port ptu_port
Definition: PTUFree.h:582
bool setTiltStationaryPowerMode(long mode)
setTiltStationaryPowerMode Method to set the stationary power mode for tilt axis. ...
Definition: PTUFree.cpp:1146
bool setMaximumTiltPositionLimit(short int position)
setMaximumTiltPositionLimit Method that is used to set a user defined maximum tilt position limit...
Definition: PTUFree.cpp:672
bool setTiltInMotionPowerMode(long mode)
setTiltInMotionPowerMode Method to set the move power mode for tilt axis.
Definition: PTUFree.cpp:1238
bool reset()
reset Method to reset the ptu (pan and/or tilt axis depending on reset mode)
Definition: PTUFree.cpp:1038
long factory_tilt_min
Definition: PTUFree.h:586
long getCurrentTiltPosition()
getCurrentTiltPosition Method that queries the current tilt position
Definition: PTUFree.cpp:488
long getUserMinimumPanPositionLimit()
getUserMinimumPanPositionLimit Method to get the user defined minimum pan position. WARNING: Does not work on older PTUs and is not tested.
Definition: PTUFree.cpp:686
bool setDesiredTiltSpeedAbsolute(short int speed)
setDesiredTiltSpeedAbsolute Method that sets absolute tilt speed (position/second) ...
Definition: PTUFree.cpp:401
bool setPanInMotionPowerMode(long mode)
setPanInMotionPowerMode Method to set the move power mode for pan axis.
Definition: PTUFree.cpp:1213
long getDesiredTiltPosition()
getDesiredTiltPosition Method that queries the desired tilt position
Definition: PTUFree.cpp:556
long getPositionExecutionMode()
getPositionExecutionMode Method to get the currently used position execution mode. Can return IMMEDIATE_POSITION_EXECUTION_MODE or SLAVED_POSITION_EXECUTION_MODE.
Definition: PTUFree.cpp:854


asr_flir_ptu_driver
Author(s): Valerij Wittenbeck, Joachim Gehrung, Pascal Mei├čner, Patrick Schlosser
autogenerated on Mon Dec 2 2019 03:15:17