libnifalcon
1.0.1
|
#include <FalconDevice.h>
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< FalconComm > | getFalconComm () |
std::shared_ptr< FalconFirmware > | getFalconFirmware () |
std::shared_ptr< FalconGrip > | getFalconGrip () |
std::shared_ptr< FalconKinematic > | getFalconKinematic () |
bool | isOpen () |
unsigned int | getErrorCount () |
![]() | |
FalconCore () | |
virtual | ~FalconCore () |
int | getErrorCode () |
Protected Attributes | |
unsigned int | m_errorCount |
std::shared_ptr< FalconComm > | m_falconComm |
std::shared_ptr< FalconKinematic > | m_falconKinematic |
std::shared_ptr< FalconFirmware > | m_falconFirmware |
std::shared_ptr< FalconGrip > | m_falconGrip |
std::array< double, 3 > | m_position |
std::array< double, 3 > | m_forceVec |
![]() | |
int | m_errorCode |
Private Member Functions | |
DECLARE_LOGGER () | |
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.
anonymous enum |
anonymous enum |
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
void libnifalcon::FalconDevice::close | ( | ) |
Closes the falcon, if open
|
private |
bool libnifalcon::FalconDevice::getDeviceCount | ( | unsigned int & | count | ) |
Returns the number of falcons currectly connected to the system
count | Reference to return to |
|
inline |
Get the number of total errors generated by the I/O loop
|
inline |
Get communication behavior object pointer
|
inline |
Get firmware behavior object pointer
|
inline |
Get grip behavior object pointer
|
inline |
Get kinematic behavior object pointer
|
inline |
Return the position given by the kinematic behavior.
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.
|
inline |
Checks whether the falcon communications are open
bool libnifalcon::FalconDevice::loadFirmware | ( | unsigned int | retries, |
bool | skip_checksum = false |
||
) |
Conveinence function, calls loadFirmware with a certain number of retries
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) |
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
skip_checksum | Whether or not to skip checksum tests when loading firmware (useful with ftd2xx on non-windows platforms) |
bool libnifalcon::FalconDevice::open | ( | unsigned int | index | ) |
Opens the falcon at the specified index
index | Index of falcon to open (starts at 0) |
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
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
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
void libnifalcon::FalconDevice::setFalconGrip | ( | ) |
Set grip behavior, and create a new internal object from it.
Template should be a subclass of FalconGrip
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
filename | Name of the file to use for firmware |
|
inline |
Set the instantanious force for the next I/O loop
force | Force vector, in cartesian coordinates (x,y,z) |
|
protected |
Number of errors in I/O loops
|
protected |
Falcon communication object
|
protected |
Falcon firmware object
|
protected |
Falcon grip object
|
protected |
Falcon kinematics object
|
protected |
Current force in 3D cartesian coordinates
|
protected |
Current position in 3D cartesian coordinates