So, I tried to create code using the Inertial sensor where my drivetrain would turn 90 degrees to the right and it just stayed still and did nothing. Any suggestions?
The reason behind is that you want your motors to spin while the inertial is detecting that the angle is not what you have achieved. The reason that I used the rotation API instead of heading is that heading wraps the angle, meaning that it’s only between (0 -360). Usually, you want to be able to go into negatives so its a better choice to use rotation unless you need angle wrapping. I also added another parameter called speed so its easier for you to change the speed at what the motors spin. I hope this helps
I have a question, how do you read the rotation because on the Inertial Sensor set up because you can’t read it on the brain (only the heading, X,Y and,Z plane, the roll, and pitch) or am I missing something?
So for this you usually want to display the data to the brain so to do this you can do it like this
Brain.Screen.printAt(1, 20, "Rotation of Robot: %f", Inertial1.rotation(deg));
and this way you can see the exact rotation that the inertial is giving. And to do this properly you should put this in your while loop that you have setup so it updates the value on the screen every 10ms. And as a side note the %f basically tells the computer that you want to display a float value there.
Same as a right turn but you spin the motors the other way and check for the current inertial value being more than the target rather than less. Keep in mind that in both cases you would have to account for the crossover between 359 and 0.
Okay, Thank you. Though when I use a heading type turn at the beginning of an auton, it doesn’t always turn even though I have a wait until completion in the void itself