mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
60 lines
965 B
C++
60 lines
965 B
C++
|
|
#include "WPILib.h"
|
||
|
|
|
||
|
|
class Robot: public IterativeRobot
|
||
|
|
{
|
||
|
|
|
||
|
|
RobotDrive myRobot; // robot drive system
|
||
|
|
Joystick stick; // only joystick
|
||
|
|
LiveWindow *lw;
|
||
|
|
int autoLoopCounter;
|
||
|
|
|
||
|
|
public:
|
||
|
|
Robot() :
|
||
|
|
myRobot(0, 1), // these must be initialized in the same order
|
||
|
|
stick(1), // as they are declared above.
|
||
|
|
lw(NULL),
|
||
|
|
autoLoopCounter(0)
|
||
|
|
{
|
||
|
|
myRobot.SetExpiration(0.1);
|
||
|
|
}
|
||
|
|
|
||
|
|
private:
|
||
|
|
void RobotInit()
|
||
|
|
{
|
||
|
|
lw = LiveWindow::GetInstance();
|
||
|
|
}
|
||
|
|
|
||
|
|
void AutonomousInit()
|
||
|
|
{
|
||
|
|
autoLoopCounter = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
void AutonomousPeriodic()
|
||
|
|
{
|
||
|
|
if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
|
||
|
|
{
|
||
|
|
myRobot.Drive(-0.5, 0.0); // drive forwards half speed
|
||
|
|
autoLoopCounter++;
|
||
|
|
} else {
|
||
|
|
myRobot.Drive(0.0, 0.0); // stop robot
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void TeleopInit()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
void TeleopPeriodic()
|
||
|
|
{
|
||
|
|
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
|
||
|
|
}
|
||
|
|
|
||
|
|
void TestPeriodic()
|
||
|
|
{
|
||
|
|
lw->Run();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
START_ROBOT_CLASS(Robot);
|