Inertial sensor doesnt set heading properly

Whenever I try to calibrate the inertial sensor, it works fine. Then, when the code starts reading the gyro, I notice it will constantly tick up until it reaches a point. That angle is the angle it is from a certain point, that always being the same every time I restart the code / bot
My inertial sensor is called Gyro

while(true) {
inertial::quaternion Inertial_quaternion;
Inertial_quaternion = Gyro.orientation();
Brain.Screen.clearScreen();
Brain.Screen.setCursor(1, 1);
Brain.Screen.print(Gyro.rotation(degrees));
task::sleep(1);
}

1 Like

How have you mounted the inertial sensor ? if it is at an angle when you calibrate it will slowly drift to match the angle it is mounted at. What does the dashboard show ? does it do the same thing as your code ?

5 Likes

The dashboard on the v5 will only show acceleration, so that’s not helpful. I will remount the gyro tomorrow and see if that helps.

dashboard shows roll, pitch and yaw in addition to raw gyro and accelerometer data. Which angle are you having trouble with ?

5 Likes

I just updated the firmware to 1.0.9, and now it works.

1 Like

yes, I should have asked that, vexos 1.0.9 is required for correct inertial sensor operation.

5 Likes

Hi, Could you please paste the link for firmware 1.0.9? Thanks.

You can update your brain to the later vexOS using VEXcode V5 Text or Blocks, or by downloading the stand alone firmware updates from this page.

2 Likes

Thanks. Updated the brain but same problem. My robot is just spinning several rotations before it stops. Here is part of my code…

insangle = GyroAccel.heading(rotationUnits::raw);
wait(20, msec);

It gives me tiny readings which led to the robot spinning before reaching a set heading.

Is there a proper way of reading from the new V5 Inertial sensor?  

Thanks again

raw is not supported, use degrees or turns
(see the example code in VEXcode)

3 Likes