mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Add OI and RobotMap files to Command Project template (fixes artf2407)
Change-Id: Ia3fb2a03b6435ae74bd70ad856a41a2c15f22f5a
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package $package;
|
||||
|
||||
import edu.wpi.first.wpilibj.buttons.Button;
|
||||
import $package.commands.ExampleCommand;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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);
|
||||
|
||||
// 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:
|
||||
|
||||
// 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());
|
||||
|
||||
// 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());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import $package.subsystems.ExampleSubsystem;
|
||||
public class Robot extends IterativeRobot {
|
||||
|
||||
public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem();
|
||||
public static OI oi;
|
||||
|
||||
Command autonomousCommand;
|
||||
|
||||
@@ -26,6 +27,7 @@ public class Robot extends IterativeRobot {
|
||||
* used for any initialization code.
|
||||
*/
|
||||
public void robotInit() {
|
||||
oi = new OI();
|
||||
// instantiate the command used for the autonomous period
|
||||
autonomousCommand = new ExampleCommand();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package $package;
|
||||
/**
|
||||
* The RobotMap is a mapping from the ports sensors and actuators are wired into
|
||||
* to a variable name. This provides flexibility changing wiring, makes checking
|
||||
* the wiring easier and significantly reduces the number of magic numbers
|
||||
* 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 final int leftMotor = 1;
|
||||
// public static final 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 final int rangefinderPort = 1;
|
||||
// public static final int rangefinderModule = 1;
|
||||
}
|
||||
@@ -33,6 +33,8 @@ public class JavaProjectType implements ProjectType {
|
||||
@Override public Map<String, String> getFiles(String packageName) {
|
||||
Map<String, String> files = super.getFiles(packageName);
|
||||
files.put("src/"+packageName.replace(".", "/")+"/Robot.java", "command-based/Robot.java");
|
||||
files.put("src/"+packageName.replace(".", "/")+"/RobotMap.java", "command-based/RobotMap.java");
|
||||
files.put("src/"+packageName.replace(".", "/")+"/OI.java", "command-based/OI.java");
|
||||
files.put("src/"+packageName.replace(".", "/")+"/commands/ExampleCommand.java", "command-based/ExampleCommand.java");
|
||||
files.put("src/"+packageName.replace(".", "/")+"/subsystems/ExampleSubsystem.java", "command-based/ExampleSubsystem.java");
|
||||
return files;
|
||||
|
||||
Reference in New Issue
Block a user