Arduino + LSM6DS33 + Romi

Hello all

I am trying to write code on the Romi bot Pololu - Romi Chassis Kit - Red which uses the Arduino*-compatible ATmega32U4 MCU board. This also has a IMU LSM6DS33 installed.

All i want is to write a function say void turn(90) and the romi bot should turn 90 degrees.

I have tried the following sketch from examples to read the Z value where Romi is pointing. If romi is not moving ( which it is not) i expect the Z value to be same... but its not so.. the Z value keeps changing as if the romi is moving :frowning: what am i doing wrong or what do i need to do more...

// ****** START CODE********//

#include <Wire.h>
#include <LSM6.h>

LSM6 imu;

char report[80];

void setup()
{
  Serial.begin(9600);
  Wire.begin();

  if (!imu.init())
  {
    Serial.println("Failed to detect and initialize IMU!");
    while (1);
  }
  imu.enableDefault();
}

void loop()
{
  imu.read();

  snprintf(report, sizeof(report), "A: %6d %6d %6d    G: %6d %6d %6d",
    imu.a.x, imu.a.y, imu.a.z,
    imu.g.x, imu.g.y, imu.g.z);
  Serial.println(report);

  delay(100);
}

//******* END CODE*********//```


The code compiles and runs but even if romi is not moving i keep getting values of Z that are not the same. My expectation is that if the Romi is not moving then Z value should not change..

sample out put The last col is the gyroscope Z value and it keeps changing

A:    367     -8  16750    G:    285   -263   -748
A:    435     37  16612    G:    206   -189   -616
A:    316    -12  16641    G:    261   -489   -602
A:    321     -2  17027    G:    230   -147   -628
A:    583    -13  16615    G:    204      9   -558
A:    298    -12  16711    G:    223    -44   -733

Anyone!!!!!

The gyroscope reports the rates of rotation around three axes, not angles.

To estimate angles, you first have to calibrate the gyroscope offsets, then integrate the corrected rates with respect to time.

For the offset correction, measure a few hundred gyroscope values while it is sitting still, average the values, then subtract the resulting offsets from subsequent readings.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.