Go to Post Mess up something important and you lose. Just like real life. - DonRotolo [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread Yesterday, 23:59
sgk525 sgk525 is offline
Registered User
FRC #5465
 
Join Date: Jan 2016
Location: Chandler, AZ
Posts: 5
sgk525 is an unknown quantity at this point
Distance Measurements to Target

Hi, we are currently using the Microsoft Lifecam-3000 with a raspberry pi for vision tracking and distance measurements. We can find the pixel height of the bounding box of the two vision rectangles and are inputting it into the equation:

distance: 0.83 (actual height of bounding box (ft)) * 480 (y-pixel resolution) / 2 * pixelHeight * tan( 14.9 (vertical view angle in degrees) )

When testing this formula, we have found that distance measurements are within 2-3 in. when the target is 2-4 m. away; however, from 1- 2 m, the error is around 10 in. We were wondering if there is anyway to prevent this, or if there is another, more-robust method to calculate the distance to the target.
Reply With Quote
  #2   Spotlight this post!  
Unread Today, 01:33
arichman1257's Avatar
arichman1257 arichman1257 is offline
VP, Control Systems Captain, Coach
AKA: Alan Richman
FRC #1257 (Parallel Universe)
Team Role: Electrical
 
Join Date: Dec 2014
Rookie Year: 2014
Location: Fanwood, New Jersey, USA, Earth...
Posts: 79
arichman1257 will become famous soon enougharichman1257 will become famous soon enough
Re: Distance Measurements to Target

https://acroname.com/products/r93-srf04?sku=R93-SRF04

This is an ultrasonic distance sensor. It is great for this application
__________________
1257 Parallel Universe: 2014 - 2017 Seasons
2017: Vice President, Control Systems Captain, Drive Coach
2016: Control Systems Captain, Operator. MAR District Championship Winner, MAR Mt. Olive Event Winner, MAR Bridgewater-Raritan Event Finalist
2015: Control Systems, Operator. MAR North Brunswick Event Finalist
2014: Programming/Electronics Apprentice. MAR Clifton Event Winner
Reply With Quote
  #3   Spotlight this post!  
Unread Today, 05:48
GeeTwo's Avatar
GeeTwo GeeTwo is online now
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,785
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Distance Measurements to Target

The easy method using the camera is an empirical curve.

That is, position the robot at a series of measured distances from the vision target, take pictures and measure the vertical height. Then, use you measured height during the match and interpolate into the curve you measured.

It will likely require re-measurement if you move the camera to a different location.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #4   Spotlight this post!  
Unread Today, 09:50
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,777
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Distance Measurements to Target

The distance estimation based on the optics of the camera is only valid if the camera sensor and the object you are measuring are in the same plane. When you tilt the camera up or down, you are introducing a perspective distortion dependent on the Y value where the size was measured.

This is a somewhat new wrinkle to FRC vision, as we have short robots and tall targets this year.

It is possible to calibrate this out of the system, and that was why the LV example had reference to a calibration file and a step to load it so that NIImaq could correct the distance with this info. But there are other approaches that will work as well.

Essentially, a 10px distance at the bottom of the camera image, in the middle, and at the top of the camera image are not supposed to give the same real-world distance estimate. I'd suggest making some empirical measurements and seeing how you can normalize this. Or look at the perspective distortion transform and figure out how to invert it (might not want to do this to all the pixels, however), or use some training utility.

With any of these, it is key to keep the camera height and angle pretty consistent or come up with a way to compensate based on some field element also in the image.

Greg McKaskle
Reply With Quote
  #5   Spotlight this post!  
Unread Today, 12:04
Thardro Thardro is offline
Registered User
AKA: Ethan
FRC #3042 (Cobalt Catalysts)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Minnesota
Posts: 20
Thardro has a spectacular aura aboutThardro has a spectacular aura about
Re: Distance Measurements to Target

First I would recommend doing the calculations found here in order to convert your pixels to actual angles, as the relationship between pixels and angles is not exactly linear.

From there what we did is we calculated the vertical angle taken up by the target and found this angle at various distances in .5 foot increments and using Excel found a curve that fit our points very well. This has worked extremely well and using the curve of best fit we are now able to measure distance to the target with less than an inch of error.
__________________


Reply With Quote
  #6   Spotlight this post!  
Unread Today, 12:20
FuzzyLogic FuzzyLogic is offline
Registered User
FRC #3792 (Army Ants)
Team Role: Programmer
 
Join Date: Feb 2017
Rookie Year: 2016
Location: Missouri
Posts: 3
FuzzyLogic is an unknown quantity at this point
Re: Distance Measurements to Target

We had this problem too with our vision measurements. We solved it by adjusting the viewing angle in our algorithm.

Take measurements from varying distances and plot them on a graph (actual distance on x axis, measured distance of y axis). It should be fairly linear. Find the slope of the line. Our slope was about 0.91.

tan(theta)/tan(current viewing angle) = slope

Theta is the viewing angle you should use in your algorithm.

After calibrating the viewing angle, our measurements are consistently with in 1-3 inches of the actual distance. I hope this works for you too!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 23:34.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi