Skip to content

Instantly share code, notes, and snippets.

@davidtsong
Created November 22, 2016 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidtsong/fc1ba8167b54cc3b96c3a2cdc399da50 to your computer and use it in GitHub Desktop.
Save davidtsong/fc1ba8167b54cc3b96c3a2cdc399da50 to your computer and use it in GitHub Desktop.
package org.usfirst.frc.team295.robot;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.VictorSP;
/**
* This is a demo program showing the use of the RobotDrive class, specifically it
* contains the code necessary to operate a robot with tank drive.
*
* 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; // class that handles basic drive operations
Joystick driver; // set to ID 1 in DriverStation
Jaguar driveBackLeft;
Victor driveBackRight;
Jaguar driveFrontLeft;
Jaguar driveFrontRight;
public Robot() {
driveBackLeft = new Jaguar(0);
driveFrontLeft = new Jaguar(1);
driveBackRight = new Victor(2);
driveFrontRight = new Jaguar(3);
myRobot = new RobotDrive(driveFrontLeft,driveBackLeft,driveFrontRight,driveBackRight);
myRobot.setExpiration(0.1);
driver = new Joystick(0);
}
/**
* Runs the motors with tank steering.
*/
public void operatorControl() {
// driveBackRight.set(1);
// driveFrontRight.set(1);
// driveBackLeft.set(1);
// driveFrontLeft.set(1);
while (isOperatorControl() && isEnabled()) {
myRobot.tankDrive(driver.getRawAxis(1), driver.getRawAxis(5));
Timer.delay(0.005); // wait for a motor update time
}
}
public void disabled(){
System.out.println("disabled");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment