Go to Post FIRST is NOT just about robotics. It is about the growth of leaders - of Gracious Professionals... - MysterE [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 13-01-2009, 07:55
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
WPILib Bugs (Fixes FindColor unreliability)

Team 2702 and I have found what appear to be several bugs in the chain of functions called when you call FindColor. They don't completely stop it from working, but they nearly do. If you're using WPILib and your FindColor works, it is likely mostly due to luck. If you're using WPILib and your FindColor generally picks up single pixels even when you're SURE your TrackingThresholds are set perfectly, then this thread is for you. If other teams have been having trouble with FindColor being fairly finicky or unreliable about picking things up, maybe these tips could help. I can't post our source code because I'm don't have access to it right now, but hopefully these tips should guide you.

MODIFY YOUR WPILIB SOURCE CODE AT YOUR OWN RISK. MAKE A BACKUP.

1) InArea (TrackApi.cpp). Look at this code:
Code:
imaqMeasureParticle(binaryImage, particleIndex, 0, IMAQ_MT_BOUNDING_RECT_LEFT, &position);
if ( position < (rect.left + rect.width) ) return false;
So if the left side of the particle's bounding rect is less than the right side of the caller's input rect, it returns false. It seems that the "+ rect.width" shouldn't be there. The rest of the conditions to return false in InArea appear to be incorrect as well.
2) GetLargestParticle (TrackApi.cpp)
The very first thing this function does it blow away the caller-supplied pointer (instead making it point at a stack-declared variable), thus making it impossible to return the largest particle index. Though it never seems to try to return the largest particle index in its current implementation anyway. Note that even if you fix the return problems, this function won't work right until you fix InArea as well.
3) FindColor (TrackApi.cpp)
After its call to GetLargestParticle (see (2)), the main implementation of FindColor does "if (largestParticleIndex == 0) { /* lots of analysis code goes here */ )". It seems that this should be "if( largestParticleIndex >= 0)", since you can have nonzero particle indexes once GetLargestParticle and InArea is fixed.

Hope this helps some teams. Again, use at your own risk, and I imagine WPI will have fixes for these soon. But if you want to get FindColor working better, these should help until WPI puts official fixes out.

The effect of these three bugs is:
-InArea fails pretty much every time
-GetLargestParticle always appears to return 0 for the largest particle index because it doesn't change the input parameter.
-FindColor uses that 'returned' index, and analyzes the 0th particle. This _could_ be your target, but more likely it'll be a single-pixel noise blob in the top-left of your image.

With these fixes:
-InArea correctly returns whether a given particle is in your search rect
-GetLargestParticle actually returns the particle index of the largest, rather than the first, particle
-FindColor does analysis on the largest particle, which will more reliably be the particle you're actually interested in


And a little pre-response:
Quote:
You should email WPI with these
I did just before I posted this thread
Quote:
Teams should wait until WPI posts their official fixes
They should, but if they are risk takers and want to make their camera work properly sooner, they can try to implement these fixes.

Last edited by Bongle : 13-01-2009 at 08:29.
Reply With Quote
  #2   Spotlight this post!  
Unread 13-01-2009, 16:23
Dr Nick Dr Nick is offline
Registered User
FRC #0501 (The Powerknights!)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Manchvegas NH!
Posts: 24
Dr Nick has a spectacular aura aboutDr Nick has a spectacular aura about
Send a message via AIM to Dr Nick
Re: WPILib Bugs (Fixes FindColor unreliability)

Ah nice. My team is working on vision either late this week or early next week so if there's no update by then we'll definitely implement these fixes. You guys rock!
Reply With Quote
  #3   Spotlight this post!  
Unread 13-01-2009, 16:54
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,572
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: WPILib Bugs (Fixes FindColor unreliability)

Looks like you found the same things team 67 posted about on the FIRST forums a few days ago: http://forums.usfirst.org/showpost.p...7&postcount=28
Reply With Quote
  #4   Spotlight this post!  
Unread 13-01-2009, 21:03
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: WPILib Bugs (Fixes FindColor unreliability)

Quote:
Originally Posted by Joe Ross View Post
Looks like you found the same things team 67 posted about on the FIRST forums a few days ago: http://forums.usfirst.org/showpost.p...7&postcount=28
Well, it's good to see we found the same stuff independently and we're not just crazy.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
pic: Hex Bugs Freddy Schurr Extra Discussion 1 11-05-2007 09:54
Portal Config Fixes Brandon Martus Announcements 0 28-06-2006 13:27
PWM cables: too fragile? what fixes/precautions? BillCloyes Control System 18 14-03-2005 17:34
Email Bugs Brandon Martus Announcements 0 07-03-2003 22:53
robot fixes for battlecry 2 mike o'leary Off-Season Events 1 20-06-2001 23:37


All times are GMT -5. The time now is 15:10.

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