The Femto Bolt device contains an Inertial Measurement Unit (IMU) with accelerometer and gyroscope. To get IMU data, you first need to open the device, then start the IMU, and get IMU samples. See Find and Open Devices.
Since the IMU sampling rate is much higher than image frame rates, and the application gets IMU at a lower rate than IMU sampling, each time the application receives IMU data, it will receive multiple IMU samples at once.
See Femto Bolt Hardware Specifications for details on IMU rates.
Configure and Start Cameras
Note: The IMU in Femto Bolt is independent of the depth and color cameras, so IMU data can be output separately. This differs from Azure Kinect, but for consistency we still start color or depth cameras first before starting the IMU.
To start cameras, use k4a_device_start_cameras().
k4a_device_configuration_t config = K4A_DEVICE_CONFIG_INIT_DISABLE_ALL; config.camera_fps = K4A_FRAMES_PER_SECOND_30; config.color_format = K4A_IMAGE_FORMAT_COLOR_MJPG; config.color_resolution = K4A_COLOR_RESOLUTION_2160P; if (K4A_RESULT_SUCCEEDED != k4a_device_start_cameras(device, &config)) { printf("Failed to start cameras\n"); goto Exit; } if (K4A_RESULT_SUCCEEDED != k4a_device_start_imu(device)) { printf("Failed to start imu\n"); goto Exit; }
Get IMU Data
Each k4a_imu_sample_t contains accelerometer and gyroscope data captured at the same time.
You can get IMU data in the same thread as getting image data or in a different thread.
For fast IMU acquisition, use a separate thread where you call k4a_device_get_imu_sample() to get IMU samples.
Since IMU data is first queued internally in the SDK, you can get and process data without dropping:
- Wait to capture data at a fixed rate (can’t be too low due to finite queue length, usually no more than 100ms interval)
- Process data when captured
- Get and process all data already queued
- Loop the above steps
In step 3 you can call k4a_device_get_imu_sample() in a loop with timeout_in_ms = 0 until K4A_WAIT_RESULT_TIMEOUT is returned, indicating no queued data and no data arrived within the timeout.
Example
k4a_imu_sample_t imu_sample; // Capture a imu sample switch (k4a_device_get_imu_sample(device, &imu_sample, TIMEOUT_IN_MS)) { case K4A_WAIT_RESULT_SUCCEEDED: break; case K4A_WAIT_RESULT_TIMEOUT: printf("Timed out waiting for a imu sample\n"); continue; break; case K4A_WAIT_RESULT_FAILED: printf("Failed to read a imu sample\n"); goto Exit; } // Access the accelerometer readings if (imu_sample != NULL) { printf(" | Accelerometer temperature:%.2f x:%.4f y:%.4f z: %.4f\n", imu_sample.temperature, imu_sample.acc_sample.xyz.x, imu_sample.acc_sample.xyz.y, imu_sample.acc_sample.xyz.z); }
Next Steps
Now that you know how to get IMU data, you can explore other capabilities:《Image Transformation》