Quote:
Originally Posted by mikelowry
Thanks for all the help so far. One more question.
We are using the simple robot template, and as far as I can tell, everything is right, but it wont build.
Code:
#include "WPILib.h"
RobotDrive myRobot(1,2);
Joystick leftStick(1);
Joystick rightStick(2);
class RobotDemo : public SimpleRobot
{
RobotDemo(void)
{
GetWatchdog().SetEnabled(false);
}
void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
while(1)
{
for(int i = 0; i < 4; i++)
{
myRobot.TankDrive(0.5,-0.5);
Wait(4);
myRobot.TankDrive(0.5,0.5);
Wait(2);
}
myRobot.TankDrive(0.0,0.0);
Wait(4);
}
}
void OperatorControl(void)
{
while(1)
{
GetWatchdog().SetEnabled(false);
while (IsOperatorControl())
{
myRobot.TankDrive(leftStick, rightStick);
Wait(0.005);
}
}
}
};
START_ROBOT_CLASS(RobotDemo);
we get the following errors at build:
"RobotDemo::RobotDemo()' is private" in reference to line 7
and
a nonspecific error at the very last line.
Can you tell what I need to do to fix it?
|
you should also put the Joystics and RobotDrive inside the class (and move the constructors for them, you SHOULD use the watchdog (unless debugging), and you have infinite loops (and auto is longer than 15 seconds, but i am assuming it is not for a real competition):
Code:
#include "WPILib.h"
class RobotDemo : public SimpleRobot
{
RobotDrive myRobot;
Joystick leftStick;
Joystick rightStick;
public:
RobotDemo():myRobot(1,2), leftStick(1), rightStick(2)//need to put them here
{
//GetWatchdog().SetEnabled(false); dont need to do this here
}
void Autonomous()
{
GetWatchdog().SetEnabled(false);
//while(1)
//{
for(int i = 0; i < 4; i++)
{
myRobot.TankDrive(0.5,-0.5);
Wait(4);
myRobot.TankDrive(0.5,0.5);
Wait(2);
}
myRobot.TankDrive(0.0,0.0);
Wait(4);
//}
}
void OperatorControl()
{
//while(1) and you should use while(true) in C++, while(1) is so C
//{
GetWatchdog().SetEnabled(true);
while (IsOperatorControl())
{
GetWatchdog().Feed();
myRobot.TankDrive(leftStick, rightStick);
Wait(0.005);
}
//}
}
};
START_ROBOT_CLASS(RobotDemo);