Straberrie
22-12-2008, 21:14
Hi! Currently, I am trying to program the camera and the bot so that when it detects green, it aligns itself with the traget, but since i epicly phailed at that, I decided to do something simpler and just make the bot go forward when it detects green! I made this code *well, technically I used the guide and didnt really MAKE it* and i am getting 2 errors.... And i cant figure out whats wrong! help would be appreciated! THANKS!
So here are the headers I used:
#include "WPILib.h"
#include "AxisCamera.h"
#include "Servo.h"
#include "SimpleRobot.h"
#include "SensorBase.h"
#include "Error.h"
#include "ErrorBase.h"
#include "FrcError.h"
This is the rest of the defining and stuff!
class RobotDemo : public SimpleRobot
{
RobotDrive *Bot; // robot drive system
Joystick *stickRight;
Joystick *stickLeft;
DriverStation *ds; // driver station
public:
RobotDemo(void)
{
if (StartCameraTask ()== -1) {
printf( "Failed to spawn camera task; Error code %s",
GetErrorText (GetLastError()) };
ds = DriverStation::GetInstance();
Bot = new RobotDrive(1, 2); // create robot drive base
stickRight = new Joystick(1);
stickLeft = new Joystick(2);
Range greenHue, greenSat, greenLum;
greenHue.minValue = 65; greenHue.maxValue = 80;
greenSat.minValue =100; greenSat.maxValue = 255;
greenLum.minValue = 100; greenLum.maxValue = 255;
GetWatchdog().SetExpiration(100);
}
and here is the autonomous:
void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
while(IsAutonomous())
{
if( FindColor(IMAQ_HSL, &greenHue, &greenSat, &greenLum, &par)
&& par.particleToImagePercent < MAX_PARTICLE_TO_IMAGE_PERCENT
&& par.particleToImagePercent > MIN_PARTICLE_TO_IMAGE_PERCENT )
{Bot->Drive(1.0, (float)par.center_mass_x_normalized);}
else
Bot->Drive(0.0, 0.0);
Wait(50);
}
Bot->Drive(0.0, 0.0); // stop robot
}
and the very end line of the code:
START_ROBOT_CLASS(RobotDemo);
I highlighted the lines where i get an error; basically on the get error one, they say the function was not defined.... and it also highlights the Start Robot Class thing as wrong. And is camera initiated/used right? Because in the guide, there are different things on different pages and I did not know what to use... Sorry for the lengthy question.
So here are the headers I used:
#include "WPILib.h"
#include "AxisCamera.h"
#include "Servo.h"
#include "SimpleRobot.h"
#include "SensorBase.h"
#include "Error.h"
#include "ErrorBase.h"
#include "FrcError.h"
This is the rest of the defining and stuff!
class RobotDemo : public SimpleRobot
{
RobotDrive *Bot; // robot drive system
Joystick *stickRight;
Joystick *stickLeft;
DriverStation *ds; // driver station
public:
RobotDemo(void)
{
if (StartCameraTask ()== -1) {
printf( "Failed to spawn camera task; Error code %s",
GetErrorText (GetLastError()) };
ds = DriverStation::GetInstance();
Bot = new RobotDrive(1, 2); // create robot drive base
stickRight = new Joystick(1);
stickLeft = new Joystick(2);
Range greenHue, greenSat, greenLum;
greenHue.minValue = 65; greenHue.maxValue = 80;
greenSat.minValue =100; greenSat.maxValue = 255;
greenLum.minValue = 100; greenLum.maxValue = 255;
GetWatchdog().SetExpiration(100);
}
and here is the autonomous:
void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
while(IsAutonomous())
{
if( FindColor(IMAQ_HSL, &greenHue, &greenSat, &greenLum, &par)
&& par.particleToImagePercent < MAX_PARTICLE_TO_IMAGE_PERCENT
&& par.particleToImagePercent > MIN_PARTICLE_TO_IMAGE_PERCENT )
{Bot->Drive(1.0, (float)par.center_mass_x_normalized);}
else
Bot->Drive(0.0, 0.0);
Wait(50);
}
Bot->Drive(0.0, 0.0); // stop robot
}
and the very end line of the code:
START_ROBOT_CLASS(RobotDemo);
I highlighted the lines where i get an error; basically on the get error one, they say the function was not defined.... and it also highlights the Start Robot Class thing as wrong. And is camera initiated/used right? Because in the guide, there are different things on different pages and I did not know what to use... Sorry for the lengthy question.