Skip to content

Commit

Permalink
Added blind baseline autonomous mode
Browse files Browse the repository at this point in the history
  • Loading branch information
briansemrau committed Feb 27, 2018
1 parent 6a7c805 commit 302f293
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/org/usfirst/frc/team4737/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package org.usfirst.frc.team4737.robot;

import org.usfirst.frc.team4737.robot.commands.drivetrain.AutoBlindBaseline;
import org.usfirst.frc.team4737.robot.commands.drivetrain.RelaxDrivetrain;
import org.usfirst.frc.team4737.robot.subsystems.Climber;
import org.usfirst.frc.team4737.robot.subsystems.Drivetrain;
Expand Down Expand Up @@ -34,18 +35,18 @@ public class Robot extends TimedRobot {
public static final Climber CLIMBER = new Climber();
public static final OI OI = new OI();

Command m_autonomousCommand;
SendableChooser<Command> m_chooser = new SendableChooser<>();
private Command autonomousCommand;
private SendableChooser<Command> chooser = new SendableChooser<>();

/**
* This function is run when the robot is first started up and should be used
* for any initialization code.
*/
@Override
public void robotInit() {
// m_chooser.addDefault("Default Auto", new ExampleCommand());
// chooser.addObject("My Auto", new MyAutoCommand());
SmartDashboard.putData("Auto mode", m_chooser);
chooser.addDefault("No Auto", null);
chooser.addObject("Blind Baseline", new AutoBlindBaseline());
SmartDashboard.putData("Auto mode", chooser);
}

/**
Expand Down Expand Up @@ -77,7 +78,7 @@ public void disabledPeriodic() {
*/
@Override
public void autonomousInit() {
m_autonomousCommand = m_chooser.getSelected();
autonomousCommand = chooser.getSelected();

/*
* String autoSelected = SmartDashboard.getString("Auto Selector", "Default");
Expand All @@ -87,8 +88,8 @@ public void autonomousInit() {
*/

// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.start();
if (autonomousCommand != null) {
autonomousCommand.start();
}
}

Expand All @@ -106,8 +107,8 @@ public void teleopInit() {
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand != null) {
m_autonomousCommand.cancel();
if (autonomousCommand != null) {
autonomousCommand.cancel();
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/org/usfirst/frc/team4737/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,8 @@ public class RobotMap {
public static final double ELEVATOR_MAX_DOWN_SPEED = -0.6; // TODO tune

public static final double DRIVE_SLOW_SCALE = 0.5;

public static final double AUTO_BLIND_TIME = 5;
public static final double AUTO_BLIND_SPEED = 0.3;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.usfirst.frc.team4737.robot.commands.drivetrain;

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

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

/**
*
*/
public class AutoBlindBaseline extends Command {

public AutoBlindBaseline() {
requires(Robot.DRIVETRAIN);
}

// Called just before this Command runs the first time
protected void initialize() {
Robot.DRIVETRAIN.setBrakeMode();
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {
Robot.DRIVETRAIN.arcadeDrive(RobotMap.AUTO_BLIND_SPEED, 0);
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return this.timeSinceInitialized() > RobotMap.AUTO_BLIND_TIME;
}

// Called once after isFinished returns true
protected void end() {
Robot.DRIVETRAIN.arcadeDrive(0, 0);
}

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

}

0 comments on commit 302f293

Please sign in to comment.