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

#include <FalconFirmwareNovintSDK.h>

+ Inheritance diagram for libnifalcon::FalconFirmwareNovintSDK:
+ Collaboration diagram for libnifalcon::FalconFirmwareNovintSDK:

Public Member Functions

 FalconFirmwareNovintSDK ()
 
virtual ~FalconFirmwareNovintSDK ()
 
virtual std::string getRawReturn ()
 
bool runIOLoop ()
 
int32_t getGripInfoSize ()
 
const uint8_t * getGripInfo ()
 
- Public Member Functions inherited from libnifalcon::FalconFirmware
 FalconFirmware ()
 
virtual ~FalconFirmware ()
 
void setForces (const std::array< int, 3 >(&force))
 
std::array< int, 3 > getEncoderValues ()
 
void setLEDStatus (unsigned int leds)
 
uint8_t getLEDStatus ()
 
void setHomingMode (bool value)
 
unsigned int getHomingModeStatus ()
 
bool isHomed ()
 
void setFalconComm (std::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 ()
 
uint64_t getLoopCount ()
 
- Public Member Functions inherited from libnifalcon::FalconCore
 FalconCore ()
 
virtual ~FalconCore ()
 
int getErrorCode ()
 

Protected Member Functions

void formatInput ()
 
bool formatOutput ()
 

Protected Attributes

uint8_t m_gripInfo
 
uint8_t m_rawData [128]
 
uint8_t m_rawInput [17]
 
uint8_t m_rawOutput [17]
 
uint8_t m_rawOutputInternal [17]
 
unsigned int m_currentOutputIndex
 
unsigned int m_rawDataSize
 
- Protected Attributes inherited from libnifalcon::FalconFirmware
std::shared_ptr< FalconCommm_falconComm
 
std::string m_firmwareFilename
 
bool m_isFirmwareLoaded
 
bool m_homingMode
 
unsigned int m_ledStatus
 
std::array< int, 3 > m_forceValues
 
std::array< int, 3 > m_encoderValues
 
unsigned int m_homingStatus
 
uint64_t m_loopCount
 
uint64_t m_outputCount
 
bool m_hasWritten
 
- Protected Attributes inherited from libnifalcon::FalconCore
int m_errorCode
 

Private Member Functions

 DECLARE_LOGGER ()
 

Additional Inherited Members

- Public Types inherited from libnifalcon::FalconFirmware
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 Attributes inherited from libnifalcon::FalconFirmware
enum
libnifalcon::FalconFirmware:: { ... }  
FalconFirmwareLEDValues
 
enum
libnifalcon::FalconFirmware:: { ... }  
FalconFirmwareHomingValues
 
enum
libnifalcon::FalconFirmware:: { ... }  
FalconFirmwareErrorValues
 

Detailed Description

FalconFirmwareNovintSDK implements the firmware communications strategy for the firmware that comes with the Novint drivers, and with the nVent software.

Intro to Novint Firmware Format

16 bytes sent to the Falcon causes 16 bytes to be returned. It's expected that the host will be constantly polling the falcon to set motor positions, as it is assumed that the PID loops for the control exist in the software, not the hardware.

Input and output strings are printable. Each string starts with 0x3c ('<') and ends with 0x3e ('>'), and the byte range is 0x41 ('A') to 0x50 ('P').

A null input/output string looks like:

<AAAAAAAAAAAAAA>

However, after any amount of usage, the input/output string will probably look something like:

<HNGPOKOPFPOPAA>

Input Layout (To Controller)

0x3C 0x(g0) 0x(g1) 0x(g2) 0x(g3) 0x(h0) 0x(h1) 0x(h2) 0x(h3) 0x(i0) 0x(i1) 0x(i2) 0x(i3) 0x(j0) 0x(k0) 0x3E

Input Packet Byte Definitions:

Homing and LED Controls (Value of j0 byte):

Output Layout (To Controller)

0x3C 0x(m0) 0x(m1) 0x(m2) 0x(m3) 0x(n0) 0x(n1) 0x(n2) 0x(n3) 0x(o0) 0x(o1) 0x(o2) 0x(o3) 0x4(p0) 0x(q0) 0x3E

Output packet byte definitions:

Buttons and Homing Control Report (Value of j0 byte) - Directions taken from looking at the Falcon from the front:

Output Layout (To Controller)

Retrieving/Setting Axis Position:

Example:

  1. Test GUI gives us 1447 for first encoder, so that's the number we're trying to get to in the end.
  2. Driver gives us (positions represented by .s can be ignored): <JFBA..........>
  3. Translate to ascii values: 0x3c 0x4A 0x46 0x4B 0x50
  4. Drop first byte since it's just a marker: 0x4A 0x46 0x4B 0x50
  5. Subtract 0x41 (ASCII value for A) from all bytes: 0x9 0x5 0xA 0xF
  6. //(For readability only, not in the drivers)// Reverse into Big Endian: 0xF 0xA 0x5 0x9
  7. Shift into 16 bit number: 0xFA59
  8. Twos compliment conversion (~x+1): 0x05A7
  9. Decimal conversion (16 bit signed): 1447

Constructor & Destructor Documentation

libnifalcon::FalconFirmwareNovintSDK::FalconFirmwareNovintSDK ( )

Constructor

libnifalcon::FalconFirmwareNovintSDK::~FalconFirmwareNovintSDK ( )
virtual

Destructor

Member Function Documentation

libnifalcon::FalconFirmwareNovintSDK::DECLARE_LOGGER ( )
private
void libnifalcon::FalconFirmwareNovintSDK::formatInput ( )
protected

Formats current input (forces, LED commands, etc...) for sending to falcon.

bool libnifalcon::FalconFirmwareNovintSDK::formatOutput ( )
protected

Formats current output from falcon (joint positions, calibration, etc...)

Returns
True if at least one complete packet has been parsed
const uint8_t* libnifalcon::FalconFirmwareNovintSDK::getGripInfo ( )
inlinevirtual

Accessor for raw grip info

Returns
Const pointer to internal representation of raw grip info

Implements libnifalcon::FalconFirmware.

int32_t libnifalcon::FalconFirmwareNovintSDK::getGripInfoSize ( )
inlinevirtual

Returns size of the grip data portion of the message. Currently always 1.

Returns
Size of the grip data portion of the message. Currently always 1.

Implements libnifalcon::FalconFirmware.

std::string libnifalcon::FalconFirmwareNovintSDK::getRawReturn ( )
virtual

Get the raw data string returned from the falcon

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

Reimplemented from libnifalcon::FalconFirmware.

bool libnifalcon::FalconFirmwareNovintSDK::runIOLoop ( )
virtual

Runs device polling, then tries to write next command to device, or read return from device if write has already happened.

Returns
True if we've read something, false otherwise. Sets error and returns false on communications error.

Implements libnifalcon::FalconFirmware.

Member Data Documentation

unsigned int libnifalcon::FalconFirmwareNovintSDK::m_currentOutputIndex
protected

How far the firmware object is into parsing the current packet

uint8_t libnifalcon::FalconFirmwareNovintSDK::m_gripInfo
protected

Internal representation of grip data (buttons pressed, etc...)

uint8_t libnifalcon::FalconFirmwareNovintSDK::m_rawData[128]
protected

Raw buffer to read into

unsigned int libnifalcon::FalconFirmwareNovintSDK::m_rawDataSize
protected

Amount of data last returned from communications object read

uint8_t libnifalcon::FalconFirmwareNovintSDK::m_rawInput[17]
protected

Raw buffer for formatting input. Plus one character to make it zero terminated

uint8_t libnifalcon::FalconFirmwareNovintSDK::m_rawOutput[17]
protected

Raw buffer for last full output packet. Plus one character to make it zero terminated

uint8_t libnifalcon::FalconFirmwareNovintSDK::m_rawOutputInternal[17]
protected

Raw buffer for formatting output incrementally. Plus one character to make it zero terminated


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