|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
I am trying to use camera tracking to track the reflective tape, but I am having problems with the frcParticleAnalysis function. I'm not sure how to use it. my code is:
#include "WPILib.h" /** * This is a demo program showing the use of the RobotBase class. * The SimpleRobot class is the base of a robot application that will automatically call your * Autonomous and OperatorControl methods at the right time as controlled by the switches on * the driver station or the field controls. */ class RobotDemo : public SimpleRobot { RobotDrive myRobot; // robot drive system Joystick stick; // only joystick Jaguar jag1; Jaguar jag2; Solenoid Sol1 ; Joystick stick2; HSLImage image; ParticleAnalysisReport par; BinaryImage image2; public: RobotDemo(void): myRobot(1, 3, 2, 10), // front left, rear left, front right, rear right stick(1), //these must be initialized in the same order jag1(7), jag2(8), Sol1(8), stick2(2) { myRobot.SetExpiration(0.1); } /** * Drive left & right motors for 2 seconds then stop */ 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()) { camera.GetImage(); frcParticleAnalysis(image2, 5, par); /*the error says "cannot convert 'BinaryImage' to 'Image*' for argument '1' to 'int frcParticleAnalysis (Image*, int, ParticleAnalysisReport*)'*/ } } /* * Runs the motors with single stick holonomic steering. * comment */ void OperatorControl(void) { while (IsOperatorControl()) { myRobot.SetSafetyEnabled(true); myRobot.MecanumDrive_Cartesian(stick.GetX(), stick.GetY(), stick.GetThrottle(), 0); // drive with arcade style (use right stick) if(stick.GetTrigger()) jag2.SetSpeed(.8); jag1.SetSpeed(.5); Wait(.2); Sol1.Set(true); if(stick2.GetTrigger()) jag1.SetSpeed(.5); else Sol1.Set(false); jag1.SetSpeed(0); jag2.SetSpeed(0); Wait(0.005); // wait for a motor update time } } }; START_ROBOT_CLASS(RobotDemo); |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|