Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Goal Finder 2011 Documentation (http://www.chiefdelphi.com/forums/showthread.php?t=93642)

newkidd-sagar 15-03-2011 17:49

Goal Finder 2011 Documentation
 
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.

newkidd-sagar 16-03-2011 11:37

Re: Goal Finder 2011 Documentation
 
Quote:

Originally Posted by newkidd-sagar (Post 1040243)
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);


All times are GMT -5. The time now is 17:43.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi