libnifalcon::FalconFirmware Class Reference
[Core ClassesFirmware Classes]

#include <FalconFirmware.h>

Inherits libnifalcon::FalconCore.

Inherited by libnifalcon::FalconFirmwareNovintSDK.

Collaboration diagram for libnifalcon::FalconFirmware:

Collaboration graph
[legend]

List of all members.

Public Types

enum  { GREEN_LED = 0x2, BLUE_LED = 0x4, RED_LED = 0x8 }
enum  { ENCODER_1_HOMED = 0x1, ENCODER_2_HOMED = 0x2, ENCODER_3_HOMED = 0x4 }
enum  {
  FALCON_FIRMWARE_NO_COMM_SET = 3000, FALCON_FIRMWARE_NO_FIRMWARE_SET, FALCON_FIRMWARE_NO_FIRMWARE_LOADED, FALCON_FIRMWARE_FILE_NOT_VALID,
  FALCON_FIRMWARE_CHECKSUM_MISMATCH
}

Public Member Functions

 FalconFirmware ()
virtual ~FalconFirmware ()
virtual bool runIOLoop ()=0
virtual int getGripInfoSize ()=0
virtual const uint8_t * getGripInfo ()=0
void setForces (const boost::array< int, 3 >(&force))
boost::array< int, 3 > getEncoderValues ()
void setLEDStatus (unsigned int leds)
uint8_t getLEDStatus ()
void setHomingMode (bool value)
unsigned int getHomingModeStatus ()
bool isHomed ()
void setFalconComm (boost::shared_ptr< FalconComm > f)
bool isFirmwareLoaded ()
bool setFirmwareFile (const std::string &filename)
bool loadFirmware (unsigned int retries, bool skip_checksum=false)
bool loadFirmware (bool skip_checksum=false)
bool loadFirmware (bool skip_checksum, const unsigned int &firmware_size, uint8_t *buffer)
virtual void resetFirmwareState ()
virtual std::string getRawReturn ()
uint64_t getLoopCount ()

Public Attributes

enum
libnifalcon::FalconFirmware:: { ... }  
FalconFirmwareLEDValues
enum
libnifalcon::FalconFirmware:: { ... }  
FalconFirmwareHomingValues
enum
libnifalcon::FalconFirmware:: { ... }  
FalconFirmwareErrorValues

Protected Attributes

boost::shared_ptr< FalconCommm_falconComm
std::string m_firmwareFilename
bool m_isFirmwareLoaded
bool m_homingMode
unsigned int m_ledStatus
boost::array< int, 3 > m_forceValues
boost::array< int, 3 > m_encoderValues
unsigned int m_homingStatus
uint64_t m_loopCount
uint64_t m_outputCount
bool m_hasWritten

Private Member Functions

 DECLARE_LOGGER ()


Detailed Description

Firmware dictates the format we talk to the falcon in after we've loaded a certain firmware. We assume all falcon firmware provides a certain set of functions:

This class provides the pure virtual functions that need to be filled in by specific firmware implementations.

Homing Mode

Homing mode is a feature of the firmware that allows the falcon to self-correct the origin of the grip. The homing mode bit must be set in each input packet sent in order for the falcon to stay homed.

It is recommended that any program using the falcon require the falcon to be homed before enacting any torques calculated from positions, as the transfer from non-homed to homed completely resets the coordinate system, and will cause large errors in calculations. Since each motor is decently powerful, these errors can lead to violence.

To home the falcon:


Member Enumeration Documentation

anonymous enum

Enumerator:
GREEN_LED  Flag to control Green LED
BLUE_LED  Flag to control Blue LED
RED_LED  Flag to control Red LED

anonymous enum

Enumerator:
ENCODER_1_HOMED  Flag for encoder homing for motor 1
ENCODER_2_HOMED  Flag for encoder homing for motor 2
ENCODER_3_HOMED  Flag for encoder homing for motor 3

anonymous enum

Enumerator:
FALCON_FIRMWARE_NO_COMM_SET  Error for no communications policy set
FALCON_FIRMWARE_NO_FIRMWARE_SET  Error for no firmware policy set
FALCON_FIRMWARE_NO_FIRMWARE_LOADED  Error for no firmware loaded
FALCON_FIRMWARE_FILE_NOT_VALID  Error for firmware file missing
FALCON_FIRMWARE_CHECKSUM_MISMATCH  Error for checksum mismatch during firmware loading


Constructor & Destructor Documentation

libnifalcon::FalconFirmware::FalconFirmware (  ) 

Constructor

virtual libnifalcon::FalconFirmware::~FalconFirmware (  )  [inline, virtual]

Destructor


Member Function Documentation

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

boost::array<int, 3> libnifalcon::FalconFirmware::getEncoderValues (  )  [inline]

Returns an array of current motor encoder values from the last I/O loop

Returns:
Signed 16-bit integers representing the current encoder values for each motor

virtual const uint8_t* libnifalcon::FalconFirmware::getGripInfo (  )  [pure virtual]

Retrieves the buffer containing grip data

Returns:
Byte buffer with grip data

Implemented in libnifalcon::FalconFirmwareNovintSDK.

virtual int libnifalcon::FalconFirmware::getGripInfoSize (  )  [pure virtual]

Returns the size of grip information for this firmware.

This may or may not work. However, there's currently only one grip type, so I'm guessing.

Returns:
Size of the buffer that getGripInfo will return

Implemented in libnifalcon::FalconFirmwareNovintSDK.

unsigned int libnifalcon::FalconFirmware::getHomingModeStatus (  )  [inline]

Return the homing status of each encoder

Returns:
Bitfield of encoder homing statuses

uint8_t libnifalcon::FalconFirmware::getLEDStatus (  )  [inline]

Returns the current LED status bitfield

Returns:
The current LED status bitfield

uint64_t libnifalcon::FalconFirmware::getLoopCount (  )  [inline]

Get the number of successful I/O loops run

Returns:
number of successful I/O loops

virtual std::string libnifalcon::FalconFirmware::getRawReturn (  )  [inline, virtual]

Get the raw data string returned from the falcon

Returns:
std::string of last full packet received from the falcon

Reimplemented in libnifalcon::FalconFirmwareNovintSDK.

bool libnifalcon::FalconFirmware::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::FalconFirmware::isHomed (  )  [inline]

Returns the overall homing status

Basically, if only one encoder is homed, it doesn't do you a lot of good. This is a conveinence function to signify whether all motors are homed

Returns:
True if all encoders are homed, false otherwise

bool libnifalcon::FalconFirmware::loadFirmware ( bool  skip_checksum,
const unsigned int &  firmware_size,
uint8_t *  buffer 
)

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)
firmware_size Size of the raw buffer we're passing to the firmware
buffer Raw buffer loaded with binary falcon firmware
Returns:
true if firmware is loaded successfully, false otherwise

bool libnifalcon::FalconFirmware::loadFirmware ( bool  skip_checksum = false  ) 

Conveinence function, runs one try of loading firmware with set filename

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

virtual void libnifalcon::FalconFirmware::resetFirmwareState (  )  [inline, virtual]

Used to reset the state of the communications if reloading firmware more than once in the same session

virtual bool libnifalcon::FalconFirmware::runIOLoop (  )  [pure virtual]

Run one read/write loop

Returns:
True if read and write are successful, false otherwise

Implemented in libnifalcon::FalconFirmwareNovintSDK.

void libnifalcon::FalconFirmware::setFalconComm ( boost::shared_ptr< FalconComm f  )  [inline]

Sets the communication object for the firmware to run I/O through

Parameters:
f Pointer to the communications object

bool libnifalcon::FalconFirmware::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::FalconFirmware::setForces ( const boost::array< int, 3 > &  force  )  [inline]

Sets the instantious force (in whatever units the falcon takes) for the next I/O loop

Parameters:
force Array of signed 16-bit integers to set force

void libnifalcon::FalconFirmware::setHomingMode ( bool  value  )  [inline]

Sets the homing mode for the next I/O loop

Parameters:
value True to turn homing mode on, false for off

void libnifalcon::FalconFirmware::setLEDStatus ( unsigned int  leds  )  [inline]

Sets the LEDs to turn on or off at the next I/O loop

Parameters:
leds Bitfield of the LED flags


Member Data Documentation

boost::array<int, 3> libnifalcon::FalconFirmware::m_encoderValues [protected]

Encoder values from the last I/O loop

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

Communications object for I/O

Filename of the firmware to load

boost::array<int, 3> libnifalcon::FalconFirmware::m_forceValues [protected]

Force values for the next I/O loop

True if we're waiting for a read return

True if homing mode is on, false for homing mode off

Current homing status from the last I/O loop

True if firmware has been loaded, false otherwise

unsigned int libnifalcon::FalconFirmware::m_ledStatus [protected]

Bitfield for LED Status

Number of successful loops that have been run by this firmware instance

Number of successful loops that have been run by this firmware instance


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

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