Inertial Sensor Rotation & Heading

Hello

I am going to use a function to turn my drivetrain more accurately, but I have encountered a road bump.

For vex::inertial::heading, how is the degrees calculated? If we go clockwise, does it go from 0 - 360 and if we go counter clockwise, does it go 360-0 or go into the negatives?

I may be using vex::inertial::rotation too, so how is the degrees on that calculated? Does it go into the negatives?

Thank you!

Open up the inertial sensor under the devices tab. There is a great deal of information that will help you understand the values.

Take a look at the following:

heading is reffer to the absolute orientation in a cartesian plane.

In the next figure you would see how the angle is recorded. The angle is in range to 0 to 360 degrees, it is absolute orientation, it doesn´t exist negative numbers. So, its doesnt matter if you turn 90 degrees counterclockwise or if you decided turn 90 degrees clockwise the robot´s final orientation (heading) would be 270 degrees.

image

Heading is very useful because allows you to know the global orientation of your robot respect a start orientation. In odometry, for example is useful.

That means; if you create a function using heading to measure the robot’s current orientation you may no command: “turn 90 degrees to the right” or “turn 180 degrees to the left”. You may do your functions to being able to command : “turn to 90 degrees”, “turn to 180 degrees”, “turn to 270 degrres”, etc.

You may need to do some math in order that your robot could decided wich direction it needs to turn.

In the other hand using rotation is a good option to. The main difference is that rotation doesn´t give your the global orientation of your robot. The functions send you the mount of degrees rotated since the last reset. So it doesn´t exist a range, your robot could turn 720 degrees or maybe -720 degrees. The rotation functions could send you negative or positive numbers, the sign depends of the direction of your robot.

I strongly recommend you to take a look on VEX library and try using both functions !.

2 Likes