FlexSEA Communication
device_wrapper.h
Go to the documentation of this file.
1 #ifndef DEVICE_WRAPPER_H
2 #define DEVICE_WRAPPER_H
3 
12 #include <stdbool.h>
13 #include <string>
14 #include "actpack_struct.h"
15 #include "netmaster_struct.h"
16 #include "cellscreener_struct.h"
17 #include "battcycler_struct.h"
18 #include "i2t_struct.h"
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 typedef enum fxError
26 {
27  FxSuccess = 0,
28  FxFailure,
29  FxInvalidParam,
30  FxInvalidDevice,
31  FxNotStreaming,
32 
33 } FxError;
34 
35 typedef enum fxControlMode
36 {
37  FxPosition = 0,
38  FxVoltage = 1,
39  FxCurrent = 2,
41  FxNone = 4,
42  FxCustom = 5,
43  FxMeasRes = 6,
44  FxStalk = 7,
45 
46 } FxControlMode;
47 
48 typedef enum fxAppType
49 {
50  FxInvalidApp = -1,
51  FxActPack = 0,
52  FxExo,
53  FxNetMaster,
54  FxBMS,
55  FxHabsolute,
56  FxCellScreener,
57  FxBattCycler
58 
59 } FxAppType;
60 
61 struct ActPackState;
62 struct NetMasterState;
63 struct BMSState;
64 struct HabsoluteState;
65 struct CellScreenerState;
66 struct BattCyclerState;
67 
69 #define NUM_TIMER_FREQS 11
70 
72 #define FX_MAX_DEVICES 10
73 
76 #define MIN_UVLO 15000
77 #define MAX_UVLO 50000
78 
80 #define MIN_UNIQUE_ID 0
81 #define MAX_UNIQUE_ID 65535
82 
84 #define MIN_CURRENT_OFFSET -15
85 #define MAX_CURRENT_OFFSET 15
86 
92 
110 int fxOpen(const char* portName,
111  unsigned int baudRate,
112  unsigned int logLevel);
113 
119 bool fxIsOpen(unsigned int deviceId);
120 
124 bool fxIsActiveDevice(unsigned int deviceId);
125 
130 FxError fxClose(unsigned int deviceId);
131 
132 
134 void fxCloseAll();
135 
151 int fxGetDeviceIds(int* idArray, unsigned int size);
152 
179 FxError fxStartStreaming(unsigned int deviceId,
180  unsigned int frequency,
181  bool shouldLog);
182 
188 FxError fxStopStreaming(unsigned int deviceId);
189 
194 int fxGetValidStreamingFrequencies(unsigned int deviceId, int validFrequencies[NUM_TIMER_FREQS]);
195 
201 bool fxIsStreaming(unsigned int deviceId);
212 FxError fxReadDevice(unsigned int deviceId, ActPackState* readData);
213 
224 FxError fxReadNetMasterDevice(unsigned int deviceId, NetMasterState* readData);
225 
235 FxError fxReadBMSDevice(unsigned int deviceId, BMSState* readData);
236 
246 FxError fxReadHabsoluteDevice(unsigned int deviceId, HabsoluteState* readData);
247 
257 FxError fxReadCellScreenerDevice(unsigned int deviceId, CellScreenerState* readData);
258 
268 FxError fxReadBattCyclerDevice(unsigned int deviceId, BattCyclerState* readData);
269 
279 FxError fxSetReadDataQueueSize(unsigned int deviceId,
280  unsigned int size);
281 
288 int fxGetReadDataQueueSize(unsigned int deviceId);
289 
304 int fxReadDeviceAll(unsigned int deviceId,
305  ActPackState* readData,
306  unsigned int n);
307 
321 int fxReadNetMasterDeviceAll(unsigned int deviceId,
322  NetMasterState* readData,
323  unsigned int n);
324 
338 int fxReadBMSDeviceAll(unsigned int deviceId,
339  BMSState* readData,
340  unsigned int n);
341 
355 int fxReadHabsoluteDeviceAll(unsigned int deviceId,
356  HabsoluteState* readData,
357  unsigned int n);
358 
372 int fxReadCellScreenerDeviceAll(unsigned int deviceId,
373  CellScreenerState* readData,
374  unsigned int n);
375 
389 int fxReadBattCyclerDeviceAll(unsigned int deviceId,
390  BattCyclerState* readData,
391  unsigned int n);
392 
410 FxError fxSetGains(unsigned int deviceId,
411  unsigned int kp,
412  unsigned int ki,
413  unsigned int kd,
414  unsigned int K,
415  unsigned int B,
416  unsigned int ff);
417 
432 FxError fxSendMotorCommand(unsigned int deviceId, FxControlMode controlMode, int value);
433 
438 
439 FxAppType fxGetAppType(unsigned int deviceId);
440 
451 FxError fxSetUVLO(unsigned int deviceId, unsigned int mV);
452 
463 FxError fxRequestUVLO(unsigned int deviceId);
464 
472 int fxGetLastReceivedUVLO(unsigned int deviceId);
473 
485 FxError fxSetUniqueId(unsigned int deviceId, unsigned int uid);
486 
498 FxError fxSetCurrentOffset(unsigned int deviceId, int offset);
499 
511 FxError fxRequestCurrentOffset(unsigned int deviceId);
512 
525 int fxGetLastReceivedCurrentOffset(unsigned int deviceId);
526 
536 FxError fxSetI2T(unsigned int deviceId, i2tVals i2tValsToWrite);
537 
550 FxError fxRequestI2T(unsigned int deviceId);
551 
561 i2tVals fxGetLastReceivedI2T(unsigned int deviceId);
562 
569 FxError fxSendEventFlags(int flag, int time);
570 
580 FxError fxFindPoles(unsigned int deviceId);
581 
589 FxError fxSetAnkleTorquePoints(unsigned int deviceId, int16_t *newAnkleTorque, uint8_t controller, uint8_t points);
590 
598 FxError fxReadAnkleTorquePoints(unsigned int deviceId, uint8_t points);
599 
606 int16_t * fxGetLastReceivedAnkleTorquePoints(unsigned int deviceId);
607 
617 FxError fxActivateBootloader(unsigned int deviceId, uint8_t target);
618 
626 FxError fxIsBootloaderActivated(unsigned int deviceId);
627 
633 double fxGetTimingGain(unsigned int deviceId, bool *isValid, double *highestTimingGain);
634 
635 #ifdef __cplusplus
636 } // extern "C"
637 #endif
638 
639 #endif // DEVICE_WRAPPER_H
FxVoltage
@ FxVoltage
Position - Send a position setpoint.
Definition: device_wrapper.h:38
fxRequestUVLO
FxError fxRequestUVLO(unsigned int deviceId)
Send a UVLO request to the specified device. The value is retrieved asynchronously and must be checke...
FxNone
@ FxNone
Impedance - Send an impedance command. Position setpoints but with stiffness and damping coefficients...
Definition: device_wrapper.h:41
FxImpedance
@ FxImpedance
Current - Send a current Setpoint command.
Definition: device_wrapper.h:40
fxSetUVLO
FxError fxSetUVLO(unsigned int deviceId, unsigned int mV)
Set the UVLO to the desired value.
fxSetGains
FxError fxSetGains(unsigned int deviceId, unsigned int kp, unsigned int ki, unsigned int kd, unsigned int K, unsigned int B, unsigned int ff)
Sets the gains used by PID controllers on the FlexSEA device.
fxReadNetMasterDevice
FxError fxReadNetMasterDevice(unsigned int deviceId, NetMasterState *readData)
Read the most recent data from a streaming FlexSEA NetMaster device. Must call fxStartStreaming befor...
fxGetAppType
FxAppType fxGetAppType(unsigned int deviceId)
Get the device application type.
fxReadNetMasterDeviceAll
int fxReadNetMasterDeviceAll(unsigned int deviceId, NetMasterState *readData, unsigned int n)
Read all exo data from a streaming FlexSEA NetMaster device. Must call fxStartStreaming before callin...
fxIsStreaming
bool fxIsStreaming(unsigned int deviceId)
check if streaming data from a FlexSEA device.
fxSetI2T
FxError fxSetI2T(unsigned int deviceId, i2tVals i2tValsToWrite)
Set the i2t values to the desired values.
fxGetLastReceivedI2T
i2tVals fxGetLastReceivedI2T(unsigned int deviceId)
Check the last i2t values which were received from the device. These i2t values are updated asyncrono...
fxGetValidStreamingFrequencies
int fxGetValidStreamingFrequencies(unsigned int deviceId, int validFrequencies[NUM_TIMER_FREQS])
Get the valid frequencies for a device.
FxCurrent
@ FxCurrent
Voltage - Open Control Command.
Definition: device_wrapper.h:39
fxReadHabsoluteDeviceAll
int fxReadHabsoluteDeviceAll(unsigned int deviceId, HabsoluteState *readData, unsigned int n)
Read all exo data from a streaming FlexSEA Habsolute device. Must call fxStartStreaming before callin...
fxSetCurrentOffset
FxError fxSetCurrentOffset(unsigned int deviceId, int offset)
Set the current offset to the desired value.
fxGetReadDataQueueSize
int fxGetReadDataQueueSize(unsigned int deviceId)
Get the maximum read data queue size of a device.
fxStartStreaming
FxError fxStartStreaming(unsigned int deviceId, unsigned int frequency, bool shouldLog)
Start streaming data from a FlexSEA device and optionally log the streamed data. The data logger can ...
fxSetReadDataQueueSize
FxError fxSetReadDataQueueSize(unsigned int deviceId, unsigned int size)
Set the maximum read data queue size of a device.
fxReadCellScreenerDeviceAll
int fxReadCellScreenerDeviceAll(unsigned int deviceId, CellScreenerState *readData, unsigned int n)
Read all data from a streaming FlexSEA CellScreener device. Must call fxStartStreaming before calling...
fxRequestI2T
FxError fxRequestI2T(unsigned int deviceId)
Send an i2t values request to the specified device. The value is retrieved asyncronously and must be ...
fxGetTimingGain
double fxGetTimingGain(unsigned int deviceId, bool *isValid, double *highestTimingGain)
fxIsActiveDevice
bool fxIsActiveDevice(unsigned int deviceId)
Check if Device connection is still active and running.
fxReadBattCyclerDeviceAll
int fxReadBattCyclerDeviceAll(unsigned int deviceId, BattCyclerState *readData, unsigned int n)
Read all data from a streaming FlexSEA BattCycler device. Must call fxStartStreaming before calling t...
fxSetAnkleTorquePoints
FxError fxSetAnkleTorquePoints(unsigned int deviceId, int16_t *newAnkleTorque, uint8_t controller, uint8_t points)
Sends new Ankle Torque points to device (Read/Write)
fxIsOpen
bool fxIsOpen(unsigned int deviceId)
Check if the device with the given device ID is open.
FxCustom
@ FxCustom
No controller type. Shutoff command.
Definition: device_wrapper.h:42
fxStopStreaming
FxError fxStopStreaming(unsigned int deviceId)
Stop streaming data from a FlexSEA device.
fxReadDevice
FxError fxReadDevice(unsigned int deviceId, ActPackState *readData)
Read the most recent data from a streaming FlexSEA device stream. Must call fxStartStreaming before c...
fxReadAnkleTorquePoints
FxError fxReadAnkleTorquePoints(unsigned int deviceId, uint8_t points)
Reads new Ankle Torque points to device (pure read)
fxClose
FxError fxClose(unsigned int deviceId)
Disconnect from a FlexSEA device with the given device ID.
fxFindPoles
FxError fxFindPoles(unsigned int deviceId)
Find the motor poles.
fxReadDeviceAll
int fxReadDeviceAll(unsigned int deviceId, ActPackState *readData, unsigned int n)
Read all data from a streaming FlexSEA device stream. Must call fxStartStreaming before calling this.
fxGetDeviceIds
int fxGetDeviceIds(int *idArray, unsigned int size)
Get the device ID of all connected FlexSEA devices. The device ID is used by the functions in this AP...
fxReadBMSDevice
FxError fxReadBMSDevice(unsigned int deviceId, BMSState *readData)
Read the most recent data from a streaming FlexSEA BMS device. Must call fxStartStreaming before call...
fxOpen
int fxOpen(const char *portName, unsigned int baudRate, unsigned int logLevel)
Establish a connection with a FlexSEA device.
fxGetLastReceivedCurrentOffset
int fxGetLastReceivedCurrentOffset(unsigned int deviceId)
Check the last current offset which was received from the device. This current offset is updated asyn...
fxGetLastReceivedUVLO
int fxGetLastReceivedUVLO(unsigned int deviceId)
Check the last UVLO value which was received from the device. This UVLO value is updated asyncronousl...
NUM_TIMER_FREQS
#define NUM_TIMER_FREQS
Valid streaming frequencies.
Definition: device_wrapper.h:69
fxSetUniqueId
FxError fxSetUniqueId(unsigned int deviceId, unsigned int uid)
Set the Unique ID to the desired value.
fxCloseAll
void fxCloseAll()
Disconnect from all FlexSEA devices.
fxReadBattCyclerDevice
FxError fxReadBattCyclerDevice(unsigned int deviceId, BattCyclerState *readData)
Read the most recent data from a streaming FlexSEA BattCycler device. Must call fxStartStreaming befo...
fxGetLastReceivedAnkleTorquePoints
int16_t * fxGetLastReceivedAnkleTorquePoints(unsigned int deviceId)
Returns the last points read by the stack.
fxSendMotorCommand
FxError fxSendMotorCommand(unsigned int deviceId, FxControlMode controlMode, int value)
Send a command to the device.
fxReadHabsoluteDevice
FxError fxReadHabsoluteDevice(unsigned int deviceId, HabsoluteState *readData)
Read the most recent data from a streaming FlexSEA Habsolute device. Must call fxStartStreaming befor...
fxRequestCurrentOffset
FxError fxRequestCurrentOffset(unsigned int deviceId)
Send a current offset request to the specified device. The value is retrieved asynchronously and must...
fxReadCellScreenerDevice
FxError fxReadCellScreenerDevice(unsigned int deviceId, CellScreenerState *readData)
Read the most recent data from a streaming FlexSEA CellScreener device. Must call fxStartStreaming be...
fxIsBootloaderActivated
FxError fxIsBootloaderActivated(unsigned int deviceId)
Returns target bootloader status.
fxSendEventFlags
FxError fxSendEventFlags(int flag, int time)
fxActivateBootloader
FxError fxActivateBootloader(unsigned int deviceId, uint8_t target)
Activates target bootloader.
fxControlMode
fxControlMode
Definition: device_wrapper.h:35
fxReadBMSDeviceAll
int fxReadBMSDeviceAll(unsigned int deviceId, BMSState *readData, unsigned int n)
Read all exo data from a streaming FlexSEA BMS device. Must call fxStartStreaming before calling this...