FlexSEA Wiki

A WEARABLE ROBOTICS TOOLKIT

User Tools

Site Tools


fxapifunctions

Functions

com_wrapper.h File Reference

File that documents the API of the FlexSEA Plan Stack. More...

#include <stdint.h>

Go to the source code of this file.

Functions
void fxSetup ()
 Initialize the FlexSEA API library environment. This must be called before any call to other functions in this library. More...
 
void fxCleanup ()
 Clean up the FlexSEA API library environment. Call this before exiting your program. More...
 
void fxOpen (char *portName, int portIdx)
 Open a serial port to communicate with a FlexSEA device. More...
 
uint8_t fxIsOpen (int portIdx)
 Check if a com port has been successfully opened. More...
 
void fxClose (uint16_t portIdx)
 Close a com port. More...
 
void fxGetDeviceIds (int *idarray, int n)
 Get the device id of all connected FlexSEA devices. The device ID is an opaque handle used by the functions in this API to specify which FlexSEA device to communicate with. More...
 
uint8_t fxSetStreamVariables (int devId, int *fieldIds, int n)
 This function is called to select which FlexSEA variables are streamed from a device. More...
 
uint8_t fxStartStreaming (int devId, int frequency, bool shouldLog, int shouldAuto)
 Start streaming data from a FlexSEA device. More...
 
uint8_t fxStopStreaming (int devId)
 Stop streaming data from a FlexSEA device. More...
 
int * fxReadDevice (int devId, int *fieldIds, uint8_t *success, int n)
 a utility function to access the most recent values received from a FlexSEA device. More...
 
void setControlMode (int devId, int ctrlMode)
 Sets the type of control mode of the FlexSEA device. The modes are open voltage, current, position, and impedance. More...
 
void setMotorVoltage (int devId, int mV)
 Sets the voltage being supplied to the motor. The voltage is specified in mV (milli-volts). More...
 
void setMotorCurrent (int devId, int cur)
 Sets the current for the motor. The current is specified in mA (milli-amps). More...
 
void setPosition (int devId, int pos)
 Sets the setpoint in encoder ticks. More...
 
void setZGains (int devId, int z_k, int z_b, int i_kp, int i_ki)
 Sets the gains used by PID controllers on the FlexSEA device. More...
 
void actPackFSM2 (int devId, int on)
 Enables or disables the user FSM 2 on the FlexSEA device. More...
 
void findPoles (int devId, int block)
 Runs the internal calibration routine on the FlexSEA device. find poles procedure on the device. More...
 

Detailed Description

File that documents the API of the FlexSEA Plan Stack.

Function Documentation

◆ actPackFSM2()

void actPackFSM2(int devId,
int on 
)

Enables or disables the user FSM 2 on the FlexSEA device.

  • Parameters devId is the opaque handle for the device. on 1 Enables the FSM, 0 disables it.
  • Returns Nothing.

◆ findPoles()

void findPoles(int devId,
int block 
)

Runs the internal calibration routine on the FlexSEA device. find poles procedure on the device.

  • Parameters devId is the opaque handle for the device. block Forces the function to block until the operation complete.
  • Returns Nothing.

◆ fxCleanup()

void fxCleanup( )

Clean up the FlexSEA API library environment. Call this before exiting your program.

  • Returns Nothing.

◆ fxClose()

void fxClose(uint16_t portIdx)

Close a com port.

  • Parameters portIdx is the handle to the port to close
  • Returns Nothing.

◆ fxGetDeviceIds()

void fxGetDeviceIds(int * idarray,
int 
)

Get the device id of all connected FlexSEA devices. The device ID is an opaque handle used by the functions in this API to specify which FlexSEA device to communicate with.

  • Parameters idarray On return idarray will contain “handle” for each FlexSEA device found. Each element of the array will contain -1 for no valid device or an opaque 'handle' that refers to a device. On input it should contain enough space for the maximum number of devices supported (currently 3). n is the length of the array idarray.
  • Returns Nothing. idarray is updated with device handles.
  • Note idArray must be pre-allocated with enough space for the maximum number of FlexSEA devices supported by this API (currently 3).

◆ fxIsOpen()

uint8_t fxIsOpen(int portIdx)

Check if a com port has been successfully opened.

  • Parameters portIdx is the “handle” supplied in fxOpen()
  • Returns 1 if the port is open, 0 otherwise

◆ fxOpen()

void fxOpen(char * portName,
int portIdx 
)

Open a serial port to communicate with a FlexSEA device.

  • Parameters portName is the name of the port to open (e.g. “COM3”) portIdx is a user defined “handle” that refers to this port.
  • Returns Nothing.

◆ fxReadDevice()

int* fxReadDevice(int devId,
int * fieldIds,
uint8_t * success,
int 
)

a utility function to access the most recent values received from a FlexSEA device.

  • Parameters devId is the opaque handle for the device. fieldIds Specify the field ids of variables to read. These must have been requested in the fxSetStreamVariables. Refer to http://dephy.com/wiki/flexsea/doku.php?id=fxdevicefields for a description of the field ids. success An array of status codes indicating whether the returned data aray contains valid data. This array must contain the same number of elements as the fieldIds array. Each element in the success array will contain 1 if that fieldIds element contains valid data. Otherwise, the success array element will contain 0. n Specifies the length of the arrays fieldIds and success. The arrays must be preallocated and the sze of the arrays must match.
  • Returns Returns a pointer to an array that contains the data being read.
  • Note This function will fail if the device is not configured to stream the requested field. Refer to fxSetStreamVariables().fieldIds and success arrays must be pre-allocated with enough space to hold all of the variables being streamed from the FlexSEA device.The returned data array is reused by each call to fxReadDevice. If you need it to persist, copy the data out of the array.

◆ fxSetStreamVariables()

uint8_t fxSetStreamVariables(int devId,
int * fieldIds,
int 
)

This function is called to select which FlexSEA variables are streamed from a device.

  • Returns Returns 0 on error 1 otherwise.

◆ fxSetup()

void fxSetup( )

Initialize the FlexSEA API library environment. This must be called before any call to other functions in this library.

  • Returns Nothing.

◆ fxStartStreaming()

uint8_t fxStartStreaming(int devId,
int frequency,
bool shouldLog,
int shouldAuto 
)

Start streaming data from a FlexSEA device.

  • Parameters devId is the opaque handle for the device. frequency This is the frequency of updates. This value is in Hz and can be one of the following 1, 5, 10, 20, 33, 50, 100, 200, 300, 500, 1000. shouldLog If set true, the program logs all received data to a file. The name of the file is formed as follows:

< FlexSEA model >_id< device ID >_< date and time >.csv

for example:

rigid_id3904_Tue_Nov_13_11_03_50_2018.csv

The file is formatted as a CSV file. The first line of the file will be headers for all columns. Each line after that will contain the data read from the device.

  • Parameters shouldAuto if set true, the device triggers itself to send read messages, otherwise the data is sent at the requested frequency.
  • Returns Returns 0 on error. Otherwise returns 1.

◆ fxStopStreaming()

uint8_t fxStopStreaming(int devId)

Stop streaming data from a FlexSEA device.

  • Parameters devId is the opaque handle for the device.
  • Returns 0 on success. Otherwise returns 1.

◆ setControlMode()

void setControlMode(int devId,
int ctrlMode 
)

Sets the type of control mode of the FlexSEA device. The modes are open voltage, current, position, and impedance.

  • Returns Nothing.

◆ setMotorCurrent()

void setMotorCurrent(int devId,
int cur 
)

Sets the current for the motor. The current is specified in mA (milli-amps).

  • Parameters devId is the opaque handle for the device. cur Is the current in milli Amos.
  • Returns Nothing.
  • Note The control mode must be set to current. Refer to fxSetControlMode().

◆ setMotorVoltage()

void setMotorVoltage(int devId,
int mV 
)

Sets the voltage being supplied to the motor. The voltage is specified in mV (milli-volts).

  • Parameters devId is the opaque handle for the device. mV is the voltage in milli Volts.
  • Returns Nothing.
  • Note The control mode must be open voltage. Refer to fxSetControlMode().

◆ setPosition()

void setPosition(int devId,
int pos 
)

Sets the setpoint in encoder ticks.

  • Parameters devId is the opaque handle for the device. pos Is the position.
  • Returns Nothing.
  • Note The control mode must be either position or impedance.

◆ setZGains()

void setZGains(int devId,
int z_k,
int z_b,
int i_kp,
int i_ki 
)

Sets the gains used by PID controllers on the FlexSEA device.

  • Parameters devId is the opaque handle for the device. z_k : Damping factor (used for current in current control & position in position/impedance control) z_b : Damping factor (used for current in current control & position in position/impedance control) i_kp : Proportional (used for for the underlying current control within the impedance controller) i_ki : Integral gain (used for for the underlying current control within the impedance controller)
  • Returns Nothing.
fxapifunctions.txt · Last modified: 2018/11/20 14:46 by dtscbs