![]() |
Turn 90 Degrees
Hey guys, recently my team (237) gave me the Robovation kit. I'm still looking around the source code, but i'm starting to understand it. Right now I'm trying to make a function that'll make it turn 90 degrees. I have a good idea on how to do it via the programming aspect, but im mind blocked on the math part.
Heres a pic I drew in paint. ![]() Whats the formula to figure out how many times the wheel needs to turn to go 90 degrees? I'm sure I can just go manually turn it and figure it out, but the formula would be better when I need to have it turn other angles. :confused: I probably didn't make much sense... it's a saturday. |
Re: Turn 90 Degrees
Well, it's not that simple. In the code there is no direct way to make the robot turn 90 degrees. You control the motors through the PWM variables. And in that you do not control how many times they turn directly. You control the amount of power that is sent to the individual motor. For example, if pwm01 and pwm02 control the left and right side of you mini-bot:
pwm01 = 0; pwm02 = 255; Your robot would go spining to the left, it would not stop until you set pwm01 and pwm02 back to 127. The easiest, but least accurate method of doing what you are talking about would be "dead reconing" in which you just set pwm01 = 0 and pwm02 = 255 for a certain amount of time, which you can control by using a simple incrementing variable. Here is some source to help you out. I'm just typing it in here, so I don't know if I made a stupid syntax error, but the general logic should all be there. Code:
long int timer = 0; //Declare this globally at the top of the file. Right under the includes.The next ways which are more advanced but still not 100% accurate would be to use a gyroscope, which sences angular rate. So if the robot is turning to the right then it would sence it. You could use that in combination with some guese and check to get a reasonable accurate 90 degree turn. |
Re: Turn 90 Degrees
Quote:
|
Re: Turn 90 Degrees
The way that is more accurate than dead reckoning but not as complex as a gyroscope is an encoder. You can use either an optical sensor, like the Banner sensor in the KOP, or a potentiometer that has no stop (multi-turn, you call that?). Either one of these will count the revolutions of the wheel, which makes it easier to measure how far it has gone. To implement the optical sensor, you'd have to paint white dots on the wheels so the sensor can have something to count. You wouldn't have to do that, and you'd have less error with a pot, but it's a little trickier to figure out how to mount a pot on the EDU bot. There are numerous coding examples on these forums that will explain how you can program this.
|
Re: Turn 90 Degrees
...Shouldn't this be under Programming?
|
Re: Turn 90 Degrees
Quote:
EDIT: Mods feel free to move it if I was wrong |
Re: Turn 90 Degrees
|
Re: Turn 90 Degrees
Thanks, Tom. I knew there was a thread around here somewhere. :)
|
Re: Turn 90 Degrees
Quote:
Somehow measure the amount of time it takes for the wheel to spin one revolution at speed x. Set it to run at speed x for the needed amount of length/time. EDIT: thats not exactly what im going to do, I can't explain it... but it'll work |
Re: Turn 90 Degrees
Quote:
To compute the required travel, you'll need to know the position of the stationary center of rotation and the distance from that point to the wheel. If you're trying to turn by applying power to one of the rear wheels, the other wheel is the stationary point and the turning radius is the distance between the wheels. If you're going to apply forward power to one wheel and reverse power to the other, the stationary point is directly between them and the turning radius is 1/2 the distance. Then just use the simple formula for the circumference of a circle (C = 2*pi*r) and divide by four to find out how far the wheel has to go for a quarter turn. Now divide by the circumference of the wheel itself et voila! you now know how many revolutions the wheel must make to perform the 90 degree turn. Making the wheel turn that many times is left to you as an exercise. |
Re: Turn 90 Degrees
i think it is only simple to do it mathematically w/ a 2 wheel drive robots... .use the distance between two wheels as your turning diameter multiply that times pi for circumferance... now to turn 90 deg it is the (circumferance / 4 )/(wheel circumfrence) to get revoutions of wheel needed....
now if you have four wheels i think it gets trickier because the radius along which each wheel / side turns seems to be uncalculable ...easily ... at least i can't think of a way... also the other side kinda affects it... |
Re: Turn 90 Degrees
Quote:
Code:
#define COUNT 20 //determine this number experimentally |
Re: Turn 90 Degrees
Quote:
You keep on mentioning "the pot"... whats that? A member on my team said that doing it this way wouldn't be reliable, because as the battery dies it won't be able to spin the wheel as fast as it did before. Will this fix that? I'd rather ask questions then just copy/paste... =/ |
Re: Turn 90 Degrees
Quote:
Quote:
Quote:
|
Re: Turn 90 Degrees
Quote:
|
| All times are GMT -5. The time now is 14:09. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi