added basic time drive auto
This commit is contained in:
parent
73c96c9b9d
commit
f7b7eb47d2
@ -1,5 +1,6 @@
|
|||||||
package org.usfirst.frc.team2059.robot;
|
package org.usfirst.frc.team2059.robot;
|
||||||
import org.usfirst.frc.team2059.robot.commands.CommandBase;
|
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.IterativeRobot;
|
||||||
import edu.wpi.first.wpilibj.command.Command;
|
import edu.wpi.first.wpilibj.command.Command;
|
||||||
import edu.wpi.first.wpilibj.command.Scheduler;
|
import edu.wpi.first.wpilibj.command.Scheduler;
|
||||||
@ -14,6 +15,10 @@ public class Robot extends IterativeRobot {
|
|||||||
CommandBase.init();
|
CommandBase.init();
|
||||||
oi = new OI();
|
oi = new OI();
|
||||||
chooser = new SendableChooser();
|
chooser = new SendableChooser();
|
||||||
|
|
||||||
|
chooser.addDefault("Time based drive", new RoutineDriveTime());
|
||||||
|
chooser.addObject("Distance based drive", new RoutineDriveTime());
|
||||||
|
|
||||||
SmartDashboard.putData("Auto mode", chooser);
|
SmartDashboard.putData("Auto mode", chooser);
|
||||||
SmartDashboard.putData("MainArm", CommandBase.mainArm.getPIDController());
|
SmartDashboard.putData("MainArm", CommandBase.mainArm.getPIDController());
|
||||||
SmartDashboard.putData("LeftEncoderController", CommandBase.driveBase.getLeftController());
|
SmartDashboard.putData("LeftEncoderController", CommandBase.driveBase.getLeftController());
|
||||||
|
@ -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
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user