Skip to content

IMU Calibration

AutoModelCar edited this page May 15, 2018 · 6 revisions

IMU calibration steps

Program IMU_Zero library on Arduino

From your computer

You can program the arduino from your computer following steps below:

  • Turn off the car, disconnect the odroid power cable
  • Connect the ardunio usb to your computer
  • Open serial port "sudo chmod 777 /dev/ttyUSB0"
  • Compile IMU_Zero library and program it on the ardunio

From Odroid

Copy hex file to the odroid and program the code from odroid. upload-hex-file-from-odroid-to-arduino

    /opt/arduino-1.8.5/hardware/tools/avr/bin/avrdude -C/opt/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyArduino -b57600 -D -Uflash:w:/root/IMU_Zero.ino.eightanaloginputs.hex:i

Read Arduino Output

Rplidar

Turn on the car, run the rplidar.launch node:

   pkill ros
   roslaunch rplidar_ros rplidar.launch

Show output of arduino

You can use the terminal program minicom to see the output of the arduino board in the odroid terminal window. It should be installed by default. Setup the correct serial port and baud rate first:

minicom -s

Then select 'Serial port setup'. Change 'Serial Device' to /dev/ttyArduino and 'Bps/Par/Bits' to 115200 8N1 (for main.ino) or 9600 8N1 (for initial IMU calibration with IMU_Zero.ino). After that press Enter to go back to main menu. In the 'Screen and keyboard' section you may set the 'Add carriage return' option to Yes. In the main menu select 'Save setup as dfl' and 'Exit from Minicom' to close minicom.

Open minicom again without the setup flag:

minicom

Now you can see the output of the running arduino program. To close the program press Ctrl+A, then Z to open the menu and Q (when pressing X here the configuration will be reset).

Hint: Wait 3 minutes and read the results.

Update main.ino

  • Update your main.ino source based on the the numbers

    // supply your own gyro offsets here, scaled for min sensitivity
    mpu.setXAccelOffset(-1643); 
    mpu.setYAccelOffset(589); 
    mpu.setZAccelOffset(1333); // 1688 factory default for my test chip
    mpu.setXGyroOffset(418);
    mpu.setYGyroOffset(-57);
    mpu.setZGyroOffset(69);
    
  • Compile again the main.ino and program it to the arduino

      /opt/arduino-1.8.5/hardware/tools/avr/bin/avrdude -C/opt/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyArduino -b57600 -D -Uflash:w:/root/main.ino.eightanaloginputs.hex:i
    

Clone this wiki locally