FlexSEA Wiki

A WEARABLE ROBOTICS TOOLKIT

User Tools

Site Tools


fxapifunctions

FX_Plan_Stack API

Data types

For information about the data available to the Actuator Package, go the units page.

Functions

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

Go to the source code of this file.

Function Name Return Arguments Description
fxSetup void Initialize the FlexSEA API library environment. This must be called before any call to other functions in this library. More...
fxCleanup void  Clean up the FlexSEA API library environment. Call this before exiting your program. More...
fxOpen void  char *portName, int portIdx Open a serial port to communicate with a FlexSEA device. More...
fxIsOpen uint8_t  int portIdx Check if a com port has been successfully opened. More...
fxClose void  uint16_t portIdx Close a com port. More...
fxGetDeviceIds void  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...
fxSetStreamVariables uint8_t  int devId, int *fieldIds, int n This function is called to select which FlexSEA variables are streamed from a device. More...
fxStartStreaming uint8_t  int devId, int frequency, bool shouldLog, int shouldAuto Start streaming data from a FlexSEA device. More...
fxStopStreaming uint8_t  int devIdStop streaming data from a FlexSEA device. More...
fxReadDevice   int * int devId, int *fieldIds, uint8_t *success, int n A utility function to access the most recent values received from a FlexSEA device. More...
setControlMode void  int devId, int ctrlMode Sets the type of control mode of the FlexSEA device. The modes are open voltage, current, position, and impedance. More...
setMotorVoltage void  int devId, int mV Sets the voltage being supplied to the motor. The voltage is specified in mV (millivolts). More...
setMotorCurrent void  int devId, int cur Sets the current for the motor. The current is specified in mA (milliamps). More...
setPosition void  int devId, int pos Sets the setpoint in encoder ticks. More...
setZGains void  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...
actPackFSM2 void  int devId, int on Enables or disables the user FSM 2 on the FlexSEA device. More...
findPoles void  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.

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.

void findPoles(int devId, int block)

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

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

void fxCleanup()

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

  • Returns
    • Nothing.

void fxClose(uint16_t portIdx)

Close a com port.

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

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.

  • 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).

uint8_t fxIsOpen(int portIdx)

Check if a com port has been successfully opened.

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

void fxOpen(char *portName, int portIdx)

Open a serial port to communicate with a FlexSEA device.

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

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.

  • Parameters
    • devId: 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.

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

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

  • Returns
    • Returns 0 on error 1 otherwise.

void fxSetup()

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

  • Returns
    • Nothing.

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

Start streaming data from a FlexSEA device.

  • Parameters
    • devId: 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.
    • 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.
  • Note The CSV file naming scheme is the following:

< 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.

uint8_t fxStopStreaming(int devId)

Stop streaming data from a FlexSEA device.

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

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.

void setMotorCurrent(int devId, int cur)

Sets the current for the motor. The current is specified in mA (milliamps).

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

void setMotorVoltage(int devId, int mv)

Sets the voltage being supplied to the motor. The voltage is specified in mV (millivolts).

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

void setPosition(int devId, int pos)

Sets the setpoint in encoder ticks.

  • Parameters
    • devId: opaque handle for the device.
    • pos: motor position in ticks.
  • Returns
    • Nothing.
  • Note The control mode must be either position or impedance.

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: 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: 2019/03/25 12:17 by flabelle