I am using encoders on my robot and am trying to get the robot to make two 90 degree precision turns so I can turn and go back to the exact same spot over and over again. So far I am close but not prefect. To be close My encoder reads <4, which I think is wrong, and to fine tune I've changed power to the wheels. The encoders are working fine in a straight line and I can see them on debug.

As you can tell I am new to this.

Thu Mar 31, 2011 7:22 am

magicode

Moderator

Joined: Tue Sep 14, 2010 9:19 pmPosts: 496

Re: 90 degree precise turn

If you want help, you could post your code and see if someone can help you make it better. But using encoders, you will never be able to turn exactly 90 degrees. If one motor is running a bit faster then the other, or a wheel slips slightly, your center of turning will be off, and your encoder values won't be as useful. Think about it this way: If your center of turning is exactly between the encoders, then you have to keep turning until both encoder values have turned through the same absolute value. So if your encoder values are zero at the start, you have to keep turning until the left encoder is at, say 50, and your right encoder is at -50. But if your center of turning changes, the robot will not turn 90 degrees even if you reach the same encoder values. I hope this helped. I'm sorry if I didn't explain very clearly, I'm sick and my brain is slightly malfunctioning.

_________________sudo rm -rf /

Thu Mar 31, 2011 10:19 am

TomH

Rookie

Joined: Thu Mar 31, 2011 7:08 amPosts: 10

Re: 90 degree precise turn

thanks here id the part of the code I am working on. The robot is to move straight, then pick up a can, then back up, then turn 90 degrees to the left, go forward set the can down, back up, turn right, and go get another can.

As I say it works except the trouble with the turns. Which does no place me in the correct unloading or loading spot each time. Which is greatly needed. Any help suggestions etc. are warmly welcomed

Like Magicode said, it's very difficult to achieve perfect 90-degree turns every time, even using the encoders. The rubber wheels in the VEX system lend themselves to the occasional jumps or slips while turning on a point.

Have you considered incorporating other sensors to help achieve your goal? For example, you could use two ultrasonic range finders (one on the front, and one on the right) to see if you were the correct distance from two walls.

Like the others said, you will never get a precise turn of 90 degress all the time. However there is still room for improvement. Two things can be improved, the first is easy. The second more difficult. Implement in order.

1. After the while loops that make sure the robot travels or turns there is often a wait statement. The motors will still run when exiting the while loop and executing the wait command. Only after the wait you halt the motors. This will make the motors overshoot the target. So you should halt your motors right after the while loop.

2. Even if you stop the motors right after the while loop they still need to halt. While coming to stand still the motors are overshooting. If you want precise turns you should make sure that the motors don't overshoot at all. For this the motors should start slowing down when reaching he target position, so that they can stop right on spot. The easy way to do this is to use the nMotorTarget statement. (i'm not sure if they are available for the VEx, but you can check the manual). The more complex way to do it is to use a feedback controller. A feedback controler is something that uses the distance to the target to adjust the motor speed. Most commonly feed back used is a PID controller. Search for it here and in wikipedia to get an idea how it works and how it can be programmed.

I like the range finder idea to follow the wall. How would I set it up to stay a certain distance from the wall?

I can fix the motor stops easy enough and I spent more time and right now I am soooo close to having it routine turn a 90 degree.

But yes its not perfectly doing it. My project is to feed a can crusher that we made. So it is to go forward until it see the can. pick up the can then back up , turn the 90 degrees and go forward until it gets to the can crusher. Load the crusher and then return for another can. While the can crusher does it thing. But if I cannot get it to make the turn and end up in the same place repeatedly I have to come up with a new routine.

Another problem I seem to have is the robot will jump a little at times or just stop in the middle of a move. I am thinking this maybe a problem with how I have the waits set up so maybe by cleaning those up that will be eliminated.

Thanks for your suggestions

Thu Mar 31, 2011 8:36 pm

magicode

Moderator

Joined: Tue Sep 14, 2010 9:19 pmPosts: 496

Re: 90 degree precise turn

if you are parallel or perpendicular to a wall when you are at the can crusher, you can use two ultrasonic rangefinders to align yourself with the wall. if you have one rangefinder on the back-left of your robot, and one on the back-right, you can use the difference between them to align yourself parallel to the wall. I can provide sample code if you need it. I don't think that this is what jbflot was saying, but I may have misinterpreted his comment.

_________________sudo rm -rf /

Thu Mar 31, 2011 10:37 pm

TomH

Rookie

Joined: Thu Mar 31, 2011 7:08 amPosts: 10

Re: 90 degree precise turn

I am going to try installing a three line followers. So far I am not impressed with this Vex controller. It jumps around at times and I do not know why. I get it running fine then all of a sudden it just stops like it gets stuck. Then it will start again. Other times it just jumps. I took it to show some one and it ran fine, but then it starting screwing up again. I do not understand why that is. Now I got home and am trying to down line the code to try the line follower and It will not send it. So I am charging the battery. I hope that is it. Sorry for the negative attitude but I just spend well over $600 on all this stuff and it runs like junk. I will surly not recommend VEX to any one at this point!

Trouble with this one is I can't tell it any thing because its locked up and I cannot send any program to it. Plus when it was working it would run the program perfectly on thre or four cycles and then start acting up. That is not programmed as far as I can see. But I've been wrong before. I just need advise on how to get this unlocked and why did this happen1

Here is what is in it right now. I cannot run it, nor reload a different program. All I get is "cannot communicate with Vex". I have recharged the battery, rebooted the computer, reloaded the USB drive. The Robot was working fine, except for its occassinally jump or stopping in the middle of a While loop for no reason I can figure out. After I loaded the below program,which I have run many times before it locked up. It shows the battery light on and the program status light is on. but it will not do any thing. once in a while it will move a motor for a second. But that like 30 minutes apart.

while (1 == 1) //Creates and infinite loop { motor[port2] = vexRT(Ch2)/2; //The right motor is set to equal half the value transmitted by Ch2 (y-axis of the right joystick) motor[port3] = vexRT(Ch3)/2; //The left motor is set to equal half the value transmitted by Ch3 (y-axis of the left joystick)

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum