View Single Post
  #13   Spotlight this post!  
Unread 06-03-2010, 00:37
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Camera code does not recognize target

Quote:
Originally Posted by Lucie365 View Post
I tried changing the compareTargets function to boolean as follows:

bool compareTargets(Target t1, Target t2) {
return (t1.m_score > t2.m_score)
}

This solved the problem. Apparently the sort function is looking for a true/false rather than -1/0/1. Both -1 and 1 were considered true (only 0 is considered false) so no sorting was actually being done.
You are right. I don't know about WindRiver C++ but apparently the standard Microsoft C++ sort function is expecting a bool compare function as well. I didn't realize this either. Long time ago in C, I believe the sort function in C runtime expects a compare function to return +1, 0 or -1. Apparently, C++ expects bool. Good catch.

http://msdn.microsoft.com/en-us/libr...h1(VS.71).aspx
__________________
Reply With Quote