Run wpiformat on merged repo (#1021)

This commit is contained in:
Tyler Veness
2018-05-13 17:09:56 -07:00
committed by Peter Johnson
parent 0babbf317c
commit 6729a7d6b1
481 changed files with 9581 additions and 6828 deletions

View File

@@ -12,31 +12,31 @@ package edu.wpi.first.wpilibj.templates.commandbased;
* interface to the commands and command groups that allow control of the robot.
*/
public class OI {
//// CREATING BUTTONS
// One type of button is a joystick button which is any button on a
//// joystick.
// You create one by telling it which joystick it's on and which button
// number it is.
// Joystick stick = new Joystick(port);
// Button button = new JoystickButton(stick, buttonNumber);
//// CREATING BUTTONS
// One type of button is a joystick button which is any button on a
//// joystick.
// You create one by telling it which joystick it's on and which button
// number it is.
// Joystick stick = new Joystick(port);
// Button button = new JoystickButton(stick, buttonNumber);
// There are a few additional built in buttons you can use. Additionally,
// by subclassing Button you can create custom triggers and bind those to
// commands the same as any other Button.
// There are a few additional built in buttons you can use. Additionally,
// by subclassing Button you can create custom triggers and bind those to
// commands the same as any other Button.
//// TRIGGERING COMMANDS WITH BUTTONS
// Once you have a button, it's trivial to bind it to a button in one of
// three ways:
//// TRIGGERING COMMANDS WITH BUTTONS
// Once you have a button, it's trivial to bind it to a button in one of
// three ways:
// Start the command when the button is pressed and let it run the command
// until it is finished as determined by it's isFinished method.
// button.whenPressed(new ExampleCommand());
// Start the command when the button is pressed and let it run the command
// until it is finished as determined by it's isFinished method.
// button.whenPressed(new ExampleCommand());
// Run the command while the button is being held down and interrupt it once
// the button is released.
// button.whileHeld(new ExampleCommand());
// Run the command while the button is being held down and interrupt it once
// the button is released.
// button.whileHeld(new ExampleCommand());
// 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());
// 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());
}

View File

@@ -23,98 +23,98 @@ import edu.wpi.first.wpilibj.templates.commandbased.subsystems.ExampleSubsystem;
* project.
*/
public class Robot extends TimedRobot {
public static ExampleSubsystem m_subsystem = new ExampleSubsystem();
public static OI m_oi;
public static ExampleSubsystem m_subsystem = new ExampleSubsystem();
public static OI m_oi;
Command m_autonomousCommand;
SendableChooser<Command> m_chooser = new SendableChooser<>();
Command m_autonomousCommand;
SendableChooser<Command> m_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_oi = new OI();
m_chooser.addDefault("Default Auto", new ExampleCommand());
// chooser.addObject("My Auto", new MyAutoCommand());
SmartDashboard.putData("Auto mode", m_chooser);
}
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit() {
m_oi = new OI();
m_chooser.addDefault("Default Auto", new ExampleCommand());
// chooser.addObject("My Auto", new MyAutoCommand());
SmartDashboard.putData("Auto mode", m_chooser);
}
/**
* This function is called once each time the robot enters Disabled mode.
* You can use it to reset any subsystem information you want to clear when
* the robot is disabled.
*/
@Override
public void disabledInit() {
/**
* This function is called once each time the robot enters Disabled mode.
* You can use it to reset any subsystem information you want to clear when
* the robot is disabled.
*/
@Override
public void disabledInit() {
}
}
@Override
public void disabledPeriodic() {
Scheduler.getInstance().run();
}
@Override
public void disabledPeriodic() {
Scheduler.getInstance().run();
}
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString code to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional commands to the
* chooser code above (like the commented example) or additional comparisons
* to the switch structure below with additional strings & commands.
*/
@Override
public void autonomousInit() {
m_autonomousCommand = m_chooser.getSelected();
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString code to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional commands to the
* chooser code above (like the commented example) or additional comparisons
* to the switch structure below with additional strings & commands.
*/
@Override
public void autonomousInit() {
m_autonomousCommand = m_chooser.getSelected();
/*
* String autoSelected = SmartDashboard.getString("Auto Selector",
* "Default"); switch(autoSelected) { case "My Auto": autonomousCommand
* = new MyAutoCommand(); break; case "Default Auto": default:
* autonomousCommand = new ExampleCommand(); break; }
*/
/*
* String autoSelected = SmartDashboard.getString("Auto Selector",
* "Default"); switch(autoSelected) { case "My Auto": autonomousCommand
* = new MyAutoCommand(); break; case "Default Auto": default:
* autonomousCommand = new ExampleCommand(); break; }
*/
// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.start();
}
}
// schedule the autonomous command (example)
if (m_autonomousCommand != null) {
m_autonomousCommand.start();
}
}
/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
Scheduler.getInstance().run();
}
/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
Scheduler.getInstance().run();
}
@Override
public void teleopInit() {
// This makes sure that the autonomous stops running when
// 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();
}
}
@Override
public void teleopInit() {
// This makes sure that the autonomous stops running when
// 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();
}
}
/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
Scheduler.getInstance().run();
}
/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
Scheduler.getInstance().run();
}
/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
}

View File

@@ -14,13 +14,13 @@ package edu.wpi.first.wpilibj.templates.commandbased;
* floating around.
*/
public class RobotMap {
// For example to map the left and right motors, you could define the
// following variables to use with your drivetrain subsystem.
// public static int leftMotor = 1;
// public static int rightMotor = 2;
// For example to map the left and right motors, you could define the
// following variables to use with your drivetrain subsystem.
// public static int leftMotor = 1;
// public static int rightMotor = 2;
// If you are using multiple modules, make sure to define both the port
// number and the module. For example you with a rangefinder:
// public static int rangefinderPort = 1;
// public static int rangefinderModule = 1;
// If you are using multiple modules, make sure to define both the port
// number and the module. For example you with a rangefinder:
// public static int rangefinderPort = 1;
// public static int rangefinderModule = 1;
}

View File

@@ -14,35 +14,35 @@ import edu.wpi.first.wpilibj.templates.commandbased.Robot;
* An example command. You can replace me with your own command.
*/
public class ExampleCommand extends Command {
public ExampleCommand() {
// Use requires() here to declare subsystem dependencies
requires(Robot.m_subsystem);
}
public ExampleCommand() {
// Use requires() here to declare subsystem dependencies
requires(Robot.m_subsystem);
}
// Called just before this Command runs the first time
@Override
protected void initialize() {
}
// Called just before this Command runs the first time
@Override
protected void initialize() {
}
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
}
// Called repeatedly when this Command is scheduled to run
@Override
protected void execute() {
}
// Make this return true when this Command no longer needs to run execute()
@Override
protected boolean isFinished() {
return false;
}
// Make this return true when this Command no longer needs to run execute()
@Override
protected boolean isFinished() {
return false;
}
// Called once after isFinished returns true
@Override
protected void end() {
}
// Called once after isFinished returns true
@Override
protected void end() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
@Override
protected void interrupted() {
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
@Override
protected void interrupted() {
}
}

View File

@@ -13,11 +13,11 @@ import edu.wpi.first.wpilibj.command.Subsystem;
* An example subsystem. You can replace me with your own Subsystem.
*/
public class ExampleSubsystem extends Subsystem {
// Put methods for controlling this subsystem
// here. Call these from Commands.
// Put methods for controlling this subsystem
// here. Call these from Commands.
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
public void initDefaultCommand() {
// Set the default command for a subsystem here.
// setDefaultCommand(new MySpecialCommand());
}
}

View File

@@ -19,68 +19,68 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
* project.
*/
public class Robot extends IterativeRobot {
private static final String kDefaultAuto = "Default";
private static final String kCustomAuto = "My Auto";
private String m_autoSelected;
private SendableChooser<String> m_chooser = new SendableChooser<>();
private static final String kDefaultAuto = "Default";
private static final String kCustomAuto = "My Auto";
private String m_autoSelected;
private SendableChooser<String> m_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", kDefaultAuto);
m_chooser.addObject("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);
}
/**
* 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", kDefaultAuto);
m_chooser.addObject("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);
}
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the switch structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
@Override
public void autonomousInit() {
m_autoSelected = m_chooser.getSelected();
// autoSelected = SmartDashboard.getString("Auto Selector",
// defaultAuto);
System.out.println("Auto selected: " + m_autoSelected);
}
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the switch structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
@Override
public void autonomousInit() {
m_autoSelected = m_chooser.getSelected();
// autoSelected = SmartDashboard.getString("Auto Selector",
// defaultAuto);
System.out.println("Auto selected: " + m_autoSelected);
}
/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
switch (m_autoSelected) {
case kCustomAuto:
// Put custom auto code here
break;
case kDefaultAuto:
default:
// Put default auto code here
break;
}
}
/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
switch (m_autoSelected) {
case kCustomAuto:
// Put custom auto code here
break;
case kDefaultAuto:
default:
// Put default auto code here
break;
}
}
/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
}
/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
}
/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
}

View File

@@ -33,123 +33,123 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
* Command-Based instead if you're new.
*/
public class Robot extends SampleRobot {
private static final String kDefaultAuto = "Default";
private static final String kCustomAuto = "My Auto";
private static final String kDefaultAuto = "Default";
private static final String kCustomAuto = "My Auto";
private DifferentialDrive m_robotDrive
= new DifferentialDrive(new Spark(0), new Spark(1));
private Joystick m_stick = new Joystick(0);
private SendableChooser<String> m_chooser = new SendableChooser<>();
private DifferentialDrive m_robotDrive
= new DifferentialDrive(new Spark(0), new Spark(1));
private Joystick m_stick = new Joystick(0);
private SendableChooser<String> m_chooser = new SendableChooser<>();
public Robot() {
m_robotDrive.setExpiration(0.1);
}
public Robot() {
m_robotDrive.setExpiration(0.1);
}
@Override
public void robotInit() {
m_chooser.addDefault("Default Auto", kDefaultAuto);
m_chooser.addObject("My Auto", kCustomAuto);
SmartDashboard.putData("Auto modes", m_chooser);
}
@Override
public void robotInit() {
m_chooser.addDefault("Default Auto", kDefaultAuto);
m_chooser.addObject("My Auto", kCustomAuto);
SmartDashboard.putData("Auto modes", m_chooser);
}
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the if-else structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*
* <p>If you wanted to run a similar autonomous mode with an IterativeRobot
* you would write:
*
* <blockquote><pre>{@code
* Timer timer = new Timer();
*
* // This function is run once each time the robot enters autonomous mode
* public void autonomousInit() {
* timer.reset();
* timer.start();
* }
*
* // This function is called periodically during autonomous
* public void autonomousPeriodic() {
* // Drive for 2 seconds
* if (timer.get() < 2.0) {
* myRobot.drive(-0.5, 0.0); // drive forwards half speed
* } else if (timer.get() < 5.0) {
* myRobot.drive(-1.0, 0.0); // drive forwards full speed
* } else {
* myRobot.drive(0.0, 0.0); // stop robot
* }
* }
* }</pre></blockquote>
*/
@Override
public void autonomous() {
String autoSelected = m_chooser.getSelected();
// String autoSelected = SmartDashboard.getString("Auto Selector",
// defaultAuto);
System.out.println("Auto selected: " + autoSelected);
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the if-else structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*
* <p>If you wanted to run a similar autonomous mode with an IterativeRobot
* you would write:
*
* <blockquote><pre>{@code
* Timer timer = new Timer();
*
* // This function is run once each time the robot enters autonomous mode
* public void autonomousInit() {
* timer.reset();
* timer.start();
* }
*
* // This function is called periodically during autonomous
* public void autonomousPeriodic() {
* // Drive for 2 seconds
* if (timer.get() < 2.0) {
* myRobot.drive(-0.5, 0.0); // drive forwards half speed
* } else if (timer.get() < 5.0) {
* myRobot.drive(-1.0, 0.0); // drive forwards full speed
* } else {
* myRobot.drive(0.0, 0.0); // stop robot
* }
* }
* }</pre></blockquote>
*/
@Override
public void autonomous() {
String autoSelected = m_chooser.getSelected();
// String autoSelected = SmartDashboard.getString("Auto Selector",
// defaultAuto);
System.out.println("Auto selected: " + autoSelected);
// MotorSafety improves safety when motors are updated in loops
// but is disabled here because motor updates are not looped in
// this autonomous mode.
m_robotDrive.setSafetyEnabled(false);
// MotorSafety improves safety when motors are updated in loops
// but is disabled here because motor updates are not looped in
// this autonomous mode.
m_robotDrive.setSafetyEnabled(false);
switch (autoSelected) {
case kCustomAuto:
// Spin at half speed for two seconds
m_robotDrive.arcadeDrive(0.0, 0.5);
Timer.delay(2.0);
switch (autoSelected) {
case kCustomAuto:
// Spin at half speed for two seconds
m_robotDrive.arcadeDrive(0.0, 0.5);
Timer.delay(2.0);
// Stop robot
m_robotDrive.arcadeDrive(0.0, 0.0);
break;
case kDefaultAuto:
default:
// Drive forwards for two seconds
m_robotDrive.arcadeDrive(-0.5, 0.0);
Timer.delay(2.0);
// Stop robot
m_robotDrive.arcadeDrive(0.0, 0.0);
break;
case kDefaultAuto:
default:
// Drive forwards for two seconds
m_robotDrive.arcadeDrive(-0.5, 0.0);
Timer.delay(2.0);
// Stop robot
m_robotDrive.arcadeDrive(0.0, 0.0);
break;
}
}
// Stop robot
m_robotDrive.arcadeDrive(0.0, 0.0);
break;
}
}
/**
* Runs the motors with arcade steering.
*
* <p>If you wanted to run a similar teleoperated mode with an IterativeRobot
* you would write:
*
* <blockquote><pre>{@code
* // This function is called periodically during operator control
* public void teleopPeriodic() {
* myRobot.arcadeDrive(stick);
* }
* }</pre></blockquote>
*/
@Override
public void operatorControl() {
m_robotDrive.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {
// Drive arcade style
m_robotDrive.arcadeDrive(-m_stick.getY(), m_stick.getX());
/**
* Runs the motors with arcade steering.
*
* <p>If you wanted to run a similar teleoperated mode with an IterativeRobot
* you would write:
*
* <blockquote><pre>{@code
* // This function is called periodically during operator control
* public void teleopPeriodic() {
* myRobot.arcadeDrive(stick);
* }
* }</pre></blockquote>
*/
@Override
public void operatorControl() {
m_robotDrive.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {
// Drive arcade style
m_robotDrive.arcadeDrive(-m_stick.getY(), m_stick.getX());
// The motors will be updated every 5ms
Timer.delay(0.005);
}
}
// The motors will be updated every 5ms
Timer.delay(0.005);
}
}
/**
* Runs during test mode.
*/
@Override
public void test() {
}
/**
* Runs during test mode.
*/
@Override
public void test() {
}
}

View File

@@ -19,68 +19,68 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
* project.
*/
public class Robot extends TimedRobot {
private static final String kDefaultAuto = "Default";
private static final String kCustomAuto = "My Auto";
private String m_autoSelected;
private SendableChooser<String> m_chooser = new SendableChooser<>();
private static final String kDefaultAuto = "Default";
private static final String kCustomAuto = "My Auto";
private String m_autoSelected;
private SendableChooser<String> m_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", kDefaultAuto);
m_chooser.addObject("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);
}
/**
* 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", kDefaultAuto);
m_chooser.addObject("My Auto", kCustomAuto);
SmartDashboard.putData("Auto choices", m_chooser);
}
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the switch structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
@Override
public void autonomousInit() {
m_autoSelected = m_chooser.getSelected();
// m_autoSelected = SmartDashboard.getString("Auto Selector",
// kDefaultAuto);
System.out.println("Auto selected: " + m_autoSelected);
}
/**
* This autonomous (along with the chooser code above) shows how to select
* between different autonomous modes using the dashboard. The sendable
* chooser code works with the Java SmartDashboard. If you prefer the
* LabVIEW Dashboard, remove all of the chooser code and uncomment the
* getString line to get the auto name from the text box below the Gyro
*
* <p>You can add additional auto modes by adding additional comparisons to
* the switch structure below with additional strings. If using the
* SendableChooser make sure to add them to the chooser code above as well.
*/
@Override
public void autonomousInit() {
m_autoSelected = m_chooser.getSelected();
// m_autoSelected = SmartDashboard.getString("Auto Selector",
// kDefaultAuto);
System.out.println("Auto selected: " + m_autoSelected);
}
/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
switch (m_autoSelected) {
case kCustomAuto:
// Put custom auto code here
break;
case kDefaultAuto:
default:
// Put default auto code here
break;
}
}
/**
* This function is called periodically during autonomous.
*/
@Override
public void autonomousPeriodic() {
switch (m_autoSelected) {
case kCustomAuto:
// Put custom auto code here
break;
case kDefaultAuto:
default:
// Put default auto code here
break;
}
}
/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
}
/**
* This function is called periodically during operator control.
*/
@Override
public void teleopPeriodic() {
}
/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
/**
* This function is called periodically during test mode.
*/
@Override
public void testPeriodic() {
}
}