libnifalcon::FalconDevice Class Reference
[Core Classes]

#include <FalconDevice.h>

Inherits libnifalcon::FalconCore.

Inherited by libnifalcon::FalconDeviceBoostThread.

Collaboration diagram for libnifalcon::FalconDevice:

Collaboration graph
[legend]

List of all members.

Public Types

enum  {
  FALCON_DEVICE_NO_COMM_SET = 1000, FALCON_DEVICE_NO_FIRMWARE_SET, FALCON_DEVICE_NO_KINEMATIC_SET, FALCON_DEVICE_NO_GRIP_SET,
  FALCON_DEVICE_NO_FIRMWARE_LOADED, FALCON_DEVICE_FIRMWARE_NOT_VALID, FALCON_DEVICE_FIRMWARE_CHECKSUM_MISMATCH
}
enum  { FALCON_LOOP_FIRMWARE = 0x1, FALCON_LOOP_KINEMATIC = 0x2, FALCON_LOOP_GRIP = 0x4 }

Public Member Functions

 FalconDevice ()
 ~FalconDevice ()
bool isFirmwareLoaded ()
bool setFirmwareFile (const std::string &filename)
bool loadFirmware (unsigned int retries, bool skip_checksum=false)
bool loadFirmware (bool skip_checksum)
bool getDeviceCount (unsigned int &count)
bool open (unsigned int index)
void close ()
bool runIOLoop (unsigned int exe_flags=(FALCON_LOOP_FIRMWARE|FALCON_LOOP_KINEMATIC|FALCON_LOOP_GRIP))
template<class T >
void setFalconComm ()
template<class T >
void setFalconFirmware ()
template<class T >
void setFalconGrip ()
template<class T >
void setFalconKinematic ()
boost::array< double, 3 > getPosition ()
void setForce (boost::array< double, 3 > force)
boost::shared_ptr< FalconCommgetFalconComm ()
boost::shared_ptr< FalconFirmwaregetFalconFirmware ()
boost::shared_ptr< FalconGripgetFalconGrip ()
boost::shared_ptr
< FalconKinematic
getFalconKinematic ()
bool isOpen ()
unsigned int getErrorCount ()

Protected Attributes

unsigned int m_errorCount
boost::shared_ptr< FalconCommm_falconComm
boost::shared_ptr
< FalconKinematic
m_falconKinematic
boost::shared_ptr< FalconFirmwarem_falconFirmware
boost::shared_ptr< FalconGripm_falconGrip
boost::array< double, 3 > m_position
boost::array< double, 3 > m_forceVec

Private Member Functions

 DECLARE_LOGGER ()


Detailed Description

FalconDevice is a conveinence class that ties together all of the components in libnifalcon to create a simple, usable single object for accessing and controlling a novint falcon. It does this by using a templated version of the pimpl idiom to fulfill the following behaviors:

Once these behaviors are established, FalconDevice can be used to get/set common parameters (end effector position, force generation, LED status, button/grip status, etc...) without have to refer to the specific behavior class.

The most common use of libnifalcon will look something like

All of the above functions can be achieved through using the FalconDevice object.


Member Enumeration Documentation

anonymous enum

Enumerator:
FALCON_DEVICE_NO_COMM_SET  Error for no communications policy set
FALCON_DEVICE_NO_FIRMWARE_SET  Error for no firmware policy set
FALCON_DEVICE_NO_KINEMATIC_SET  Error for no kinematics policy set
FALCON_DEVICE_NO_GRIP_SET  Error for no grip policy set
FALCON_DEVICE_NO_FIRMWARE_LOADED  Error for no firmware loaded
FALCON_DEVICE_FIRMWARE_NOT_VALID  Error for firmware file missing
FALCON_DEVICE_FIRMWARE_CHECKSUM_MISMATCH  Error for checksum mismatch during firmware loading

anonymous enum

Enumerator:
FALCON_LOOP_FIRMWARE  runIOLoop should run firmware update (device read/write)
FALCON_LOOP_KINEMATIC  runIOLoop should run kinematic update (end effector position and force calculation)
FALCON_LOOP_GRIP  runIOLoop should run grip information update


Constructor & Destructor Documentation

libnifalcon::FalconDevice::FalconDevice (  ) 

Constructor

Sets the falcon communications device to the default for the system (FTD2XX for windows, libusb-1.0 for anything else)

libnifalcon::FalconDevice::~FalconDevice (  ) 

Destructor


Member Function Documentation

void libnifalcon::FalconDevice::close (  ) 

Closes the falcon, if open

libnifalcon::FalconDevice::DECLARE_LOGGER (  )  [private]

bool libnifalcon::FalconDevice::getDeviceCount ( unsigned int &  count  ) 

Returns the number of falcons currectly connected to the system

Parameters:
count Reference to return to
Returns:
true if count is successfully returned, false otherwise

unsigned int libnifalcon::FalconDevice::getErrorCount (  )  [inline]

Get the number of total errors generated by the I/O loop

Returns:
Number of errors generated by the I/O loop since device creation

boost::shared_ptr<FalconComm> libnifalcon::FalconDevice::getFalconComm (  )  [inline]

Get communication behavior object pointer

Returns:
Non-smart pointer to internal falcon communications object

boost::shared_ptr<FalconFirmware> libnifalcon::FalconDevice::getFalconFirmware (  )  [inline]

Get firmware behavior object pointer

Returns:
Non-smart pointer to internal falcon firmware object

boost::shared_ptr<FalconGrip> libnifalcon::FalconDevice::getFalconGrip (  )  [inline]

Get grip behavior object pointer

Returns:
Non-smart pointer to internal falcon grip object

boost::shared_ptr<FalconKinematic> libnifalcon::FalconDevice::getFalconKinematic (  )  [inline]

Get kinematic behavior object pointer

Returns:
Non-smart pointer to internal falcon kinematic object

boost::array<double, 3> libnifalcon::FalconDevice::getPosition (  )  [inline]

Return the position given by the kinematic behavior.

Returns:
Array of 3 doubles, representing 3D cartesian coordinate

bool libnifalcon::FalconDevice::isFirmwareLoaded (  ) 

Checks to see if firmware is loaded by running IO loop 10 times, returning true on first success Will automatically return false is setFalconFirmware() has not been called.

Returns:
true if firmware is loaded, false otherwise

bool libnifalcon::FalconDevice::isOpen (  )  [inline]

Checks whether the falcon communications are open

Returns:
True if comm component is set and open, false otherwise

bool libnifalcon::FalconDevice::loadFirmware ( bool  skip_checksum  ) 

Tries to load the firmware that was specified by the setFirmwareFile function. For the moment, skip_checksum should be used on non-windows platforms when using the ftd2xx communications core, as there is a bug that causes bad checksum returns on otherwise proper firmware loading events

Parameters:
skip_checksum Whether or not to skip checksum tests when loading firmware (useful with ftd2xx on non-windows platforms)
Returns:
true if firmware is loaded successfully, false otherwise

bool libnifalcon::FalconDevice::loadFirmware ( unsigned int  retries,
bool  skip_checksum = false 
)

Conveinence function, calls loadFirmware with a certain number of retries

Parameters:
retries Number of times to retry loading firmware before quitting
skip_checksum Whether or not to skip checksum tests when loading firmware (useful with ftd2xx on non-windows platforms)
Returns:
true if firmware is loaded successfully, false otherwise

bool libnifalcon::FalconDevice::open ( unsigned int  index  ) 

Opens the falcon at the specified index

Parameters:
index Index of falcon to open (starts at 0)
Returns:
true if falcon opened successfully, false otherwise

bool libnifalcon::FalconDevice::runIOLoop ( unsigned int  exe_flags = (FALCON_LOOP_FIRMWARE | FALCON_LOOP_KINEMATIC | FALCON_LOOP_GRIP)  ) 

Runs one iteration of the IO Loop, with the following logic

  • If firmware not set, return false
  • Run firmware IO Loop, return false if fails
  • If falcon is homed and kinematic behavior is set, Run kinematic update, return false if fails
  • If grip behavior is set, run grip update, return false if fails

Returns:
true on success, false otherwise

template<class T >
void libnifalcon::FalconDevice::setFalconComm (  )  [inline]

Set communications behavior type, and create a new internal object from it. Also passes new comm object to firmware behavior, if it exists.

Template should be a subclass of FalconComm

template<class T >
void libnifalcon::FalconDevice::setFalconFirmware (  )  [inline]

Set firmware behavior type, and create a new internal object from it. Also passes communications behavior to firmware, if it exists.

Template should be a subclass of FalconFirmware

template<class T >
void libnifalcon::FalconDevice::setFalconGrip (  )  [inline]

Set grip behavior, and create a new internal object from it.

Template should be a subclass of FalconGrip

template<class T >
void libnifalcon::FalconDevice::setFalconKinematic (  )  [inline]

Set communications behavior, and create a new internal object from it.

Template should be a subclass of FalconKinematic

bool libnifalcon::FalconDevice::setFirmwareFile ( const std::string &  filename  ) 

Sets the firmware file to load to the falcon

Parameters:
filename Name of the file to use for firmware
Returns:
true if file exists and is openable, false otherwise

void libnifalcon::FalconDevice::setForce ( boost::array< double, 3 >  force  )  [inline]

Set the instantanious force for the next I/O loop

Parameters:
force Force vector, in cartesian coordinates (x,y,z)


Member Data Documentation

unsigned int libnifalcon::FalconDevice::m_errorCount [protected]

Number of errors in I/O loops

boost::shared_ptr<FalconComm> libnifalcon::FalconDevice::m_falconComm [protected]

Falcon communication object

Falcon firmware object

boost::shared_ptr<FalconGrip> libnifalcon::FalconDevice::m_falconGrip [protected]

Falcon grip object

Falcon kinematics object

boost::array<double, 3> libnifalcon::FalconDevice::m_forceVec [protected]

Current force in 3D cartesian coordinates

boost::array<double, 3> libnifalcon::FalconDevice::m_position [protected]

Current position in 3D cartesian coordinates


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

Generated on Sun Sep 20 12:24:29 2009 for libnifalcon by  doxygen 1.5.9