View Single Post
  #6   Spotlight this post!  
Unread 10-03-2006, 12:12
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: calculating distance

If you're talking about distance to the target, you can use the camera tilt angle (not very reliable or accurate), or you can use the camera's reported blob size.

If you take an average of the camera's blob size over several cycles (2-3 seconds of summing), you can get a pixel count that is effectively accurate to about 0.01 pixels. Once you know, for example, that you can see 5.27 pixels from your current position, you can plug that into an empirically derived equation to determine your distance in whatever units you want.

So here's what you can do:
1. Write code that sums up the blob size over the last 100 robot cycles
2. Have the code print out the sum of the last 100 cycles, and record this value
3. Measure the distance your robot is from the target, and record that value next to the value from step 2
4. Write the distance and sum down, and repeat for varying distances
5. Put all these (sum,distance) pairs into excel, and have it generate a matching function for you (our best fit was a polynomial).

Example data:
Code:
Pixels	Distance
5.27	8m
5.70	7m
5.95	6m
We ended up collecting five pixel sizes for each distance, and spaced the distances 25cm apart from 8m to 4m.

Once you have this polynomial function, you can use it to take a sum or average of blob sizes and turn it into a measured distance with great accuracy.

The problem with trig is that moving 1 foot when you're 10 feet away doesn't change the angle very much, and as such, you won't get a very accurate distance measurement. We tested this method, and it's accurate to about 10 centimeters. You can also make it variably accurate, depending on how much time you have to measure the blob size. The problem with the blob method is that when you're off to the side, the blob will be artificially smaller without decreasing the distance. However, if you're so off to the side that that is a big issue, you probably won't make the shot anyway.

Last edited by Bongle : 10-03-2006 at 12:14.