Go to Post Just wanted to know some of your favorite physics and math equasions during build seasions thanks. mine is pathagriom therom - team 3311 [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 16-03-2011, 11:37
newkidd-sagar newkidd-sagar is offline
Registered User
FRC #1241
 
Join Date: Jan 2010
Location: Mississauga
Posts: 13
newkidd-sagar is an unknown quantity at this point
Re: Goal Finder 2011 Documentation

Quote:
Originally Posted by newkidd-sagar View Post
Hey guys,

I wanted to quickly ask about this documentation posted here:

http://firstforge.wpi.edu/sf/go/doc1209?nav=1

This is some sample code written to track the retro reflective tape on the scoring pegs. This code is written in Java and I was wondering whether anyone knows where I can find something similar for C++. We mainly want to use the camera to align with the pegs so we can score in autonomous.

Thanks for all your help.
Here is some code I made converting the Java code.

#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
RobotDrive *myRobot;
Joystick *Gamepad;

AxisCamera *camera;
ColorImage *colorImage;
ParticleAnalysisReport sparticles;


DriverStation *ds;
BinaryImage *binImage;

public:

RobotDemo(void)
{
myRobot = new RobotDrive(10, 9);

Gamepad = new Joystick (1);
ds = DriverStation::GetInstance();





GetWatchdog().SetExpiration(100);
}

void Autonomous(void)
{
GetWatchdog().SetEnabled(false);

}

void OperatorControl(void)
{

printf("Getting camera instance\n");
camera -> AxisCamera::GetInstance();
printf("Setting camera parameters\n");
camera -> WriteResolution(AxisCamera::kResolution_320x240);
camera -> WriteCompression(20);
camera -> WriteBrightness(35);

GetWatchdog().SetEnabled(true);


while (IsOperatorControl())
{

GetWatchdog().Feed();

float rightDrive = Gamepad -> GetRawAxis (4);
float leftDrive = Gamepad -> GetRawAxis (2);

myRobot -> TankDrive (leftDrive, rightDrive);


if (camera->IsFreshImage())
{
colorImage = camera->GetImage(); // get the image from the camera

binImage = colorImage->ThresholdHSL(242, 255, 36, 255, 25, 255);

sparticles * BinaryImage::GetOrderedParticleAnalysisReports();

//System.out.println("Particles: " + sparticles->length);

}


}//end while

}
};

START_ROBOT_CLASS(RobotDemo);
Reply With Quote
 


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 12:23.

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