View Single Post
  #2   Spotlight this post!  
Unread 27-03-2013, 18:58
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 7,006
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Gyro & UltraSonic Help

The short answer is yes.

I'm not a programmer, so i can't give you much, but here's a high-level view:

The Ultrasonic (e.g., Maxbotix) returns distance. Maxbotix is an analog voltage*, you read it in, do a multiplication and get a distance in, say, inches. At the start, you measure the distance several times (you want several readings the same, so you know they are good) and then move the drivetrain until the distance is what you want. If you need to move a large distance, or move quickly, you may need some kind of PID control (probably P alone is plenty) to avoid overshooting your target distance.

The Gyro can be used to measure any angle. Again, take several measurements to get a stable reading with the robot standing still, then command a turn until you reach your desired angle. Again, PID control to avoid overshooting.

Notes:
1. You can also use odometery to measure distance - specifically, a sensor on your drivetrain can report its movement, and using that number you can calculate distance quite accurately.

2. PID is not to be feared. In this case, the "error" is the distance remaining, and as that gets smaller you use it to make the motors go slower. So, as the distance (or angle) remaining gets smaller, the robot moves more slowly so you can stop where you need to. (Imagine going exactly 7 feet at full speed - think you can stop accurately from full speed? No. So, PID, but for this only P is really necessary)

*3. Maxbotix sensors also have other outputs, I find the analog easiest to use, but you may think differently and that's OK.

Good luck!
__________________

I am N2IRZ - What's your callsign?
Reply With Quote