View Single Post
  #2   Spotlight this post!  
Unread 27-01-2012, 08:33
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: Comprehensive help for camera code

It would indeed attempt to drive towards each particle in turn. I forget if I posted that particular code snippet, but what you'd probably want would be something like this, where you select a favourite particle. For example, here's code that selects the biggest particle:

Code:
ParticleAnalysisReport biggest = {0};
for(UINT32 x = 0; x < particles->size(); x++)
{
  ParticleAnalysisReport& par = (*particles)[x];
  if(par.particleArea > biggest.particleArea) // particleArea may not be the right member... I'm going from memory.
  {
    biggest = par;
  }
}
if(biggest .center_mass_x_normalized > 0)
{
//right 
}
if(biggest .center_mass_x_normalized < 0)
{
//left
}
Of course, you may not want to drive towards the biggest particle, but rather the most backboard-shaped particle...

For your syntax question:
particles is a pointer to a vector<ParticleAnalysisReport>. Therefore, to call member functions on it like size(), you need to use the arrow operator. To call the square-bracket operator, you need to indirect it using the * first to get yourself a non-pointer vector<ParticleAnalysisReport>.

particles->size() tells you how many particles there are in the list of particles.

Last edited by Bongle : 27-01-2012 at 08:36.
Reply With Quote