added basic time drive auto

This commit is contained in:
Adam Long 2016-09-21 18:28:42 +00:00
parent 73c96c9b9d
commit f7b7eb47d2
3 changed files with 40 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package org.usfirst.frc.team2059.robot;
import org.usfirst.frc.team2059.robot.commands.CommandBase;
import org.usfirst.frc.team2059.robot.commands.autonomous.*;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
@ -14,6 +15,10 @@ public class Robot extends IterativeRobot {
CommandBase.init();
oi = new OI();
chooser = new SendableChooser();
chooser.addDefault("Time based drive", new RoutineDriveTime());
chooser.addObject("Distance based drive", new RoutineDriveTime());
SmartDashboard.putData("Auto mode", chooser);
SmartDashboard.putData("MainArm", CommandBase.mainArm.getPIDController());
SmartDashboard.putData("LeftEncoderController", CommandBase.driveBase.getLeftController());

View File

@ -0,0 +1,26 @@
package org.usfirst.frc.team2059.robot.commands.autonomous;
import org.usfirst.frc.team2059.robot.commands.CommandBase;
import org.usfirst.frc.team2059.robot.Robot;
public class AutoDriveTime extends CommandBase {
double power;
public AutoDriveTime(double timeout, double power) {
requires(driveBase);
this.power=power;
setTimeout(timeout);
}
protected void initialize() {
}
protected void execute() {
driveBase.driveArcade(0,power,0,0);
}
protected void end() {
driveBase.stopDriving();
}
protected void interrupted() {
end();
}
protected boolean isFinished() {
return isTimedOut();
}
}
// vim: sw=2:ts=2:sts=2

View File

@ -0,0 +1,9 @@
package org.usfirst.frc.team2059.robot.commands.autonomous;
import org.usfirst.frc.team2059.robot.commands.CommandBase;
import edu.wpi.first.wpilibj.command.CommandGroup;
import org.usfirst.frc.team2059.robot.Robot;
public class RoutineDriveTime extends CommandGroup{
public RoutineDriveTime(){
addSequential(new AutoDriveTime(2,.5));
}
}