2013-12-15 18:30:16 -05:00
|
|
|
#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.
|
2014-02-25 18:43:40 -05:00
|
|
|
*/
|
|
|
|
|
class Robot: public SimpleRobot
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
|
|
|
|
RobotDrive myRobot; // robot drive system
|
|
|
|
|
Joystick stick; // only joystick
|
|
|
|
|
|
|
|
|
|
public:
|
2014-02-25 18:43:40 -05:00
|
|
|
Robot() :
|
|
|
|
|
myRobot(1, 2), // these must be initialized in the same order
|
|
|
|
|
stick(1) // as they are declared above.
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
|
|
|
|
myRobot.SetExpiration(0.1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Drive left & right motors for 2 seconds then stop
|
|
|
|
|
*/
|
2014-02-25 18:43:40 -05:00
|
|
|
void Autonomous()
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
|
|
|
|
myRobot.SetSafetyEnabled(false);
|
|
|
|
|
myRobot.Drive(-0.5, 0.0); // drive forwards half speed
|
|
|
|
|
Wait(2.0); // for 2 seconds
|
|
|
|
|
myRobot.Drive(0.0, 0.0); // stop robot
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Runs the motors with arcade steering.
|
|
|
|
|
*/
|
2014-02-25 18:43:40 -05:00
|
|
|
void OperatorControl()
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
|
|
|
|
myRobot.SetSafetyEnabled(true);
|
|
|
|
|
while (IsOperatorControl())
|
|
|
|
|
{
|
|
|
|
|
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
|
|
|
|
|
Wait(0.005); // wait for a motor update time
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-25 18:43:40 -05:00
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
/**
|
|
|
|
|
* Runs during test mode
|
|
|
|
|
*/
|
2014-02-25 18:43:40 -05:00
|
|
|
void Test()
|
|
|
|
|
{
|
2013-12-15 18:30:16 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
START_ROBOT_CLASS(Robot);
|