# Vex Programming Skills

Hey guys, i want to make some autonomouss for programming skills but i have a question about this. How can I set it to rotate 90 degrees without any sensors? When i try to “RightWheel.spinFor(forward,-degree value-,degrees);” it doesn’t turn completely 90 degrees.

You need to do some math here.
`RightWheel.spinFor(forward,-degree value-,degrees);` is the degrees of your wheel rotation, which you should convert to the distance to the wheel travels (depending on your wheel radius). The distances of your left wheels and right wheels travel can be converted to the angle your robot turns, which depends on your track width.

Actually, i’m new in vex and i couldn’t understand how can i do this. If you don’t mind could you share some details with me?

Math:
pi is about 3.14 if you don’t know

So we know you want to turn 90 degrees, right. Your left side wheels should go forward while your right side wheels should go backward. Now, if we draw a 90-degree arc from the front left wheel, we have our distance. The issue is that we have to solve it. Solving it should be easy if you know how to find the circumference of a circle and other circle math. You start by finding the distance (r) from the wheel to the center plane of your robot. So it should just be from the center of your wheel to the center of your drivetrain. The point should be in between your two front wheels. You only need to do the math for one wheel. So now we know the radius and the degree angle. Use the circumference formula (pi x diameter, diameter = 2r) to find the distance of a 360-degree turn (circles are 360 degrees). Now, we only want a 90-degree turn, so we multiply the circumference by 1/4 since 90 degrees is 1/4 of 360 to get our turn distance/ arc distance. We have the distance, but we need to convert that into rotations now for your wheel. Let’s assume you have 4 inch (diameter) wheels, we multiply that by pi to get the circumference. So, one rotation will move your robot forward 4 x pi inches. We now divide the arc distance by 4 x pi inches to get the number of rotations needed for a 90-degree turn.

Programming:

Programming this should be pretty straightforward, you tell your left side motors to spin forwards for the calculated distance and reverse for the left side motors. So you should copy and paste that one line 3 more times to get all 4 wheels spinning the correct way. Also, do not forget to add “, false” to each of the 3 lines before the final line. That ensures that all 4 wheels turn simultaneously. Without it, it’ll run each line separately which is not what we want.

Example code:

``````    FR.rotateFor( 1,  rev, false );
BR.rotateFor( 1, rev, false );
FL.rotateFor( 1, rev, false );
BL.rotateFor( 1, rev);
``````

rev = revolutions but shortened

IMPORTANT: The math we did for an arc and turn distance is if it was a perfect world, and our world is unfortunately not perfect. The sensors built into the motors aren’t exactly accurate and you might have to play around with your turn rotations to get the robot to actually turn 90 degrees i.e. lowering it if it overshoots and vice versa. Most of the time, people use sensors like an inertial sensor because it is way more consistent relative to the built in sensors.

Reference Image:

Also, welcome to the forums! Response times will vary, but there are a lot of people that are willing to help. There also exists a search bar in the top right corner so you can look up questions like these. In the future, try looking your topic before making a post. Other than that, have fun making robots work!

9 Likes

you are awesome! thank you so much for all of this, saved my life

Of course! My pleasure helping

1 Like