Go to Post It's good to learn from experience. It's better to learn from somebody else's experience. - Jay TenBrink [more]
Home
Go Back   Chief Delphi > ChiefDelphi.com Website > Extra Discussion
Team 51   CD-Events   CD-Media   CD-Swap   CD-Spy   FRC-Spy   Unsung FIRST Heroes   WFA
portal register members calendar search Today's Posts Mark Forums Read FAQ rules
VEXpro
The Chief Delphi Forums are sponsored by Innovation First International, Inc.
Dr. Chang D.D.S.
ADVERTISEMENT

 
Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 04-30-2012, 11:55 AM
Jared341's Avatar
Jared341 Jared341 is offline
Congrats to the Champs!
AKA: Jared Russell
FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: Philadelphia, PA
Posts: 2,410
Jared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond repute
Send a message via AIM to Jared341
paper: Team 341 Vision System Code

Thread created automatically to discuss a document in CD-Media.

Team 341 Vision System Code by Jared341
Reply With Quote
  #2   Spotlight this post!  
Unread 04-30-2012, 12:07 PM
Jared341's Avatar
Jared341 Jared341 is offline
Congrats to the Champs!
AKA: Jared Russell
FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: Philadelphia, PA
Posts: 2,410
Jared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond reputeJared341 has a reputation beyond repute
Send a message via AIM to Jared341
Re: paper: Team 341 Vision System Code

Attached is a zip file containing everything you need to run FIRST Team 341's laptop-based vision system. We are very proud of this software, as it propelled us to 4 Regional/District Championships and the Curie Division Finals. Every shot our robot attempted in Rebound Rumble was completely controlled by this code.

To get it up and running on your computer (which can be Windows, Linux, or Mac OSX), you first should install the WPI SmartDashboard using the installer which you can find here: http://firstforge.wpi.edu/sf/frs/do/.../frs.installer

Note that for Linux or OSX builds (or if you just want to use more recent libraries than are included in the SmartDashboard installer on Windows), you will need to do the installation by hand. The libraries you will need are OpenCV (http://opencv.willowgarage.com/wiki/), JavaCV (http://code.google.com/p/javacv/), and FFMPEG (http://ffmpeg.org/). Make sure that the OpenCV and JavaCV versions you install are compatible! Meaning the same version number of OpenCV, and the same architecture (x86 or x86-64). You then need to make sure the paths to the OpenCV libraries are in your system path.

To use the widget with the Axis camera, you should configure your camera to allow anonymous viewing and make sure it is connected directly to your wireless bridge (not the cRIO). The IP must also be set by right clicking on the SmartDashboard widget. For best results, you will also want to ensure that your camera has a very fast exposure time (we used 1/120s). The FIRST control system documentation and vision whitepaper go over how to do this.

You can also run the widget in a "stand alone" fashion, as the class has a Java main method that you can use to load images from disk and display the processed results. Sample images are included.

Our vision system uses OpenCV library functions to successively filter the raw camera image and find the vision targets. The highest target detected is then used to compute range and bearing information. With a statically mounted camera, we use inverse trigonometry to find the distance to the target based on the height in the image. Bearing is computed by adding the offset of the target horizontally in the camera frame to the heading we are getting back from the robot. This lets us use a closed loop controller on the robot to use the gyro to "aim". If your robot has a turret, you could instead send the turret angle back to the SmartDashboard and get the same results. The computed range is used to find an optimal shooter RPM, which also gets sent back to the robot. We interpolate between points in our "range-to-RPM" lookup table in order to provide smooth outputs to our shooter wheel speed control loop.

Thanks to Brad Miller, WPI, Kevin O'Connor, and the FRC Control System team for making OpenCV-based vision processing a reality in 2012!
Reply With Quote
  #3   Spotlight this post!  
Unread 04-30-2012, 12:32 PM
Brandon Holley's Avatar
Brandon Holley Brandon Holley is offline
Chase perfection. Catch excellence.
AKA: Let's bring CD back to the way it used to be
FRC #0125 (NU-TRONs, Team #11 Alumni (GO MORT))
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Boston, MA
Posts: 2,304
Brandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond reputeBrandon Holley has a reputation beyond repute
Send a message via AIM to Brandon Holley
Re: paper: Team 341 Vision System Code

Thanks for publishing this. Your tracking was absolutely deadly all season. I'm curious to see how our final algorithm stacks up against your code.
__________________
MORT (Team 11) '01-'05 :
-2005 New Jersey Regional Chairman's Award Winners

NUTRONs (Team 125) '05-???
2007 Boston Regional Winners
2008 & 2009 Boston Regional Driving Tomorrow's Technology Award
2010 Boston Regional Creativity Award
2011 Bayou Regional Finalists (3rd seed), Innovation in Control Award
2011 Boston Regional Finalists (2nd seed), Industrial Design Award
2012 New York City Regional Winners
2012 Boston Regional Finalists (2nd seed)
2013 Orlando Regional Finalists (2nd seed), Industrial Design Award
2013 Boston Regional Winners (1st seed)
Reply With Quote
  #4   Spotlight this post!  
Unread 04-30-2012, 01:25 PM
JamesTerm's Avatar
JamesTerm JamesTerm is offline
Terminator
AKA: James Killian
FRC #3481 (Bronc Botz)
Team Role: Engineer
 
Join Date: May 2011
Rookie Year: 2010
Location: San Antonio, Texas
Posts: 160
JamesTerm is a name known to allJamesTerm is a name known to allJamesTerm is a name known to allJamesTerm is a name known to allJamesTerm is a name known to allJamesTerm is a name known to all
Re: paper: Team 341 Vision System Code

Thanks so much for posting this... looking forward to reviewing this. It was nice to meet you... BTW I have worked with FFmpeg professionally since 2006, so if you ever have any issues with it, perhaps I can help.
Reply With Quote
  #5   Spotlight this post!  
Unread 04-30-2012, 02:14 PM
R.C.'s Avatar
R.C. R.C. is offline
Ramping Up for the 2013 Season!
AKA: Owner, WestCoast Products & Design LLC
FRC #1323 (MadTown Robotics)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2006
Location: Madera, CA
Posts: 1,762
R.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond reputeR.C. has a reputation beyond repute
Send a message via AIM to R.C.
Re: paper: Team 341 Vision System Code

1323 cannot thank Jared and 341 for helping us with vision. By champs we were one of the best shooters in our division.

-RC
Reply With Quote
  #6   Spotlight this post!  
Unread 04-30-2012, 05:35 PM
rainbowdash's Avatar
rainbowdash rainbowdash is offline
Director of Programming
AKA: Souvixada S.
FRC #1671 (Buchanan Bird Brains)
Team Role: Programmer
 
Join Date: Apr 2012
Rookie Year: 2005
Location: Clovis, CA
Posts: 28
rainbowdash is an unknown quantity at this point
Re: paper: Team 341 Vision System Code

Thanks for the code!

Great job with your camera tracking, Miss Daisy! It was exciting watching all your matches! I know everyone in the chat room was very shocked and sad when you guys got eliminated.

Good luck at your off- season competitions!
Reply With Quote
  #7   Spotlight this post!  
Unread 04-30-2012, 10:04 PM
RevonZZ's Avatar
RevonZZ RevonZZ is offline
Ace Pilot, 1337 User
AKA: Raza Alam
FRC #2016 (The Mighty Monkey Wrenches)
Team Role: Tactician
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Ewing, NJ
Posts: 9
RevonZZ is an unknown quantity at this point
Re: paper: Team 341 Vision System Code

Your tracking system was legendary this year, 341. Heh... One of our running jokes was that your team had an aimbot.

My nerdy friends always called out "HAAAAAXXXX!!1!" when you were on the field. You're pretty good when just playing the game is cheating compared to lesser robots.
__________________
RevonZZ, Strategic Director and Field Tactician
He trawls the net, looking for bits and bytes of value.
Reply With Quote
  #8   Spotlight this post!  
Unread 04-30-2012, 11:42 PM
Ziv Ziv is offline
Has code to be writing...
FRC #0125 (Nutrons)
Team Role: Alumni
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Boston
Posts: 37
Ziv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of light
Re: paper: Team 341 Vision System Code

This is really cool! I'm looking forward to taking a close look at this at a non-12AM time, but a quick skim left me hungry for more.

We used a much more primitive system to find targets. After even very lenient RGB thresholding, we found that ignoring small particles and filtering the remaining ones for high normalized moment of inertia was sufficient. However, we didn't use any measurements other than the x coordinate of the center of the targets. Your code will no doubt be studied by a great many people, hopefully including all of 125's trainee programmers .
Reply With Quote
  #9   Spotlight this post!  
Unread 05-02-2012, 08:40 PM
hodgepodge hodgepodge is offline
Registered User
FRC #0118
 
Join Date: May 2012
Location: Houston, TX
Posts: 1
hodgepodge is an unknown quantity at this point
Re: paper: Team 341 Vision System Code

It's great to see how others approached the vision processing. I wrote the vision code for team 118 this year and from a quick glance, your algorithm is quite similar.

Our code ran onboard on a BeagleBone running Linux and straight OpenCV, written in C++. libCurl was used to capture images and a UDP socket spewed angle and distance data to the cRio.
Reply With Quote
  #10   Spotlight this post!  
Unread 05-03-2012, 07:31 AM
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 486
BradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud ofBradAMiller has much to be proud of
Re: paper: Team 341 Vision System Code

Jared -

Thanks so much for posting your code. It was good meeting you at the regional and amazing watching your teams robot do it's stuff. This will go a long way to helping teams learn about computer vision processing and raise the bar for future competitions. Expect to see better documentation and improvements for next season.

And thanks to Joe Grinstead and Greg Granito for helping develop the code over last summer at WPI. They did a great job with the camera code and network tables extensions to WPILib.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
  #11   Spotlight this post!  
Unread 05-05-2012, 02:58 PM
sebflippers sebflippers is offline
Registered User
FRC #2914
 
Join Date: Jan 2012
Location: dc
Posts: 49
sebflippers will become famous soon enoughsebflippers will become famous soon enough
Re: paper: Team 341 Vision System Code

Thanks for the code. I believe lines 322-334:
Code:
private double boundAngle0to360Degrees(double angle)
    {
        // Naive algorithm
        while(angle >= 360.0)
        {
            angle -= 360.0;
        }
        while(angle < 0.0)
        {
            angle += 360.0;
        }
        return angle;
    }
could be replaced with
Code:
private double boundAngle0to360Degrees(double angle)
    {
        return(abs(angle)%360.0);
    }
Reply With Quote
  #12   Spotlight this post!  
Unread 05-05-2012, 04:50 PM
Ziv Ziv is offline
Has code to be writing...
FRC #0125 (Nutrons)
Team Role: Alumni
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Boston
Posts: 37
Ziv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of lightZiv is a glorious beacon of light
Re: paper: Team 341 Vision System Code

Quote:
Originally Posted by sebflippers View Post
Thanks for the code. I believe lines 322-334 [snipped] could be replaced with
Code:
private double boundAngle0to360Degrees(double angle)
    {
        return(abs(angle)%360.0);
    }
Consider the angle -90. Daisy's code returns 270, but yours returns 90. I think you're looking for something more like this:

Code:
private double boundAngle0to360Degrees(double angle)
    {
        double ret = abs(angle)%360.0;
        if(angle < 0.0)
        {
            ret = -ret;
        }
        return(ret);
    }
Reply With Quote
  #13   Spotlight this post!  
Unread 05-06-2012, 10:52 AM
sebflippers sebflippers is offline
Registered User
FRC #2914
 
Join Date: Jan 2012
Location: dc
Posts: 49
sebflippers will become famous soon enoughsebflippers will become famous soon enough
Re: paper: Team 341 Vision System Code

Quote:
Originally Posted by Ziv View Post
Consider the angle -90. Daisy's code returns 270, but yours returns 90. I think you're looking for something more like this:

Code:
private double boundAngle0to360Degrees(double angle)
    {
        double ret = abs(angle)%360.0;
        if(angle < 0.0)
        {
            ret = -ret;
        }
        return(ret);
    }
right.
Reply With Quote
  #14   Spotlight this post!  
Unread 05-06-2012, 01:09 PM
sebflippers sebflippers is offline
Registered User
FRC #2914
 
Join Date: Jan 2012
Location: dc
Posts: 49
sebflippers will become famous soon enoughsebflippers will become famous soon enough
Re: paper: Team 341 Vision System Code

done. This one kind of defeats the purpose of making your code simpler, though.
Code:
	public static double boundAngle0to360Degrees(double angle)
    {
        return(angle > 0.0? angle % 360.0 : 360.0*(1 + (Math.abs((int)angle)/360))+angle);
    }
Reply With Quote
  #15   Spotlight this post!  
Unread 05-07-2012, 02:58 AM
Gray Adams's Avatar
Gray Adams Gray Adams is offline
Registered User
FRC #0192 (GRT)
Team Role: College Student
 
Join Date: Dec 2011
Rookie Year: 2011
Location: University of Southern California
Posts: 265
Gray Adams is a splendid one to beholdGray Adams is a splendid one to beholdGray Adams is a splendid one to beholdGray Adams is a splendid one to beholdGray Adams is a splendid one to beholdGray Adams is a splendid one to beholdGray Adams is a splendid one to behold
Re: paper: Team 341 Vision System Code

Quote:
Originally Posted by sebflippers View Post
done. This one kind of defeats the purpose of making your code simpler, though.
Code:
	public static double boundAngle0to360Degrees(double angle)
    {
        return(angle > 0.0? angle % 360.0 : 360.0*(1 + (Math.abs((int)angle)/360))+angle);
    }
Why not just...
Code:
 public static double boundAngle0to360Degrees(double angle)
    {
        return((angle+360)%360);
    }
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 01:01 PM.

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


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright © Delphi and Pontiac Central High School