Main MRPT website > C++ reference for MRPT 1.5.5
List of all members | Public Types | Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions
mrpt::hwdrivers::CPtuDPerception Class Reference

Detailed Description

This class implements initialization and comunication methods to control a Pan and Tilt Unit model PTU-46-17.5, working in radians .

Definition at line 24 of file CPtuDPerception.h.

#include <mrpt/hwdrivers/CPtuDPerception.h>

Inheritance diagram for mrpt::hwdrivers::CPtuDPerception:
Inheritance graph

Public Types

enum  {
  NoError = 1, ComError = 2, TimeoutError = 3, InitError = 5,
  PanHitError = 7, TiltHitError = 11, PanTiltHitError =13, MaxLimitError = 17,
  MinLimitError = 19, OutOfRange = 23, IllegalCommandError = 29, UnExpectedError =31
}
 
enum  { Pan = 'P', Tilt = 'T' }
 
enum  { Regular = 'R', High = 'H', Low = 'L', Off = 'O' }
 
enum  { Com1 = 1, Com2 = 2, Com3 = 3, Com4 = 4 }
 

Public Member Functions

 CPtuDPerception ()
 Default constructor. More...
 
virtual ~CPtuDPerception ()
 Destructor. More...
 
virtual bool rangeMeasure ()
 Search limit forward. More...
 
virtual bool moveToAbsPos (char axis, double nRad)
 Specification of positions in absolute terms. More...
 
virtual bool absPosQ (char axis, double &nRad)
 Query position in absolute terms. More...
 
virtual bool moveToOffPos (char axis, double nRad)
 Specify desired axis position as an offset from the current position. More...
 
virtual bool offPosQ (char axis, double &nRad)
 Query position in relative terms. More...
 
virtual bool maxPosQ (char axis, double &nRad)
 Query max movement limit of a axis in absolute terms. More...
 
virtual bool minPosQ (char axis, double &nRad)
 Query min movement limit of a axis in absolute terms. More...
 
virtual bool enableLimitsQ (bool &enable)
 Query if exist movement limits. More...
 
virtual bool enableLimits (bool set)
 Enable/Disable movement limits. More...
 
virtual bool inmediateExecution (bool set)
 With I mode (default) instructs pan-tilt unit to immediately execute positional commands. More...
 
virtual bool aWait (void)
 Wait the finish of the last position command to continue accept commands. More...
 
virtual bool haltAll ()
 Inmediately stop all. More...
 
virtual bool halt (char axis)
 Inmediately stop. More...
 
virtual bool speed (char axis, double radSec)
 Specification of turn speed. More...
 
virtual bool speedQ (char axis, double &radSec)
 Query turn speed. More...
 
virtual bool aceleration (char axis, double radSec2)
 Specification (de/a)celeration in turn. More...
 
virtual bool acelerationQ (char axis, double &radSec2)
 Query (de/a)celeration in turn. More...
 
virtual bool baseSpeed (char axis, double radSec)
 Specification of velocity to which start and finish the (de/a)celeration. More...
 
virtual bool baseSpeedQ (char axis, double &radSec)
 Query velocity to which start and finish the (de/a)celeration. More...
 
virtual bool upperSpeed (char axis, double radSec)
 Specification of velocity upper limit. More...
 
virtual bool upperSpeedQ (char axis, double &radSec)
 Query velocity upper limit. More...
 
virtual bool lowerSpeed (char axis, double radSec)
 Specification of velocity lower limit. More...
 
virtual bool lowerSpeedQ (char axis, double &radSec)
 Query velocity lower limit. More...
 
virtual bool reset (void)
 Reset PTU to initial state. More...
 
virtual bool save (void)
 Save or restart default values. More...
 
virtual bool restoreDefaults (void)
 Restore default values. More...
 
virtual bool restoreFactoryDefaults (void)
 Restore factory default values. More...
 
virtual bool version (char *nVersion)
 Version and CopyRights. More...
 
virtual void nversion (double &nVersion)
 Number of version. More...
 
virtual bool powerModeQ (bool transit, char &mode)
 Query power mode. More...
 
virtual bool powerMode (bool transit, char mode)
 Specification of power mode. More...
 
virtual double status (double &rad)
 Check if ptu is moving. More...
 
virtual bool setLimits (char axis, double &l, double &u)
 Set limits of movement. More...
 
virtual bool changeMotionDir ()
 
virtual int checkErrors ()
 Check errors, returns 0 if there are not errors or error code in otherwise Error codes: More...
 
bool noError ()
 
bool comError ()
 
bool timeoutError ()
 
bool initError ()
 
bool panTiltHitError ()
 
bool panHitError ()
 
bool tiltHitError ()
 
bool maxLimitError ()
 
bool minLimitError ()
 
bool outOfRange ()
 
bool illegalCommandError ()
 
bool unExpectedError ()
 
virtual void clearErrors ()
 Clear errors. More...
 
virtual bool init (const std::string &port)
 PTU and serial port initialization. More...
 
virtual void close ()
 Close Connection with serial port. More...
 
virtual double radError (char axis, double nRadMoved)
 To obtains the mistake for use discrete values when the movement is expressed in radians. More...
 
virtual long radToPos (char axis, double nRad)
 To obtain the discrete value for a number of radians. More...
 
virtual double posToRad (char axis, long nPos)
 To obtain the number of radians for a discrete value. More...
 
virtual bool scan (char axis, int wait, float initial, float final, double radPre)
 Performs a scan in the axis indicated and whit the precision desired. More...
 
virtual bool verboseQ (bool &modo)
 Query verbose mode. More...
 
virtual bool verbose (bool set)
 Set verbose. More...
 
virtual bool echoModeQ (bool &mode)
 Query echo mode. More...
 
virtual bool echoMode (bool mode)
 Enable/Disable echo response with command. More...
 
virtual bool resolution (void)
 Query the pan and tilt resolution per position moved and initialize local atributes. More...
 

Public Attributes

int nError
 TimeoutError: Only occurs if the communication is cut with PTU so it is advisable to check the connection and initialize again the comunication. More...
 
double tiltResolution
 
double panResolution
 

Protected Attributes

CSerialPort serPort
 

Private Member Functions

virtual bool transmit (const char *command)
 To transmition commands to the PTU. More...
 
virtual bool receive (const char *command, char *response)
 To receive the responseof the PTU. More...
 
virtual bool radQuerry (char axis, char command, double &nRad)
 Used to obtains a number of radians. More...
 
virtual bool radAsign (char axis, char command, double nRad)
 Method used for asign a number of radians with a command. More...
 
virtual double convertToDouble (char *sDouble)
 Convert string to double. More...
 
virtual long convertToLong (char *sLong)
 Convert string to long. More...
 

Member Enumeration Documentation

anonymous enum
Enumerator
NoError 
ComError 
TimeoutError 
InitError 
PanHitError 
TiltHitError 
PanTiltHitError 
MaxLimitError 
MinLimitError 
OutOfRange 
IllegalCommandError 
UnExpectedError 

Definition at line 362 of file CPtuDPerception.h.

anonymous enum
Enumerator
Pan 
Tilt 

Definition at line 374 of file CPtuDPerception.h.

anonymous enum
Enumerator
Regular 
High 
Low 
Off 

Definition at line 375 of file CPtuDPerception.h.

anonymous enum
Enumerator
Com1 
Com2 
Com3 
Com4 

Definition at line 376 of file CPtuDPerception.h.

Constructor & Destructor Documentation

mrpt::hwdrivers::CPtuDPerception::CPtuDPerception ( )
inline

Default constructor.

Definition at line 31 of file CPtuDPerception.h.

virtual mrpt::hwdrivers::CPtuDPerception::~CPtuDPerception ( )
inlinevirtual

Destructor.

Definition at line 35 of file CPtuDPerception.h.

Member Function Documentation

bool CPtuDPerception::absPosQ ( char  axis,
double &  nRad 
)
virtual

Query position in absolute terms.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 40 of file CPtuDPerception.cpp.

bool CPtuDPerception::aceleration ( char  axis,
double  radSec2 
)
virtual

Specification (de/a)celeration in turn.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 111 of file CPtuDPerception.cpp.

bool CPtuDPerception::acelerationQ ( char  axis,
double &  radSec2 
)
virtual

Query (de/a)celeration in turn.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 121 of file CPtuDPerception.cpp.

bool CPtuDPerception::aWait ( void  )
virtual

Wait the finish of the last position command to continue accept commands.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 229 of file CPtuDPerception.cpp.

bool CPtuDPerception::baseSpeed ( char  axis,
double  radSec 
)
virtual

Specification of velocity to which start and finish the (de/a)celeration.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 131 of file CPtuDPerception.cpp.

bool CPtuDPerception::baseSpeedQ ( char  axis,
double &  radSec 
)
virtual

Query velocity to which start and finish the (de/a)celeration.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 140 of file CPtuDPerception.cpp.

bool CPtuDPerception::changeMotionDir ( )
virtual

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 802 of file CPtuDPerception.cpp.

int CPtuDPerception::checkErrors ( )
virtual

Check errors, returns 0 if there are not errors or error code in otherwise Error codes:

1: Com error
2: Time out error
3: Init error
4: Pan tilt hit error
5: Pan hit error
6: Tilt hit error
7: Max limit error
8: Min limit error
9: Out of range
10: Illegal command error
11: Unexpected error

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 741 of file CPtuDPerception.cpp.

virtual void mrpt::hwdrivers::CPtuDPerception::clearErrors ( )
inlinevirtual

Clear errors.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 251 of file CPtuDPerception.h.

void CPtuDPerception::close ( )
virtual

Close Connection with serial port.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 416 of file CPtuDPerception.cpp.

bool mrpt::hwdrivers::CPtuDPerception::comError ( )
inline

Definition at line 237 of file CPtuDPerception.h.

References ComError.

double CPtuDPerception::convertToDouble ( char *  sDouble)
privatevirtual

Convert string to double.

Definition at line 728 of file CPtuDPerception.cpp.

long CPtuDPerception::convertToLong ( char *  sLong)
privatevirtual

Convert string to long.

Definition at line 715 of file CPtuDPerception.cpp.

bool CPtuDPerception::echoMode ( bool  mode)
virtual

Enable/Disable echo response with command.


Example of use (EE supposed):
PP * 22
ED *
<pp entered again, but not echoed>* 22

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 553 of file CPtuDPerception.cpp.

bool CPtuDPerception::echoModeQ ( bool &  mode)
virtual

Query echo mode.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 536 of file CPtuDPerception.cpp.

References mrpt::system::upperCase().

bool CPtuDPerception::enableLimits ( bool  set)
virtual

Enable/Disable movement limits.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 206 of file CPtuDPerception.cpp.

bool CPtuDPerception::enableLimitsQ ( bool &  enable)
virtual

Query if exist movement limits.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 189 of file CPtuDPerception.cpp.

References mrpt::system::upperCase().

bool CPtuDPerception::halt ( char  axis)
virtual

Inmediately stop.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 248 of file CPtuDPerception.cpp.

bool CPtuDPerception::haltAll ( )
virtual

Inmediately stop all.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 239 of file CPtuDPerception.cpp.

bool mrpt::hwdrivers::CPtuDPerception::illegalCommandError ( )
inline

Definition at line 246 of file CPtuDPerception.h.

References IllegalCommandError.

bool CPtuDPerception::init ( const std::string port)
virtual

PTU and serial port initialization.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 358 of file CPtuDPerception.cpp.

References RAD2DEG.

bool mrpt::hwdrivers::CPtuDPerception::initError ( )
inline

Definition at line 239 of file CPtuDPerception.h.

References InitError.

bool CPtuDPerception::inmediateExecution ( bool  set)
virtual

With I mode (default) instructs pan-tilt unit to immediately execute positional commands.


In S mode instructs pan-tilt unit to execute positional commands only when an Await Position Command Completion command is executed or when put into Immediate Execution Mode.

Example of use of S mode:
DR *
S *
PP1500 *
TP-900 *
PP * Current Pan position is 0
TP * Current Tilt position is 0
A *
PP * Current Pan position is 1500
TP * Current Tilt position is -900

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 217 of file CPtuDPerception.cpp.

bool CPtuDPerception::lowerSpeed ( char  axis,
double  radSec 
)
virtual

Specification of velocity lower limit.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 169 of file CPtuDPerception.cpp.

bool CPtuDPerception::lowerSpeedQ ( char  axis,
double &  radSec 
)
virtual

Query velocity lower limit.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 179 of file CPtuDPerception.cpp.

bool mrpt::hwdrivers::CPtuDPerception::maxLimitError ( )
inline

Definition at line 243 of file CPtuDPerception.h.

References MaxLimitError.

bool CPtuDPerception::maxPosQ ( char  axis,
double &  nRad 
)
virtual

Query max movement limit of a axis in absolute terms.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 72 of file CPtuDPerception.cpp.

bool mrpt::hwdrivers::CPtuDPerception::minLimitError ( )
inline

Definition at line 244 of file CPtuDPerception.h.

References MinLimitError.

bool CPtuDPerception::minPosQ ( char  axis,
double &  nRad 
)
virtual

Query min movement limit of a axis in absolute terms.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 82 of file CPtuDPerception.cpp.

bool CPtuDPerception::moveToAbsPos ( char  axis,
double  nRad 
)
virtual

Specification of positions in absolute terms.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 28 of file CPtuDPerception.cpp.

bool CPtuDPerception::moveToOffPos ( char  axis,
double  nRad 
)
virtual

Specify desired axis position as an offset from the current position.


This method recives the number of radians to move.

Example of use:
TT-500 *
A *
TO * Current Tilt position is -500
TO500 *
A *
TT * Current Pan position is 1000

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 50 of file CPtuDPerception.cpp.

bool mrpt::hwdrivers::CPtuDPerception::noError ( )
inline

Definition at line 236 of file CPtuDPerception.h.

void CPtuDPerception::nversion ( double &  nVersion)
virtual

Number of version.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 781 of file CPtuDPerception.cpp.

bool CPtuDPerception::offPosQ ( char  axis,
double &  nRad 
)
virtual

Query position in relative terms.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 62 of file CPtuDPerception.cpp.

bool mrpt::hwdrivers::CPtuDPerception::outOfRange ( )
inline

Definition at line 245 of file CPtuDPerception.h.

References OutOfRange.

bool mrpt::hwdrivers::CPtuDPerception::panHitError ( )
inline

Definition at line 241 of file CPtuDPerception.h.

References PanHitError.

bool mrpt::hwdrivers::CPtuDPerception::panTiltHitError ( )
inline

Definition at line 240 of file CPtuDPerception.h.

References PanTiltHitError.

double CPtuDPerception::posToRad ( char  axis,
long  nPos 
)
virtual

To obtain the number of radians for a discrete value.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 704 of file CPtuDPerception.cpp.

bool CPtuDPerception::powerMode ( bool  transit,
char  mode 
)
virtual

Specification of power mode.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 342 of file CPtuDPerception.cpp.

bool CPtuDPerception::powerModeQ ( bool  transit,
char &  mode 
)
virtual

Query power mode.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 314 of file CPtuDPerception.cpp.

References mrpt::system::upperCase().

bool CPtuDPerception::radAsign ( char  axis,
char  command,
double  nRad 
)
privatevirtual

Method used for asign a number of radians with a command.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 604 of file CPtuDPerception.cpp.

References mrpt::system::os::sprintf(), and mrpt::system::os::strcpy().

double CPtuDPerception::radError ( char  axis,
double  nRadMoved 
)
virtual

To obtains the mistake for use discrete values when the movement is expressed in radians.

Parameters are the absolute position in radians and the axis desired

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 426 of file CPtuDPerception.cpp.

bool CPtuDPerception::radQuerry ( char  axis,
char  command,
double &  nRad 
)
privatevirtual

Used to obtains a number of radians.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 582 of file CPtuDPerception.cpp.

References convertToLong().

long CPtuDPerception::radToPos ( char  axis,
double  nRad 
)
virtual

To obtain the discrete value for a number of radians.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 693 of file CPtuDPerception.cpp.

bool CPtuDPerception::rangeMeasure ( )
virtual

Search limit forward.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 812 of file CPtuDPerception.cpp.

bool CPtuDPerception::receive ( const char *  command,
char *  response 
)
privatevirtual

To receive the responseof the PTU.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 464 of file CPtuDPerception.cpp.

References mrpt::system::os::strcpy().

bool CPtuDPerception::reset ( void  )
virtual

Reset PTU to initial state.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 261 of file CPtuDPerception.cpp.

bool CPtuDPerception::resolution ( void  )
virtual

Query the pan and tilt resolution per position moved and initialize local atributes.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 564 of file CPtuDPerception.cpp.

References DEG2RAD.

bool CPtuDPerception::restoreDefaults ( void  )
virtual

Restore default values.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 283 of file CPtuDPerception.cpp.

bool CPtuDPerception::restoreFactoryDefaults ( void  )
virtual

Restore factory default values.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 293 of file CPtuDPerception.cpp.

bool CPtuDPerception::save ( void  )
virtual

Save or restart default values.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 273 of file CPtuDPerception.cpp.

bool CPtuDPerception::scan ( char  axis,
int  wait,
float  initial,
float  final,
double  radPre 
)
virtual

Performs a scan in the axis indicated and whit the precision desired.


Parameters
<axis>{Pan or Till}
<tWait>{Wait time betwen commands}
<initial>{initial position}
<final>{final position}
<radPre>{radians precision for the scan}

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 625 of file CPtuDPerception.cpp.

References mrpt::system::sleep().

bool CPtuDPerception::setLimits ( char  axis,
double &  l,
double &  u 
)
virtual

Set limits of movement.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 791 of file CPtuDPerception.cpp.

References MRPT_UNUSED_PARAM.

bool CPtuDPerception::speed ( char  axis,
double  radSec 
)
virtual

Specification of turn speed.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 92 of file CPtuDPerception.cpp.

bool CPtuDPerception::speedQ ( char  axis,
double &  radSec 
)
virtual

Query turn speed.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 101 of file CPtuDPerception.cpp.

virtual double mrpt::hwdrivers::CPtuDPerception::status ( double &  rad)
inlinevirtual

Check if ptu is moving.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 201 of file CPtuDPerception.h.

References MRPT_UNUSED_PARAM.

bool mrpt::hwdrivers::CPtuDPerception::tiltHitError ( )
inline

Definition at line 242 of file CPtuDPerception.h.

References TiltHitError.

bool mrpt::hwdrivers::CPtuDPerception::timeoutError ( )
inline

Definition at line 238 of file CPtuDPerception.h.

References TimeoutError.

bool CPtuDPerception::transmit ( const char *  command)
privatevirtual

To transmition commands to the PTU.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 443 of file CPtuDPerception.cpp.

References mrpt::system::os::strcat(), and mrpt::system::os::strcpy().

bool mrpt::hwdrivers::CPtuDPerception::unExpectedError ( )
inline

Definition at line 247 of file CPtuDPerception.h.

References UnExpectedError.

bool CPtuDPerception::upperSpeed ( char  axis,
double  radSec 
)
virtual

Specification of velocity upper limit.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 150 of file CPtuDPerception.cpp.

bool CPtuDPerception::upperSpeedQ ( char  axis,
double &  radSec 
)
virtual

Query velocity upper limit.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 159 of file CPtuDPerception.cpp.

bool CPtuDPerception::verbose ( bool  set)
virtual

Set verbose.


Example of response with FV (verbose) active: FV * PP * Current pan position is 0 Example of response with FT (terse) active: FT * PP * 0

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 525 of file CPtuDPerception.cpp.

bool CPtuDPerception::verboseQ ( bool &  modo)
virtual

Query verbose mode.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 507 of file CPtuDPerception.cpp.

bool CPtuDPerception::version ( char *  nVersion)
virtual

Version and CopyRights.

Implements mrpt::hwdrivers::CPtuBase.

Definition at line 303 of file CPtuDPerception.cpp.

Member Data Documentation

int mrpt::hwdrivers::CPtuDPerception::nError

TimeoutError: Only occurs if the communication is cut with PTU so it is advisable to check the connection and initialize again the comunication.

Definition at line 372 of file CPtuDPerception.h.

double mrpt::hwdrivers::CPtuBase::panResolution
inherited

Definition at line 30 of file CPtuBase.h.

CSerialPort mrpt::hwdrivers::CPtuBase::serPort
protectedinherited

Definition at line 34 of file CPtuBase.h.

double mrpt::hwdrivers::CPtuBase::tiltResolution
inherited

Definition at line 30 of file CPtuBase.h.




Page generated by Doxygen 1.8.6 for MRPT 1.5.5 Git: e06b63d Fri Dec 1 14:41:11 2017 +0100 at sáb dic 2 13:00:21 CET 2017