vmu931
Library for Variense VMU931 IMU
 All Data Structures Files Functions Variables Enumerations Enumerator Groups Pages
vmu931.h File Reference

Library public interface header. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  vmu_tx
 Data streamed for Heading. More...
 
struct  vmu_txyz
 Data streamed for Accelerometers, Gyroscopes, Magnetometers and Euler angles. More...
 
struct  vmu_twxyz
 Data streamed for Quaternions. More...
 
struct  vmu_text
 Textual data returned by device and library. More...
 
struct  vmu_status
 Device status - enabled sensors, resolution, rate and streamed data. More...
 
struct  vmu_size
 Array sizes for vmu_data arrays. More...
 
struct  vmu_data
 Structure with multiple types of data returned from the device. More...
 

Enumerations

enum  { VMU_MAX_STRING_SIZE =255 }
 
enum  vmu_sensors_enum { VMU_SENSORS_ACCEL =0x01, VMU_SENSORS_GYRO =0x02, VMU_SENSORS_MAG =0x04 }
 Constants used for determining enabled sensors. More...
 
enum  vmu_resolution_enum {
  VMU_RESOLUTION_ACCEL_2G =0x01, VMU_RESOLUTION_ACCEL_4G =0x02, VMU_RESOLUTION_ACCEL_8G =0x04, VMU_RESOLUTION_ACCEL_16G =0x08,
  VMU_RESOLUTION_GYRO_250DPS =0x10, VMU_RESOLUTION_GYRO_500DPS =0x20, VMU_RESOLUTION_GYRO_1000DPS =0x40, VMU_RESOLUTION_GYRO_2000DPS =0x80
}
 Constants used for determining and setting sensor resolution. More...
 
enum  vmu_stream_enum {
  VMU_STREAM_ACCEL =0x01, VMU_STREAM_GYRO = 0x02, VMU_STREAM_QUAT =0x04, VMU_STREAM_MAG =0x08,
  VMU_STREAM_EULER =0x10, VMU_STREAM_HEAD =0x40
}
 Constants used for setting and determining streamed data. More...
 
enum  vmu_retval_enum { VMU_ERROR =-1, VMU_OK =0, VMU_DATA_PENDING =1 }
 Constants returned by most of library functions. More...
 

Functions

int vmu_read_all (struct vmu *v, struct vmu_data *data)
 Read multiple types of data simultanously. More...
 
int vmu_stream (struct vmu *v, uint32_t stream)
 Make the device stream particular data types. More...
 
int vmu_resolution (struct vmu *v, uint32_t resolution)
 Set accelerometer and/or gyroscope resolutions. More...
 
int vmu_selftest (struct vmu *v, struct vmu_text *data)
 Command device to perform selftest. More...
 
int vmu_calibrate (struct vmu *v, struct vmu_text *data)
 Command device to perform calibration. More...
 
int vmu_status (struct vmu *v, struct vmu_status *data)
 Retrieve device status. More...
 
int vmu_fd (struct vmu *v)
 Get file descriptor used for serial communication with the device. More...
 
Init and teardown
struct vmuvmu_init (const char *tty)
 initialize internal library data. More...
 
int vmu_close (struct vmu *v)
 free library resources More...
 
Convinient read

Simplified read functions for single type of data (e.g. only euler). If you need to read multiple types of data use vmu_read_all instead.

Functions will block waiting for data unless last call returned value > size. Timeout with return value VMU_ERROR and errno EAGAIN indicates device is not sending data type for some reason.

Other data types are discarded silently without parsing.

Perfomance hints:

  • use vmu_stream so that device streams only data you need
Parameters
vpointer to internal library data
datauser supplied array
sizeuser supplied array size
Returns
  • value > size indicates user array was filled and more data is pending (without blocking)
  • value <= size indicates number of data points returned in array (next call will block)
  • VMU_ERROR indicates error, query errno for the details
See Also
vmu_stream, vmu_read_all

Example:

int status, i;
struct vmu_txyz euler[10];
while( (status=vmu_euler(v, euler, 10)) != VMU_ERROR )
{
for(i=0; i<status && i<10; ++i)
printf("[%lu ms] x=%f y=%f z=%f\n", euler[i].timeout_ms, euler[i].x, euler[i].y, euler[i].z);
}
int vmu_accel (struct vmu *v, struct vmu_txyz *data, int size)
 Read only accelerometer data.
 
int vmu_gyro (struct vmu *v, struct vmu_txyz *data, int size)
 Read only gyroscope data data.
 
int vmu_mag (struct vmu *v, struct vmu_txyz *data, int size)
 Read only magnetometer data.
 
int vmu_euler (struct vmu *v, struct vmu_txyz *data, int size)
 Read only euler data.
 
int vmu_quat (struct vmu *v, struct vmu_twxyz *data, int size)
 Read only quaternion data.
 
int vmu_head (struct vmu *v, struct vmu_tx *data, int size)
 Read only heading data.
 

Detailed Description

Library public interface header.