IPC Module - Gyroscope Service
This page contains documentation of the gyroscope part of IMU API.
According to the interface description, the values in the
a_ipc_msg_gyro_publish_ind comes as an array of bytes. To be able to read
out the actual values, these bytes need to be re-composed to an
gyro_sample struct.
struct gyro_sample {
int16_t x;
int16_t y;
int16_t z;
int16_t pad;
int64_t ts;
} __attribute__ ((__packed__));
Gyroscope sample units: - x, y and z are reported in 1000x rad/s - Equivalent unit: mrad/s (milli-radians per second)
Here is an example of how to do this:
static void handle_publish_ind(a_ipc_msg* message)
{
struct gyro_sample {
int16_t x;
int16_t y;
int16_t z;
int16_t pad;
int64_t ts;
} __attribute__ ((__packed__));
struct gyro_sample* samples = (struct gyro_sample*)
message->gyro_publish_ind.sample_buffer.value;
int number_of_samples =
message->gyro_publish_ind.sample_buffer.length /
sizeof(struct gyro_sample);
for (int i = 0; i < number_of_samples; i++)
{
printf("Received values (sample %d of %d):\n", i + 1, number_of_samples);
printf("x: %i\n", samples[i].x);
printf("y: %i\n", samples[i].y);
printf("z: %i\n", samples[i].z);
printf("time stamp: %lu\n", samples[i].ts);
}
exit_main_loop_with_return_code(0);
}
Messages
Enums
- enum gyro_result
Result codes.
Constant
Value
Description
OK
0
OK
ERROR
1
Error
- enum gyro_data_profile
Gyroscope data profile.
Constant
Value
Description
BALANCED
0
Data profile 1 (default). General-purpose configuration offering a solid compromise between resolution, responsiveness, and dynamic range. Suitable for a wide variety of environments and motion types.
FINE_MOTION
1
Data profile 2 (fine_motion). Prioritizes measurement precision with low noise and high stability. Uses a lower full-scale range and stronger filtering; intended for fine motion tracking and applications requiring maximum signal detail at the cost of responsiveness and increased susceptibility to vibration.
ROBUST
2
Data profile 3 (robust). Optimized for large shocks, fast rotations, and high-dynamic motion. Uses an extended full-scale range; intended to avoid saturation in harsh or demanding environments at the cost of increased noise and reduced resolution.