V5 Inertial Sensor Drifting

Background: I’m running an Intro HS class for engineering and robotics for kids who have had zero experience with robotics. We are only using VEXcode V5 Blocks programming (no students or myself know C++ or Python); the 9 unit VEXcode VR online course has been completed by all students and they all are reasonably prepared to program the Clawbots that we are currently building. In preparation to use the V5 Inertial Sensor on our Clawbots, I have found that the sensors drift a decent amount and I can’t figure out how to correct the problem. I have tried a very simple block code to run 500mm and turn 90 degrees (repeating this 4 times) to make a square, just to test out the sensor. The sensor does not seem to self correct and maintain 90 degrees on each turn and progressively gets off track. I have tried the following: verified that the sensor does not need calibration (even swapped one out with another); I slowed down the drive and turn velocities to 20%; I put wait 2 sec “Wait” commands after each turn to allow for self correction; I’ve tried using different commands for turning (“Turn right”, “turn to heading”,“turn to rotation”). I’m not sure if I need to write something additional into the code; but again, I can only do block coding, so I am looking for some advice on this issue. Thanks!

So I think I know what you might be able to try.
So most of the time when I use a inertial sensor the robot might be turning too fast and skip over the right amount and there for turn forever because the inertial sensor wont read that exact number in the little time it has. So to fix this I configured the inertial sensor separate from the drivetrain and when turning I’ll do a repeat until block with something like this:
repeat until inertial_1 > 89 and Inertial_1 < 91. And I’ll have the turn right in the repeat until block. And this will get it to turn correctly every time. Or at least it works for me.

Is this using drivetrain class ? Are you using turnTo or turnFor blocks ? turnFor will allow any error to accumulate.

There’s no self correction as such in the code used in the drivetrain class, it uses a simple P loop that terminates when the turn is completed within 2 degrees.


One thing that worked for me was having the drivetrain turn in a while loop and just have that repeat while the degrees is > 89 and < 91

Sounds like a fix. I’m new at block coding (and coding in general). Can you share with me a screen shot of how the block codes should look? I might have not placed critical block codes in place. Thanks for your help.

This also sound like a potential fix. I tried to do this but I think I’m probably missing critical codes such as calibrating, etc prior to the code blocks for making the turns. ( I’m new at block coding and coding in general). Could you share with me a screen shot of how the block codes should look? Thank you for reaching out.

1 Like

This is a very simple example program but I haven’t tested it or anything so you may need to tweak it a bit. Let me know if you run into any problems but this should work.


This should work

Except you need different values for each turn since you are using the inertial sensor. So for each turn just add 90 so after the first 90 turn do 180 then 270 and so on… also i forgot to switch the greater than and less than’s around… so it needs to be (inertial_3 > 89 & inertial_3 < 91

1 Like