Skip to content

When using the mpu9250-jmdev library with the mpu9250 IMU an OSError: [Errno 121] Remote I/O error occurs when attempting to access the magnetometer #1190

@TCIII

Description

@TCIII

Hardware: RPi 4B 4GB
OS: Bullseye
DC: v5.0.dev3
MPU: mpu9250 on Robo HAT MM1 at hex address 0x69

IMU configuration in myconfig.py:

# IMU for imu model
HAVE_IMU = True
IMU_SENSOR = 'mpu9250'          # (mpu6050|mpu9250)
IMU_ADDRESS = 0x69
IMU_DLP_CONFIG = 3

Result when running manage.py drive from the CLI:

using donkey v5.0.dev3 ...
INFO:donkeycar.config:loading config file: /home/tciii/mycar/config.py
INFO:donkeycar.config:loading personal config over-rides from myconfig.py
Traceback (most recent call last):
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 96, in configure
    self.configureAK8963(self.mfs, self.mode)
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 232, in configureAK8963
    self.writeAK(AK8963_CNTL1, 0x00, 0.1)
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 1012, in writeAK
    self.bus.write_byte_data(self.address_ak, register, value)
  File "/usr/local/lib/python3.9/dist-packages/smbus2/smbus2.py", line 455, in write_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 96, in configure
    self.configureAK8963(self.mfs, self.mode)
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 232, in configureAK8963
    self.writeAK(AK8963_CNTL1, 0x00, 0.1)
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 1012, in writeAK
    self.bus.write_byte_data(self.address_ak, register, value)
  File "/usr/local/lib/python3.9/dist-packages/smbus2/smbus2.py", line 455, in write_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tciii/mycar/manage.py", line 494, in <module>
    drive(cfg, use_joystick=args['--js'], camera_type=args['--camera'])
  File "/home/tciii/mycar/manage.py", line 113, in drive
    add_imu(V, cfg)
  File "/home/tciii/projects/donkeycar/donkeycar/templates/complete.py", line 917, in add_imu
    imu = IMU(sensor=cfg.IMU_SENSOR, addr=cfg.IMU_ADDRESS,
  File "/home/tciii/projects/donkeycar/donkeycar/parts/imu.py", line 55, in __init__
    self.sensor.configure()
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 101, in configure
    self.configure(retry - 1)
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 101, in configure
    self.configure(retry - 1)
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 104, in configure
    raise err
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 96, in configure
    self.configureAK8963(self.mfs, self.mode)
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 232, in configureAK8963
    self.writeAK(AK8963_CNTL1, 0x00, 0.1)
  File "/home/tciii/env/lib/python3.9/site-packages/mpu9250_jmdev/mpu_9250.py", line 1012, in writeAK
    self.bus.write_byte_data(self.address_ak, register, value)
  File "/usr/local/lib/python3.9/dist-packages/smbus2/smbus2.py", line 455, in write_byte_data
    ioctl(self.fd, I2C_SMBUS, msg)
OSError: [Errno 121] Remote I/O error

Since the mpu9250 is a combination of the mpu6050 imu and the the AK8963 magnetometer, using the mpu6050-raspberrypi library in place of the mpu9250-jmdev library allows error free access to only the mpu6050 imu.

TCIII

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions