IMU initialization failed

2,802 views
Skip to first unread message

MANUJ KUSHWAHA

unread,
Sep 17, 2018, 8:31:15 AM9/17/18
to LINOROBOT
on running minimal.launch after connecting IMU-9250 to teensy 3.5 i am getting the following errors:

[ekf_localization-8] process has died [pid 2550, exit code -11, cmd /opt/ros/kinetic/lib/robot_localization/ekf_localization_node odometry/filtered:=odom __name:=ekf_localization __log:=/home/manuj/.ros/log/18d1f5ba-ba6b-11e8-8710-fbbd4c816412/ekf_localization-8.log].
log file
: /home/manuj/.ros/log/18d1f5ba-ba6b-11e8-8710-fbbd4c816412/ekf_localization-8*.log
 
[FATAL] [1537182981.899784]: IMU failed to initialize. Check your IMU connection.


I have followed the getting started and base controller chapter of the documentation. There was another post with a similar error on the group but that is also not resolved.
I have modified the base_config file and uncommented the line relating to IMU9250. I am also attaching an image showing the IMU connections.
Does anyone have any idea how to rectify this error.
IMG_20180917_173852.jpg

Juan Miguel Jimeno

unread,
Sep 17, 2018, 9:54:07 AM9/17/18
to LINOROBOT
Hi,

Can you try the following:

1. Temporarily replace firmware.ino with these codes: https://gist.github.com/grassjelly/ef3b8f5741feaf2784526fb0c975bfb0

2. Upload the firmware:
pio run —target upload

3. Check the device id:
screen /dev/linobase 9600
or
screen /dev/ttyACM0 9600

Please post a screenshot of the results here.

Thanks

MANUJ KUSHWAHA

unread,
Sep 17, 2018, 11:00:24 AM9/17/18
to LINOROBOT
On following the above commands I get a blank terminal screen. On closing and repeating the command
screen /dev/linobase 9600
 a message is displayed that
[screen is terminating]


What else can I try?
Can you speculate if the error is on the hardware side or software side?

Juan Miguel Jimeno

unread,
Sep 17, 2018, 11:18:37 AM9/17/18
to LINOROBOT
Have you successfully uploaded the firmware after the pasting the codes from the link? Basically, this gets the device id of your IMU.

When you run minimal/bringup.launch, it checks if the IMU is connected by getting the device ID. This error happens if there's a hardware problem or the replied ID from the IMU doesn't match the listed IDs. https://github.com/linorobot/linorobot/blob/master/teensy/firmware/lib/imu/MPU9250.cpp#L77

If you can get the temporary code running, we can get the ID and append it into the list of known devices. You can also try using 9150 by uncommenting  this: https://github.com/linorobot/linorobot/blob/master/teensy/firmware/lib/config/lino_base_config.h#L19

MANUJ KUSHWAHA

unread,
Sep 17, 2018, 12:09:44 PM9/17/18
to LINOROBOT
I have saved the code that you provided in the link above but i get the same blank screen.
I also uploaded the above code to teensy via the arduino software but i get the error:

Arduino: 1.8.5 (Linux), TD: 1.43, Board: "Teensy 3.5, Serial, 120 MHz, Faster, US English"

sketch_sep17b
:10: error: no matching function for call to 'MPU9250::MPU9250()'
 MPU9250 imu
;
         
^
In file included from /home/manuj/Arduino/sketch_sep17b/sketch_sep17b.ino:8:0:
/home/manuj/Arduino/libraries/MPU9250-master/src/MPU9250.h:72:5: note: candidate: MPU9250::MPU9250(SPIClass&, uint8_t)
     MPU9250
(SPIClass &bus,uint8_t csPin);
     
^
/home/manuj/Arduino/libraries/MPU9250-master/src/MPU9250.h:72:5: note:   candidate expects 2 arguments, 0 provided
/home/manuj/Arduino/libraries/MPU9250-master/src/MPU9250.h:71:5: note: candidate: MPU9250::MPU9250(TwoWire&, uint8_t)
     MPU9250
(TwoWire &bus,uint8_t address);
     
^
/home/manuj/Arduino/libraries/MPU9250-master/src/MPU9250.h:71:5: note:   candidate expects 2 arguments, 0 provided
/home/manuj/Arduino/libraries/MPU9250-master/src/MPU9250.h:31:7: note: candidate: constexpr MPU9250::MPU9250(const MPU9250&)
 
class MPU9250{
       
^
/home/manuj/Arduino/libraries/MPU9250-master/src/MPU9250.h:31:7: note:   candidate expects 1 argument, 0 provided
/home/manuj/Arduino/libraries/MPU9250-master/src/MPU9250.h:31:7: note: candidate: constexpr MPU9250::MPU9250(MPU9250&&)
/home/manuj/Arduino/libraries/MPU9250-master/src/MPU9250.h:31:7: note:   candidate expects 1 argument, 0 provided
sketch_sep17b
: In function 'void loop()':
sketch_sep17b
:19: error: 'class MPU9250' has no member named 'getDeviceID'
     
Serial.println(imu.getDeviceID(), HEX);
                       
^
no matching function for call to 'MPU9250::MPU9250()'

I have also run the below mentioned code on the teensy and on arduino using the arduino software and i get 9 columns of data.


/*
Basic_I2C.ino
Brian R Taylor
brian....@bolderflight.com

Copyright (c) 2017 Bolder Flight Systems

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/


#include "MPU9250.h"

// an MPU9250 object with the MPU-9250 sensor on I2C bus 0 with address 0x68
MPU9250 IMU
(Wire,0x68);
int status;

void setup() {
 
// serial to display data
 
Serial.begin(115200);
 
while(!Serial) {}

 
// start communication with IMU
  status
= IMU.begin();
 
if (status < 0) {
   
Serial.println("IMU initialization unsuccessful");
   
Serial.println("Check IMU wiring or try cycling power");
   
Serial.print("Status: ");
   
Serial.println(status);
   
while(1) {}
 
}
}

void loop() {
 
// read the sensor
  IMU
.readSensor();
 
// display the data
 
Serial.print(IMU.getAccelX_mss(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getAccelY_mss(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getAccelZ_mss(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getGyroX_rads(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getGyroY_rads(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getGyroZ_rads(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getMagX_uT(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getMagY_uT(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getMagZ_uT(),6);
 
Serial.print("\t");
 
Serial.println(IMU.getTemperature_C(),6);
  delay
(100);
}

when run on Arduino I get the desired output with columns of data but
when i run this program on teensy i get the output
IMU initialization unsuccessful
Check IMU wiring or try cycling power
Status: -1

My wiring is correct as far as i know
MPU9250:
Vin=3.3V
G=G
SCL0=19
SCA0=18

MANUJ KUSHWAHA

unread,
Sep 17, 2018, 12:13:49 PM9/17/18
to LINOROBOT
continuation of previous post: remaining code

Serial.print("\t");
 
Serial.print(IMU.getMagX_uT(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getMagY_uT(),6);
 
Serial.print("\t");
 
Serial.print(IMU.getMagZ_uT(),6);
 
Serial.print("\t");
 
Serial.println(IMU.getTemperature_C(),6);
  delay
(100);
}

on running this code on arduino Mega i get the desired output ie. columns of data but when i run this on teensy 3.5 i get the error:

IMU initialization unsuccessful
Check IMU wiring or try cycling power
Status: -1

My Wiring(MPU9250)
Vin=3.3V
G=G
SCL=19
SDA18

Juan Miguel Jimeno

unread,
Sep 18, 2018, 1:09:31 AM9/18/18
to LINOROBOT

Can you try bypassing the IMU check temporarily? Replace this line https://github.com/linorobot/linorobot/blob/master/teensy/firmware/src/firmware.ino#L119 with:

imu_is_initialized = true;

Subscribe to raw_imu after launching minimal.launch to check if the IMU works:

rostopic echo raw_imu


MANUJ KUSHWAHA

unread,
Sep 18, 2018, 3:03:31 AM9/18/18
to LINOROBOT
I did the above and now i get the prompt that IMU is initialized but no data is published on the topic /imu/data_raw and i get the error:

[ WARN] [1537253594.957080178]: Still waiting for data on topics /imu/data_raw and /imu/mag...
[ERROR] [1537253601.433153]: Lost sync with device, restarting...

On doing rostopic echo raw_imu on a new terminal i get no output as i guess no data is being published.

Is it because the IMU9250 I am using is maybe not the original one? Although it works with Arduino Mega. Can you send link of the one that you used.
I am attaching a picture of my IMU for reference.

MANUJ KUSHWAHA

unread,
Sep 18, 2018, 3:31:43 AM9/18/18
to LINOROBOT
Images of my MPU9250
IMG_20180918_123032.jpg
IMG_20180918_123022.jpg

Juan Miguel Jimeno

unread,
Sep 18, 2018, 4:07:51 AM9/18/18
to LINOROBOT

IMG_1560.jpg


This is what I'm using. Just tried your setup on my computer, Teensy 3.6 - MPU9250 and it works just fine. 


Few more things:

Are you using the latest version of Linorobot?

Were there any changes on the pin assignments? If so, make sure nothing is assigned to pins 18, and 19.

Can you try using an external supply to power the IMU temporarily? Your Arduino Mega's 5V out would suffice. (In case the sensor is under-powered)




MANUJ KUSHWAHA

unread,
Sep 18, 2018, 4:28:59 AM9/18/18
to LINOROBOT
I tried your earlier code to get the device id again. on opening the serial port of the arduino software i am getting "Device ID: 0"

Yes I am using the version of Linorobot that i installed two days back.
No i made no other changes to the code so there are no changes to pin assignments. I got the voltage of the pins using a multimeter. Both the SCL and SDA pins are always HIGH, give output of 3.3V. the Vin pin gets an input of 3.2 Volts.

As i am getting the readings on teensy 3.5 using the BasicI2c code that i have shown above, uploaded to the teensy using the arduino software, so i think that the sensor is not underpowered.

At the back of your sensor 9250/6500 is written while at the back of mine 92/65 is written. Can the error be due to this mismatch in hardware?

As i am getting the values using the Basic I2C code i mentioned above, is there any way to modify the firmware.ino code so that i can input these values directly to the raw_imu_msg.linear_acceleration = readAccelerometer(); by inputting that value instead of the readAccelerometer() function?

Juan Miguel Jimeno

unread,
Sep 18, 2018, 4:49:53 AM9/18/18
to LINOROBOT
Yes you can do that.

You can check these codes to see how it is implemented: 


Can you share the source code that's working?

MANUJ KUSHWAHA

unread,
Sep 18, 2018, 5:27:09 AM9/18/18
to LINOROBOT
Hey I used an MPU-6050 and the code now works. Thanks for all the help

I suspect the IMU I had was a different variant of 9250.

Kim Olesen

unread,
Mar 18, 2020, 2:48:59 PM3/18/20
to LINOROBOT
Hi

There might be an error in teensy/firmware/lib/imu/MPU9250.cpp
My MPU9250 have different device_id, i changed if(device_id == 0x38 || device_id == 0x71) to
if(device_id == 0x38 || || device_id == 0x39 || device_id == 0x68 || device_id == 0x71).

Original part of code:
bool MPU9250::testConnection() {
   uint8_t device_id = getDeviceID();

    if(device_id == 0x38 || device_id == 0x71)
       return true;
   else
        return false;
}



Message has been deleted

Gowresh R

unread,
May 20, 2020, 3:43:27 AM5/20/20
to LINOROBOT
I can confirm that this solution works. Turns out my device id was 0x39.
Message has been deleted

albert ivanov

unread,
Jul 9, 2020, 11:30:45 AM7/9/20
to LINOROBOT
I stack with this issue when work with arduino mega - nothing helped ((
I get used your code (are there a mistake in it -0x38 || || device_id -||  used twice ?)  , 
checked 3 time connection, tried to swith SCL and SDA
tried 3,3 V and 5V logic, 
Perhaps, IMU is dead ... ?

albert ivanov

unread,
Jul 10, 2020, 1:26:17 PM7/10/20
to LINOROBOT
hm...i seems i found the way out ! ))
the problem is that arduino mega uses 21 and 20 pins for SCL,SDA respectively.

So, just connected IMU to 21,20 pins (SLC to SCL, SDA to SDA) and that`s it ))

ps. do not forget to change pins in firmware.ino as 20,21 pins get used to MOTOR2.
Reply all
Reply to author
Forward
0 new messages