Skip to content

Commit

Permalink
Added TeleopTankDrive command
Browse files Browse the repository at this point in the history
  • Loading branch information
briansemrau committed Feb 10, 2018
1 parent aa22dfc commit 10f26f3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/org/usfirst/frc/team4737/robot/OI.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

package org.usfirst.frc.team4737.robot;

import edu.wpi.first.wpilibj.Joystick;

/**
* This class is the glue that binds the controls on the physical operator
* interface to the commands and command groups that allow control of the robot.
Expand Down Expand Up @@ -39,4 +41,13 @@ public class OI {
// Start the command when the button is released and let it run the command
// until it is finished as determined by it's isFinished method.
// button.whenReleased(new ExampleCommand());

public Joystick leftJoystick;
public Joystick rightJoystick;

public OI() {
leftJoystick = new Joystick(0);
rightJoystick = new Joystick(1);
}

}
42 changes: 42 additions & 0 deletions src/org/usfirst/frc/team4737/robot/commands/TeleopTankDrive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.usfirst.frc.team4737.robot.commands;

import org.usfirst.frc.team4737.robot.Robot;

import edu.wpi.first.wpilibj.command.Command;

/**
*
*/
public class TeleopTankDrive extends Command {

public TeleopTankDrive() {
// Use requires() here to declare subsystem dependencies
requires(Robot.DRIVETRAIN);
}

// Called just before this Command runs the first time
protected void initialize() {
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {
Robot.DRIVETRAIN.tankDrive(
Robot.OI.leftJoystick.getRawAxis(1),
Robot.OI.rightJoystick.getRawAxis(1));
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return false;
}

// Called once after isFinished returns true
protected void end() {
}

// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.usfirst.frc.team4737.robot.subsystems;

import org.usfirst.frc.team4737.robot.RobotMap;
import org.usfirst.frc.team4737.robot.commands.TeleopTankDrive;

import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;

Expand Down Expand Up @@ -30,7 +31,7 @@ public Drivetrain() {

public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
setDefaultCommand(new TeleopTankDrive());
}

/**
Expand Down

0 comments on commit 10f26f3

Please sign in to comment.