2013-12-15 18:30:16 -05:00
|
|
|
#include "WPILib.h"
|
|
|
|
|
|
|
|
|
|
/**
|
2014-08-08 10:48:00 -07:00
|
|
|
* This is a demo program showing the use of the RobotDrive class.
|
|
|
|
|
* The SampleRobot class is the base of a robot application that will automatically call your
|
2013-12-15 18:30:16 -05:00
|
|
|
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
|
|
|
|
|
* the driver station or the field controls.
|
2014-08-08 10:48:00 -07:00
|
|
|
*
|
|
|
|
|
* WARNING: While it may look like a good choice to use for your code if you're inexperienced,
|
|
|
|
|
* don't. Unless you know what you are doing, complex code will be much more difficult under
|
|
|
|
|
* this system. Use IterativeRobot or Command-Based instead if you're new.
|
2014-02-25 18:43:40 -05:00
|
|
|
*/
|
2014-08-08 10:48:00 -07:00
|
|
|
class Robot: public SampleRobot
|
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() :
|
2014-08-23 15:06:31 -07:00
|
|
|
myRobot(0, 1), // these must be initialized in the same order
|
2014-10-01 11:25:51 -04:00
|
|
|
stick(0) // 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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-08-08 10:48:00 -07:00
|
|
|
* Runs the motors with arcade steering.
|
2013-12-15 18:30:16 -05:00
|
|
|
*/
|
2014-02-25 18:43:40 -05:00
|
|
|
void OperatorControl()
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
|
|
|
|
myRobot.SetSafetyEnabled(true);
|
2014-10-27 15:52:37 -04:00
|
|
|
while (IsOperatorControl() && IsEnabled())
|
2013-12-15 18:30:16 -05:00
|
|
|
{
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-24 19:19:40 -04:00
|
|
|
START_ROBOT_CLASS(Robot)
|