vmu931
Library for Variense VMU931 IMU
|
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... | |
struct | vmu |
Internal library data passed around by the user. 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 vmu * | vmu_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 Functions will block waiting for data unless last call returned value > Other data types are discarded silently without parsing. Perfomance hints:
Example: | |||||||
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. | |||||||
enum vmu_resolution_enum |
Constants used for determining and setting sensor resolution.
enum vmu_retval_enum |
enum vmu_sensors_enum |
Constants used for determining enabled sensors.
enum vmu_stream_enum |
Constants used for setting and determining streamed data.
Command device to perform calibration.
Blocks for around 4 seconds while device performs calibration. All textual data output by the device is concatenated in data
argument. All non-textual data is discarded during the process. The device needs to remain still on a flat surface with its Z-axis pointing upward during the process. You don't have to repeat this procedure every time you power on the sensor.
Note - there is undocummented (VMU User Guide 1.3) magnetometer calibration procedure. Magnetometer calibration is essential to reduce drift on Z (heading) axis. While powering up the sensor move it around in multiple orientations. Do it until the Euler angles indicates 0 degrees while the sensor has its Y axis pointing North. As of firmware 1.01 this has to be repeated every time you power on the sensor.
v | pointer to internal library data |
data | argument filled with textual data |
data
for the detailsdata
and errno for the details int vmu_close | ( | struct vmu * | v | ) |
free library resources
Frees memory and restores terminal settings.
May be safely called with NULL argument.
v | pointer to internal library data |
Example:
int vmu_fd | ( | struct vmu * | v | ) |
Get file descriptor used for serial communication with the device.
Library user should not directly read or write from or to descriptor. This function is intended to be used in synchronous I/O multiplexing (select, poll).
v | pointer to internal library data |
struct vmu* vmu_init | ( | const char * | tty | ) |
Read multiple types of data simultanously.
Use this function if you need to read multiple types of data (e.g. euler and magnetometer).
If you care only about single data type use one of convinience functions instead.
Function will block waiting for data unless last call returned VMU_DATA_PENDING. Timeout with return value VMU_ERROR and errno EAGAIN indicates device is not sending data types for some reason.
Data types with 0 size in data
parameter are discarded silently without parsing.
Perfomance hints:
v | pointer to internal library data |
data | user supplied arrays with sizes |
data
parameter were filleddata
parameter was filled completely and more data is pending (without blocking)int vmu_resolution | ( | struct vmu * | v, |
uint32_t | resolution | ||
) |
Set accelerometer and/or gyroscope resolutions.
Blocks until resolution is set, error or timeout occurs.
Streaming Heading, Euler or Quaternion data forces:
It setting resolution only for accelerometer or gyroscope the second remains unchanged.
errno values:
resolution
argument is not sanev | pointer to internal library data |
resolution | logical combination of vmu_resolution_enum values |
resolution
argument, query errno for the detailsExample:
Command device to perform selftest.
Blocks for around 2 seconds while device performs selftest. All textual data output by the device is concatenated in data
argument. All non-textual data is discarded during the process.
The device needs to remain still on a flat surface with its Z-axis pointing upward during the process.
v | pointer to internal library data |
data | argument filled with textual data |
data
for the detailsdata
and errno for the details int vmu_status | ( | struct vmu * | v, |
struct vmu_status * | data | ||
) |
Retrieve device status.
Blocks until device returns status, error or timeout occurs.
Non status data types are discarded while waiting for device status.
v | pointer to internal library data |
data | argument filled with status data |
int vmu_stream | ( | struct vmu * | v, |
uint32_t | stream | ||
) |
Make the device stream particular data types.
Function blocks until one of:
v | pointer to internal library data |
stream | logical sum of values from vmu_stream_enum |
Example: