libnifalcon  1.0.1
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | List of all members
libnifalcon::FalconDevice Class Reference

#include <FalconDevice.h>

+ Inheritance diagram for libnifalcon::FalconDevice:
+ Collaboration diagram for libnifalcon::FalconDevice:

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 ()
 
std::array< double, 3 > getPosition ()
 
void setForce (std::array< double, 3 > force)
 
std::shared_ptr< FalconCommgetFalconComm ()
 
std::shared_ptr< FalconFirmwaregetFalconFirmware ()
 
std::shared_ptr< FalconGripgetFalconGrip ()
 
std::shared_ptr< FalconKinematicgetFalconKinematic ()
 
bool isOpen ()
 
unsigned int getErrorCount ()
 
- Public Member Functions inherited from libnifalcon::FalconCore
 FalconCore ()
 
virtual ~FalconCore ()
 
int getErrorCode ()
 

Protected Attributes

unsigned int m_errorCount
 
std::shared_ptr< FalconCommm_falconComm
 
std::shared_ptr< FalconKinematicm_falconKinematic
 
std::shared_ptr< FalconFirmwarem_falconFirmware
 
std::shared_ptr< FalconGripm_falconGrip
 
std::array< double, 3 > m_position
 
std::array< double, 3 > m_forceVec
 
- Protected Attributes inherited from libnifalcon::FalconCore
int m_errorCode
 

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
countReference 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
std::shared_ptr<FalconComm> libnifalcon::FalconDevice::getFalconComm ( )
inline

Get communication behavior object pointer

Returns
Non-smart pointer to internal falcon communications object
std::shared_ptr<FalconFirmware> libnifalcon::FalconDevice::getFalconFirmware ( )
inline

Get firmware behavior object pointer

Returns
Non-smart pointer to internal falcon firmware object
std::shared_ptr<FalconGrip> libnifalcon::FalconDevice::getFalconGrip ( )
inline

Get grip behavior object pointer

Returns
Non-smart pointer to internal falcon grip object
std::shared_ptr<FalconKinematic> libnifalcon::FalconDevice::getFalconKinematic ( )
inline

Get kinematic behavior object pointer

Returns
Non-smart pointer to internal falcon kinematic object
std::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 ( unsigned int  retries,
bool  skip_checksum = false 
)

Conveinence function, calls loadFirmware with a certain number of retries

Parameters
retriesNumber of times to retry loading firmware before quitting
skip_checksumWhether 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 ( 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_checksumWhether 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
indexIndex 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 ( )

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 ( )

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 ( )

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 ( )

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
filenameName of the file to use for firmware
Returns
true if file exists and is openable, false otherwise
void libnifalcon::FalconDevice::setForce ( std::array< double, 3 >  force)
inline

Set the instantanious force for the next I/O loop

Parameters
forceForce vector, in cartesian coordinates (x,y,z)

Member Data Documentation

unsigned int libnifalcon::FalconDevice::m_errorCount
protected

Number of errors in I/O loops

std::shared_ptr<FalconComm> libnifalcon::FalconDevice::m_falconComm
protected

Falcon communication object

std::shared_ptr<FalconFirmware> libnifalcon::FalconDevice::m_falconFirmware
protected

Falcon firmware object

std::shared_ptr<FalconGrip> libnifalcon::FalconDevice::m_falconGrip
protected

Falcon grip object

std::shared_ptr<FalconKinematic> libnifalcon::FalconDevice::m_falconKinematic
protected

Falcon kinematics object

std::array<double, 3> libnifalcon::FalconDevice::m_forceVec
protected

Current force in 3D cartesian coordinates

std::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: