Reading IMU Data From Sensor#
The dwSensorIMU_readFrame() function reads the next available IMU data frame with a given timeout. The function call is blocking, until an
IMU frame is available or the timeout is exceeded. Frames read from the sensor do not have to be returned because the messages are copied.
Depending on the particular IMU sensor capabilities, an IMU frame can be only partially filled with data. The dwIMUFlags are used to
indicate which fields in dwIMUFrame are valid.
Example#
The following code shows the general structure of a program reading data from an IMU sensor.
dwSensorParams params;
params.protocol = "imu.uart";
params.parameters = "device=/dev/<serial device>,baud=<baudrate>";
dwSensorHandle_t imuSensor;
dwSAL_createSensor(&imuSensor, params, ...);
dwSensor_start(imuSensor);
while(loop)
{
dwIMUFrame frame;
dwSensorIMU_readFrame(&frame, 50000, imuSensor);
...
}
dwSensor_stop(imuSensor);
dwSAL_releaseSensor(&imuSensor);
For more details see IMU Logger Sample