Aria  2.8.0
ArTCMCompassDirect Class Reference

Talk to a compass directly over a computer serial port. More...

#include <ArTCMCompassDirect.h>

Inherits ArTCM2.

Public Member Functions

 ArTCMCompassDirect (ArDeviceConnection *devCon)
 
 ArTCMCompassDirect (const char *serialPortName=ARTCM2_DEFAULT_SERIAL_PORT)
 
virtual bool blockingConnect (unsigned long connectTimeout=5000)
 
virtual void commandAutoCalibration ()
 Send commands to begin calibrating.
 
virtual void commandJustCompass ()
 Same as commandContinuousPackets() in this implementation. More...
 
virtual void commandSoftReset ()
 Not implemented yet. More...
 
virtual void commandStopCalibration ()
 
virtual void commandUserCalibration ()
 
virtual bool connect ()
 Open device connection if not yet open and send commands to configure compass. More...
 
ArDeviceConnectiongetDeviceConnetion ()
 
int read (unsigned int msWait=1)
 Read all available data, store, and call callbacks if any were added. More...
 
void setDeviceConnection (ArDeviceConnection *devCon)
 
virtual void commandContinuousPackets ()
 Send commands to start/stop sending data. More...
 
virtual void commandOnePacket ()
 
virtual void commandOff ()
 
- Public Member Functions inherited from ArTCM2
void addHeadingDataCallback (ArFunctor1< double > *f)
 
double getCalibrationH (void) const
 Get the calibration H score (See TCM Manual)
 
double getCalibrationM (void) const
 Get the calibration M score (See TCM Manual)
 
double getCalibrationV (void) const
 Get the calibration V score (See TCM Manual)
 
double getCompass (void) const
 Get the compass heading (-180, 180] degrees. More...
 
int getError (void) const
 
double getHeading (void) const
 Get the compass heading (-180, 180] degrees.
 
int getPacCount (void)
 Gets the number of readings recieved in the last second.
 
double getPitch (void) const
 Get the pitch (-180,180] degrees.
 
double getRoll (void) const
 Get the roll (-180,180] degrees.
 
double getTemperature (void) const
 Get the temperature (degrees C)
 
double getXMagnetic (void) const
 Get the magnetic field X component (See TCM2 Manual)
 
double getYMagnetic (void) const
 Get the magnetic field Y component (See TCM2 Manual)
 
double getZMagnetic (void) const
 Get the magnetic field Z component (See TCM2 Manual)
 
bool haveCalibrationH () const
 
bool haveCalibrationM () const
 
bool haveCalibrationV () const
 
bool haveHeading () const
 
bool havePitch () const
 
bool haveRoll () const
 
bool haveTemperature () const
 
bool haveXMagnetic () const
 
bool haveYMagnetic () const
 
bool haveZMagnetic () const
 

Additional Inherited Members

- Protected Member Functions inherited from ArTCM2
void incrementPacketCount ()
 
void invokeHeadingDataCallbacks (double heading)
 
- Protected Attributes inherited from ArTCM2
double myCalibrationH
 
double myCalibrationM
 
double myCalibrationV
 
int myError
 
bool myHaveCalibrationH
 
bool myHaveCalibrationM
 
bool myHaveCalibrationV
 
bool myHaveHeading
 
bool myHavePitch
 
bool myHaveRoll
 
bool myHaveTemperature
 
bool myHaveXMag
 
bool myHaveYMag
 
bool myHaveZMag
 
double myHeading
 
std::list< ArFunctor1< double > *> myHeadingDataCallbacks
 
int myPacCount
 
int myPacCurrentCount
 
double myPitch
 
double myRoll
 
double myTemperature
 
time_t myTimeLastPacket
 
double myXMag
 
double myYMag
 
double myZMag
 

Detailed Description

Talk to a compass directly over a computer serial port.

This class configures and recieves compass heading data from a TCM2 or TCM2.5 compass directly over a computer serial port, rather than via tha robot. This class cannot recieve pitch, roll or temperature data from the compass. On all Pioneer robots, the TCM compass (as originally installed by MobileRobots) is connected to the robot microcontroller, so if you have a Pioneer with this configuration, you should instead use the ArTCMCompassRobot class. Only use this class if you have connected the compass to the computer serial port.

You can create an instance of this class directly, or using an ArCompassConnector object and giving the "-compassType serialtcm" program argument.

If you create your own ArTCMCompassDirect object, you must call the read() method periodically (ideally at the same rate the compass sends data, approx. 8 hz by default) to read and parse incoming data. You can use an ArRobot callback to do this, for example:

myRobot->addSensorInterpTask("ArTCMCompassDirect read", 200, &compassReadFunc);

If you use ArCompassConnector, however, it will automatically do this.

Member Function Documentation

◆ commandContinuousPackets()

void ArTCMCompassDirect::commandContinuousPackets ( void  )
virtual

Send commands to start/stop sending data.

Implements ArTCM2.

◆ commandJustCompass()

virtual void ArTCMCompassDirect::commandJustCompass ( void  )
inlinevirtual

Same as commandContinuousPackets() in this implementation.

Implements ArTCM2.

◆ commandSoftReset()

virtual void ArTCMCompassDirect::commandSoftReset ( void  )
inlinevirtual

Not implemented yet.

Implements ArTCM2.

◆ connect()

bool ArTCMCompassDirect::connect ( )
virtual

Open device connection if not yet open and send commands to configure compass.

Reimplemented from ArTCM2.

◆ read()

int ArTCMCompassDirect::read ( unsigned int  msWait = 1)

Read all available data, store, and call callbacks if any were added.

unsigned int msWait If 0, wait indefinately for new data. Otherwise, wait a maximum of this many milliseconds for data to arrive.

Returns
A value > 0 if messages were recieved from the compass, 0 if no data was recieved, and a value < 0 on error reading from the compass.

The documentation for this class was generated from the following files: