FlexSEA Wiki

A WEARABLE ROBOTICS TOOLKIT

User Tools

Site Tools


commandsandoffsets

Commands and Offsets

FlexSEA data packets are limited to 48 bytes, with 30 bytes of payload. Since some sensor reading functions require more data, we use offsets to send and properly decode different values. Offsets are essentially sub-commands. As an example, let's look at the cmd-Rigid.c (and more specifically, at the tx_cmd_rigid_w() function. CMD_READ_ALL_RIGID is used, as its name indicates, to read all of the data from a FlexSEA-Rigid circuit. Since it has multiple sensors, a single data packet can't be used. A Read request will include an offset number. In the excerpt below we look at the TX code (the code used to reply to a read request).

//Arguments:
if(offset == 0)
{
	SPLIT_32(ri->ctrl.timestamp, shBuf, &index);
	SPLIT_16((uint16_t)ri->mn.gyro.x, shBuf, &index);
	SPLIT_16((uint16_t)ri->mn.gyro.y, shBuf, &index);
	SPLIT_16((uint16_t)ri->mn.gyro.z, shBuf, &index);
	SPLIT_16((uint16_t)ri->mn.accel.x, shBuf, &index);
	SPLIT_16((uint16_t)ri->mn.accel.y, shBuf, &index);
	SPLIT_16((uint16_t)ri->mn.accel.z, shBuf, &index);
	SPLIT_16((uint16_t)*(encoder), shBuf, &index);
	SPLIT_16((uint16_t)*(encoderVel), shBuf, &index);
	SPLIT_16((uint16_t)*(ri->ctrl.ank_ang_from_mot), shBuf, &index);
	SPLIT_16((uint16_t)ri->ex.strain, shBuf, &index);
	SPLIT_16((uint16_t)(ri->ex.ctrl.current.setpoint_val >> 3), shBuf, &index);
	//(28 bytes)
}
else if(offset == 1)
{
	SPLIT_32(ri->ctrl.timestamp, shBuf, &index);
	SPLIT_32((uint32_t)*(ri->ex.enc_ang), shBuf, &index);
	SPLIT_32((uint32_t)*(ri->ex.enc_ang_vel), shBuf, &index);
	SPLIT_32((uint32_t)ri->ex.mot_acc, shBuf, &index);
	SPLIT_16((uint16_t)(ri->ex.mot_current >> 3), shBuf, &index);
	SPLIT_16((uint16_t)(ri->ex.mot_volt >> 3), shBuf, &index);
	SPLIT_16(rigid1.re.vb, shBuf, &index);
	SPLIT_16((uint16_t)rigid1.re.current, shBuf, &index);
	shBuf[index++] = rigid1.re.temp;
	SPLIT_16(rigid1.re.status, shBuf, &index);
	shBuf[index++] = (uint8_t)ri->ctrl.walkingState;
	shBuf[index++] = (uint8_t)ri->ctrl.gaitState;
	//(29 bytes)
}

Offset 0 has all the IMU data, as well as encoder and force sensor readings. Offset 1 has motor control variables and state variables. Three other offsets have different payloads. Depending on the application, one can read from all offsets, or from a subset of them.

You can select the offsets being read from with the command line available on specific commands:

Streaming N offsets will mean that for a specify variable, the refresh rate will be divided by N. In the example above we have 4 offsets and 100Hz. The display and log will be updated at 100Hz, but sensors whose value is only contained in one offset will only see their value updated every 4th packet. For example, the IMU data will be refreshed at 25Hz. On the images below, you can see the difference between reading 1 and 4 offsets on the same signal (gyro X).

If you use the Plan GUI to log data you'll see a column that contains the last decoded offset. You can use it as part of your signal processing to only read lines where the data changed (offset 0 in that example).

commandsandoffsets.txt · Last modified: 2018/03/05 14:49 by jfduval