View Single Post
  #5   Spotlight this post!  
Unread 21-01-2012, 15:35
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: Particle Analysis Report Problems

Code:
void Autonomous(void)
	{
		myRobot.SetSafetyEnabled(false);
		AxisCamera &camera = AxisCamera::GetInstance();
		camera.WriteBrightness(0);
		Wait(3.0);
		myRobot.MecanumDrive_Cartesian(0.0, 0.0, 0.0, 0.0); 	// stop robot
		while (!IsOperatorControl())
		{
			ColorImage img;
			camera.GetImage(&img);
			BinaryImage* binImg = img.ThresholdRGB(192, 256, 192, 156, 192, 256);
			vector<ParticleAnalysisReport>* particles = binImg->GetOrderedParticleAnalysisReports();
			for(UINT32 x = 0; x < particles->size(); x++)
			{
				ParticleAnalysisReport& par = (*particles)[x]; 
				
				if(par.center_mass_x_normalized > 0) { /* turn right */ }
				else if(par.center_mass_x_normalized < 0) { /* turn left */ }
			}
		}
	}
This should get you started. The robot centering will be kinda jerky once you put the turning calls into myRobot, but should mostly work.

If you're focused JUST on autonomous however, don't forget the physical approach: put an aiming device on the robot, and have your drive team place and aim the robot using that. That removes the need to use the camera at all, mostly. You wouldn't get aiming in teleoperation mode, but if the goal is just autonomous, you can achieve it with just an on-robot aimer. It's actually what we did last year.

Last edited by Bongle : 21-01-2012 at 15:39.
Reply With Quote