|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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. Last edited by newkidd-sagar : 16-03-2011 at 11:36. Reason: This is some code that I have been working on to convert the Java code |
|
#2
|
|||
|
|||
|
Re: Goal Finder 2011 Documentation
Quote:
#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); |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|