'Unable to get imu streams in my realsense camera D435i

I am trying to get IMU data from D435i camera but unable to do so. Browsing various github issues, I got the code snippet which is straight forward but for some reason it's still not working. Any help will be really grateful.

Below is the snippet I am using:

import numpy as np             
import pyrealsense2 as rs      

pipeline = rs.pipeline()       
config = rs.config()
config.enable_stream(rs.stream.accel, rs.format.motion_xyz32f, 200)
config.enable_stream(rs.stream.gyro, rs.format.motion_xyz32f, 200)
pipeline.start(config)
  
while True:
    frames = pipeline.wait_for_frames()      
    for frame in frames:       
        motion_data = frame.as_motion_frame().get_motion_data()
        print(np.array([motion_data.x, motion_data.y, motion_data.z]))

The error comes on line pipeline.start(config) where it says, RuntimeError: Couldn't resolve requests for some reason. librealsense version I am using is 2.14



Solution 1:[1]

I think that your program is failing because the D435i's gyro and accelerometer works at different rates.

Please see the example below for the pipeline configuration:

pipeline = rs.pipeline()
config = rs.config()
# Configuring streams at different rates
# Accelerometer available FPS: {63, 250}Hz
config.enable_stream(rs.stream.accel, rs.format.motion_xyz32f, 250)  # acceleration
# Gyroscope available FPS: {200,400}Hz
config.enable_stream(rs.stream.gyro, rs.format.motion_xyz32f, 200)  # gyroscope
pipeline.start(config)

More information can be found here: https://www.intelrealsense.com/how-to-getting-imu-data-from-d435i-and-t265/

Solution 2:[2]

Gyro and Accelerometer streams have 2 different possible framerates you can choose for the d435i

For Accel u can either choose 250 or 63. For Gyro its 200 or 400

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lucian Tarb?
Solution 2 MyOtherNamesWereTaken