mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Completed artf2675 - rename SimpleRobot -> SampleRobot.
Change-Id: I23fc503f64fa6a715867f4b92f9d03e21f6c5f82
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
|
||||
package $package;
|
||||
|
||||
|
||||
import edu.wpi.first.wpilibj.SampleRobot;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Autonomous and OperatorControl methods at the right time as controlled by the switches on
|
||||
* the driver station or the field controls.
|
||||
*
|
||||
* The VM is configured to automatically run this class, and to call the
|
||||
* functions corresponding to each mode, as described in the SampleRobot
|
||||
* documentation. If you change the name of this class or the package after
|
||||
* creating this project, you must also update the manifest file in the resource
|
||||
* directory.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
public class Robot extends SampleRobot {
|
||||
RobotDrive myRobot;
|
||||
Joystick stick;
|
||||
|
||||
public Robot() {
|
||||
myRobot = new RobotDrive(1, 2);
|
||||
myRobot.setExpiration(0.1);
|
||||
stick = new Joystick(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Drive left & right motors for 2 seconds then stop
|
||||
*/
|
||||
public void autonomous() {
|
||||
myRobot.setSafetyEnabled(false);
|
||||
myRobot.drive(-0.5, 0.0); // drive forwards half speed
|
||||
Timer.delay(2.0); // for 2 seconds
|
||||
myRobot.drive(0.0, 0.0); // stop robot
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the motors with arcade steering.
|
||||
*/
|
||||
public void operatorControl() {
|
||||
myRobot.setSafetyEnabled(true);
|
||||
while (isOperatorControl()) {
|
||||
myRobot.arcadeDrive(stick); // drive with arcade style (use right stick)
|
||||
Timer.delay(0.005); // wait for a motor update time
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs during test mode
|
||||
*/
|
||||
public void test() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user