[wpilib] Prefix all NI DS specific controller classes (#8596)

Easier then the last one that put everything in a sub namespace. By
prefixing the name less things break, and intellisense will be less
confusing to new users during the transition.
This commit is contained in:
Thad House
2026-02-06 21:36:01 -08:00
committed by GitHub
parent 77b2f9802e
commit 5c5d5222f4
133 changed files with 1959 additions and 2682 deletions

View File

@@ -2,7 +2,7 @@ EXAMPLES_FOLDERS = [
"addressableled",
"apriltagsvision",
"arcadedrive",
"arcadedrivexboxcontroller",
"arcadedrivegamepad",
"armsimulation",
"canpdp",
"differentialdrivebot",
@@ -48,7 +48,7 @@ EXAMPLES_FOLDERS = [
"swervedriveposeestimator",
"sysidroutine",
"tankdrive",
"tankdrivexboxcontroller",
"tankdrivegamepad",
"unittest",
"xrpreference",
]

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.examples.tankdrivexboxcontroller;
package org.wpilib.examples.arcadedrivegamepad;
import org.wpilib.framework.RobotBase;

View File

@@ -2,24 +2,24 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.examples.arcadedrivexboxcontroller;
package org.wpilib.examples.arcadedrivegamepad;
import org.wpilib.drive.DifferentialDrive;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.hardware.motor.PWMSparkMax;
import org.wpilib.util.sendable.SendableRegistry;
/**
* This is a demo program showing the use of the DifferentialDrive class. Runs the motors with split
* arcade steering and an Xbox controller.
* arcade steering and a gamepad.
*/
public class Robot extends TimedRobot {
private final PWMSparkMax m_leftMotor = new PWMSparkMax(0);
private final PWMSparkMax m_rightMotor = new PWMSparkMax(1);
private final DifferentialDrive m_robotDrive =
new DifferentialDrive(m_leftMotor::set, m_rightMotor::set);
private final XboxController m_driverController = new XboxController(0);
private final Gamepad m_driverController = new Gamepad(0);
/** Called once at the beginning of the robot program. */
public Robot() {

View File

@@ -4,12 +4,12 @@
package org.wpilib.examples.differentialdrivebot;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.math.filter.SlewRateLimiter;
public class Robot extends TimedRobot {
private final XboxController m_controller = new XboxController(0);
private final Gamepad m_controller = new Gamepad(0);
private final Drivetrain m_drive = new Drivetrain();
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0 to 1.
@@ -24,13 +24,13 @@ public class Robot extends TimedRobot {
@Override
public void teleopPeriodic() {
// Get the x speed. We are inverting this because Xbox controllers return
// Get the x speed. We are inverting this because gamepads return
// negative values when we push forward.
final var xSpeed = -m_speedLimiter.calculate(m_controller.getLeftY()) * Drivetrain.kMaxSpeed;
// Get the rate of angular rotation. We are inverting this because we want a
// positive value when we pull to the left (remember, CCW is positive in
// mathematics). Xbox controllers return positive values when you pull to
// mathematics). Gamepads return positive values when you pull to
// the right by default.
final var rot = -m_rotLimiter.calculate(m_controller.getRightX()) * Drivetrain.kMaxAngularSpeed;

View File

@@ -4,7 +4,7 @@
package org.wpilib.examples.differentialdriveposeestimator;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.math.filter.SlewRateLimiter;
import org.wpilib.networktables.DoubleArrayTopic;
@@ -15,7 +15,7 @@ public class Robot extends TimedRobot {
private final DoubleArrayTopic m_doubleArrayTopic =
m_inst.getDoubleArrayTopic("m_doubleArrayTopic");
private final XboxController m_controller = new XboxController(0);
private final Gamepad m_controller = new Gamepad(0);
private final Drivetrain m_drive = new Drivetrain(m_doubleArrayTopic);
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0 to 1.
@@ -40,13 +40,13 @@ public class Robot extends TimedRobot {
@Override
public void teleopPeriodic() {
// Get the x speed. We are inverting this because Xbox controllers return
// Get the x speed. We are inverting this because gamepad return
// negative values when we push forward.
final var xSpeed = -m_speedLimiter.calculate(m_controller.getLeftY()) * Drivetrain.kMaxSpeed;
// Get the rate of angular rotation. We are inverting this because we want a
// positive value when we pull to the left (remember, CCW is positive in
// mathematics). Xbox controllers return positive values when you pull to
// mathematics). Gamepads return positive values when you pull to
// the right by default.
final var rot = -m_rotLimiter.calculate(m_controller.getRightX()) * Drivetrain.kMaxAngularSpeed;

View File

@@ -6,8 +6,8 @@ package org.wpilib.examples.drivedistanceoffboard;
import org.wpilib.command2.Command;
import org.wpilib.command2.Commands;
import org.wpilib.command2.button.CommandXboxController;
import org.wpilib.driverstation.XboxController;
import org.wpilib.command2.button.CommandGamepad;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.examples.drivedistanceoffboard.Constants.OIConstants;
import org.wpilib.examples.drivedistanceoffboard.subsystems.DriveSubsystem;
@@ -26,8 +26,7 @@ public class RobotContainer {
private final Command m_driveHalfSpeed = Commands.runOnce(() -> m_robotDrive.setMaxOutput(0.5));
// The driver's controller
CommandXboxController m_driverController =
new CommandXboxController(OIConstants.kDriverControllerPort);
CommandGamepad m_driverController = new CommandGamepad(OIConstants.kDriverControllerPort);
/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
@@ -49,18 +48,22 @@ public class RobotContainer {
/**
* Use this method to define your button->command mappings. Buttons can be created by
* instantiating a {@link org.wpilib.driverstation.GenericHID} or one of its subclasses ({@link
* org.wpilib.driverstation.Joystick} or {@link XboxController}), and then passing it to a {@link
* org.wpilib.driverstation.Joystick} or {@link Gamepad}), and then passing it to a {@link
* org.wpilib.command2.button.JoystickButton}.
*/
private void configureButtonBindings() {
// Drive at half speed when the bumper is held
m_driverController.rightBumper().onTrue(m_driveHalfSpeed).onFalse(m_driveFullSpeed);
m_driverController.rightShoulder().onTrue(m_driveHalfSpeed).onFalse(m_driveFullSpeed);
// Drive forward by 3 meters when the 'A' button is pressed, with a timeout of 10 seconds
m_driverController.a().onTrue(m_robotDrive.profiledDriveDistance(3).withTimeout(10));
// Drive forward by 3 meters when the 'South Face' button is pressed, with a timeout of 10
// seconds
m_driverController.southFace().onTrue(m_robotDrive.profiledDriveDistance(3).withTimeout(10));
// Do the same thing as above when the 'B' button is pressed, but without resetting the encoders
m_driverController.b().onTrue(m_robotDrive.dynamicProfiledDriveDistance(3).withTimeout(10));
// Do the same thing as above when the 'East Face' button is pressed, but without resetting the
// encoders
m_driverController
.eastFace()
.onTrue(m_robotDrive.dynamicProfiledDriveDistance(3).withTimeout(10));
}
/**

View File

@@ -197,7 +197,7 @@
"description": "Make human interface devices (HID) rumble.",
"tags": [
"Hardware",
"XboxController"
"Gamepad"
],
"foldername": "hidrumble",
"gradlebase": "java",
@@ -291,7 +291,7 @@
"Pneumatics",
"Sendable",
"DataLog",
"XboxController"
"Gamepad"
],
"foldername": "hatchbottraditional",
"gradlebase": "java",
@@ -309,7 +309,7 @@
"Pneumatics",
"Sendable",
"DataLog",
"PS4Controller"
"Gamepad"
],
"foldername": "hatchbotinlined",
"gradlebase": "java",
@@ -331,7 +331,7 @@
"PID",
"Gyro",
"Profiled PID",
"XboxController"
"Gamepad"
],
"foldername": "rapidreactcommandbot",
"gradlebase": "java",
@@ -355,7 +355,7 @@
"tags": [
"Swerve Drive",
"Odometry",
"XboxController",
"Gamepad",
"Gyro",
"Encoder"
],
@@ -372,7 +372,7 @@
"Odometry",
"Encoder",
"Gyro",
"XboxController"
"Gamepad"
],
"foldername": "mecanumbot",
"gradlebase": "java",
@@ -387,7 +387,7 @@
"Odometry",
"Encoder",
"Gyro",
"XboxController"
"Gamepad"
],
"foldername": "differentialdrivebot",
"gradlebase": "java",
@@ -400,22 +400,22 @@
"tags": [
"Basic Robot",
"Differential Drive",
"XboxController"
"Gamepad"
],
"foldername": "arcadedrivexboxcontroller",
"foldername": "arcadedrivegamepad",
"gradlebase": "java",
"mainclass": "Main",
"commandversion": 2
},
{
"name": "Tank Drive Xbox Controller",
"name": "Tank Drive Gamepad",
"description": "Control a differential drive with Xbox tank drive in teleop.",
"tags": [
"Basic Robot",
"Differential Drive",
"XboxController"
"Gamepad"
],
"foldername": "tankdrivexboxcontroller",
"foldername": "tankdrivegamepad",
"gradlebase": "java",
"mainclass": "Main",
"commandversion": 2
@@ -468,7 +468,7 @@
"Differential Drive",
"Trapezoid Profile",
"Smart Motor Controller",
"XboxController"
"Gamepad"
],
"foldername": "drivedistanceoffboard",
"gradlebase": "java",
@@ -550,7 +550,7 @@
"Path Following",
"Trajectory",
"Encoder",
"XboxController",
"Gamepad",
"Simulation"
],
"foldername": "simpledifferentialdrivesimulation",
@@ -631,7 +631,7 @@
"Pose Estimator",
"Vision",
"PID",
"XboxController"
"Gamepad"
],
"foldername": "differentialdriveposeestimator",
"gradlebase": "java",
@@ -647,7 +647,7 @@
"Pose Estimator",
"Vision",
"PID",
"XboxController"
"Gamepad"
],
"foldername": "mecanumdriveposeestimator",
"gradlebase": "java",
@@ -663,7 +663,7 @@
"Pose Estimator",
"Vision",
"PID",
"XboxController"
"Gamepad"
],
"foldername": "swervedriveposeestimator",
"gradlebase": "java",

View File

@@ -5,7 +5,7 @@
package org.wpilib.examples.gettingstarted;
import org.wpilib.drive.DifferentialDrive;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.hardware.motor.PWMSparkMax;
import org.wpilib.system.Timer;
@@ -21,7 +21,7 @@ public class Robot extends TimedRobot {
private final PWMSparkMax m_rightDrive = new PWMSparkMax(1);
private final DifferentialDrive m_robotDrive =
new DifferentialDrive(m_leftDrive::set, m_rightDrive::set);
private final XboxController m_controller = new XboxController(0);
private final Gamepad m_controller = new Gamepad(0);
private final Timer m_timer = new Timer();
/** Called once at the beginning of the robot program. */

View File

@@ -6,8 +6,8 @@ package org.wpilib.examples.hatchbotinlined;
import org.wpilib.command2.Command;
import org.wpilib.command2.Commands;
import org.wpilib.command2.button.CommandPS4Controller;
import org.wpilib.driverstation.PS4Controller;
import org.wpilib.command2.button.CommandGamepad;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.examples.hatchbotinlined.Constants.OIConstants;
import org.wpilib.examples.hatchbotinlined.commands.Autos;
import org.wpilib.examples.hatchbotinlined.subsystems.DriveSubsystem;
@@ -38,8 +38,7 @@ public class RobotContainer {
SendableChooser<Command> m_chooser = new SendableChooser<>();
// The driver's controller
CommandPS4Controller m_driverController =
new CommandPS4Controller(OIConstants.kDriverControllerPort);
CommandGamepad m_driverController = new CommandGamepad(OIConstants.kDriverControllerPort);
/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
@@ -72,17 +71,17 @@ public class RobotContainer {
/**
* Use this method to define your button->command mappings. Buttons can be created by
* instantiating a {@link org.wpilib.driverstation.GenericHID} or one of its subclasses ({@link
* org.wpilib.driverstation.Joystick} or {@link PS4Controller}), and then passing it to a {@link
* org.wpilib.driverstation.Joystick} or {@link Gamepad}), and then passing it to a {@link
* org.wpilib.command2.button.JoystickButton}.
*/
private void configureButtonBindings() {
// Grab the hatch when the Circle button is pressed.
m_driverController.circle().onTrue(m_hatchSubsystem.grabHatchCommand());
// Release the hatch when the Square button is pressed.
m_driverController.square().onTrue(m_hatchSubsystem.releaseHatchCommand());
// While holding R1, drive at half speed
// Grab the hatch when the east face button is pressed.
m_driverController.eastFace().onTrue(m_hatchSubsystem.grabHatchCommand());
// Release the hatch when the west face button is pressed.
m_driverController.westFace().onTrue(m_hatchSubsystem.releaseHatchCommand());
// While holding right bumper, drive at half speed
m_driverController
.R1()
.rightShoulder()
.onTrue(Commands.runOnce(() -> m_robotDrive.setMaxOutput(0.5)))
.onFalse(Commands.runOnce(() -> m_robotDrive.setMaxOutput(1)));
}

View File

@@ -4,11 +4,11 @@
package org.wpilib.examples.hatchbottraditional;
import static org.wpilib.driverstation.XboxController.Button;
import static org.wpilib.driverstation.Gamepad.Button;
import org.wpilib.command2.Command;
import org.wpilib.command2.button.JoystickButton;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.examples.hatchbottraditional.Constants.AutoConstants;
import org.wpilib.examples.hatchbottraditional.Constants.OIConstants;
import org.wpilib.examples.hatchbottraditional.commands.ComplexAuto;
@@ -47,7 +47,7 @@ public class RobotContainer {
SendableChooser<Command> m_chooser = new SendableChooser<>();
// The driver's controller
XboxController m_driverController = new XboxController(OIConstants.kDriverControllerPort);
Gamepad m_driverController = new Gamepad(OIConstants.kDriverControllerPort);
/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
@@ -78,17 +78,18 @@ public class RobotContainer {
/**
* Use this method to define your button->command mappings. Buttons can be created by
* instantiating a {@link org.wpilib.driverstation.GenericHID} or one of its subclasses ({@link
* org.wpilib.driverstation.Joystick} or {@link XboxController}), and then passing it to a {@link
* org.wpilib.driverstation.Joystick} or {@link Gamepad}), and then passing it to a {@link
* org.wpilib.command2.button.JoystickButton}.
*/
private void configureButtonBindings() {
// Grab the hatch when the 'A' button is pressed.
new JoystickButton(m_driverController, Button.kA.value).onTrue(new GrabHatch(m_hatchSubsystem));
// Release the hatch when the 'B' button is pressed.
new JoystickButton(m_driverController, Button.kB.value)
// Grab the hatch when the 'South Face' button is pressed.
new JoystickButton(m_driverController, Button.kSouthFace.value)
.onTrue(new GrabHatch(m_hatchSubsystem));
// Release the hatch when the 'East Face' button is pressed.
new JoystickButton(m_driverController, Button.kEastFace.value)
.onTrue(new ReleaseHatch(m_hatchSubsystem));
// While holding the shoulder button, drive at half speed
new JoystickButton(m_driverController, Button.kRightBumper.value)
new JoystickButton(m_driverController, Button.kRightShoulder.value)
.whileTrue(new HalveDriveSpeed(m_robotDrive));
}

View File

@@ -4,13 +4,13 @@
package org.wpilib.examples.hidrumble;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.driverstation.GenericHID.RumbleType;
import org.wpilib.driverstation.XboxController;
import org.wpilib.framework.TimedRobot;
/** This is a demo program showing the use of GenericHID's rumble feature. */
public class Robot extends TimedRobot {
private final XboxController m_hid = new XboxController(0);
private final Gamepad m_hid = new Gamepad(0);
@Override
public void autonomousInit() {

View File

@@ -4,12 +4,12 @@
package org.wpilib.examples.mecanumbot;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.math.filter.SlewRateLimiter;
public class Robot extends TimedRobot {
private final XboxController m_controller = new XboxController(0);
private final Gamepad m_controller = new Gamepad(0);
private final Drivetrain m_mecanum = new Drivetrain();
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0 to 1.
@@ -29,18 +29,18 @@ public class Robot extends TimedRobot {
}
private void driveWithJoystick(boolean fieldRelative) {
// Get the x speed. We are inverting this because Xbox controllers return
// Get the x speed. We are inverting this because gamepads return
// negative values when we push forward.
final var xSpeed = -m_xspeedLimiter.calculate(m_controller.getLeftY()) * Drivetrain.kMaxSpeed;
// Get the y speed or sideways/strafe speed. We are inverting this because
// we want a positive value when we pull to the left. Xbox controllers
// we want a positive value when we pull to the left. Gamepads
// return positive values when you pull to the right by default.
final var ySpeed = -m_yspeedLimiter.calculate(m_controller.getLeftX()) * Drivetrain.kMaxSpeed;
// Get the rate of angular rotation. We are inverting this because we want a
// positive value when we pull to the left (remember, CCW is positive in
// mathematics). Xbox controllers return positive values when you pull to
// mathematics). Gamepads return positive values when you pull to
// the right by default.
final var rot = -m_rotLimiter.calculate(m_controller.getRightX()) * Drivetrain.kMaxAngularSpeed;

View File

@@ -4,12 +4,12 @@
package org.wpilib.examples.mecanumdriveposeestimator;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.math.filter.SlewRateLimiter;
public class Robot extends TimedRobot {
private final XboxController m_controller = new XboxController(0);
private final Gamepad m_controller = new Gamepad(0);
private final Drivetrain m_mecanum = new Drivetrain();
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0 to 1.
@@ -29,18 +29,18 @@ public class Robot extends TimedRobot {
}
private void driveWithJoystick(boolean fieldRelative) {
// Get the x speed. We are inverting this because Xbox controllers return
// Get the x speed. We are inverting this because gamepads return
// negative values when we push forward.
final var xSpeed = -m_xspeedLimiter.calculate(m_controller.getLeftY()) * Drivetrain.kMaxSpeed;
// Get the y speed or sideways/strafe speed. We are inverting this because
// we want a positive value when we pull to the left. Xbox controllers
// we want a positive value when we pull to the left. Gamepads
// return positive values when you pull to the right by default.
final var ySpeed = -m_yspeedLimiter.calculate(m_controller.getLeftX()) * Drivetrain.kMaxSpeed;
// Get the rate of angular rotation. We are inverting this because we want a
// positive value when we pull to the left (remember, CCW is positive in
// mathematics). Xbox controllers return positive values when you pull to
// mathematics). Gamepads return positive values when you pull to
// the right by default.
final var rot = -m_rotLimiter.calculate(m_controller.getRightX()) * Drivetrain.kMaxAngularSpeed;

View File

@@ -7,7 +7,7 @@ package org.wpilib.examples.rapidreactcommandbot;
import static org.wpilib.command2.Commands.parallel;
import org.wpilib.command2.Command;
import org.wpilib.command2.button.CommandXboxController;
import org.wpilib.command2.button.CommandGamepad;
import org.wpilib.command2.button.Trigger;
import org.wpilib.epilogue.Logged;
import org.wpilib.examples.rapidreactcommandbot.Constants.AutoConstants;
@@ -35,8 +35,7 @@ public class RapidReactCommandBot {
private final Pneumatics m_pneumatics = new Pneumatics();
// The driver's controller
CommandXboxController m_driverController =
new CommandXboxController(OIConstants.kDriverControllerPort);
CommandGamepad m_driverController = new CommandGamepad(OIConstants.kDriverControllerPort);
/**
* Use this method to define bindings between conditions and commands. These are useful for
@@ -60,14 +59,14 @@ public class RapidReactCommandBot {
m_drive.arcadeDriveCommand(
() -> -m_driverController.getLeftY(), () -> -m_driverController.getRightX()));
// Deploy the intake with the X button
m_driverController.x().onTrue(m_intake.intakeCommand());
// Retract the intake with the Y button
m_driverController.y().onTrue(m_intake.retractCommand());
// Deploy the intake with the west face button
m_driverController.westFace().onTrue(m_intake.intakeCommand());
// Retract the intake with the north face button
m_driverController.northFace().onTrue(m_intake.retractCommand());
// Fire the shooter with the A button
// Fire the shooter with the south face button
m_driverController
.a()
.southFace()
.onTrue(
parallel(
m_shooter.shootCommand(ShooterConstants.kShooterTargetRPS),

View File

@@ -7,9 +7,9 @@ package org.wpilib.examples.romireference;
import org.wpilib.command2.Command;
import org.wpilib.command2.PrintCommand;
import org.wpilib.command2.button.Trigger;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.driverstation.GenericHID;
import org.wpilib.driverstation.Joystick;
import org.wpilib.driverstation.XboxController;
import org.wpilib.examples.romireference.commands.ArcadeDrive;
import org.wpilib.examples.romireference.commands.AutonomousDistance;
import org.wpilib.examples.romireference.commands.AutonomousTime;
@@ -56,7 +56,7 @@ public class RobotContainer {
/**
* Use this method to define your button->command mappings. Buttons can be created by
* instantiating a {@link GenericHID} or one of its subclasses ({@link
* org.wpilib.driverstation.Joystick} or {@link XboxController}), and then passing it to a {@link
* org.wpilib.driverstation.Joystick} or {@link Gamepad}), and then passing it to a {@link
* org.wpilib.command2.button.JoystickButton}.
*/
private void configureButtonBindings() {

View File

@@ -8,8 +8,8 @@ import java.util.Map;
import org.wpilib.command2.Command;
import org.wpilib.command2.PrintCommand;
import org.wpilib.command2.SelectCommand;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.driverstation.GenericHID;
import org.wpilib.driverstation.XboxController;
/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
@@ -52,8 +52,8 @@ public class RobotContainer {
/**
* Use this method to define your button->command mappings. Buttons can be created by
* instantiating a {@link GenericHID} or one of its subclasses ({@link
* org.wpilib.driverstation.Joystick} or {@link XboxController}), and then calling passing it to a
* {@link org.wpilib.command2.button.JoystickButton}.
* org.wpilib.driverstation.Joystick} or {@link Gamepad}), and then calling passing it to a {@link
* org.wpilib.command2.button.JoystickButton}.
*/
private void configureButtonBindings() {}

View File

@@ -5,7 +5,7 @@
package org.wpilib.examples.simpledifferentialdrivesimulation;
import java.util.List;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.math.controller.LTVUnicycleController;
import org.wpilib.math.filter.SlewRateLimiter;
@@ -18,7 +18,7 @@ import org.wpilib.math.trajectory.TrajectoryGenerator;
import org.wpilib.system.Timer;
public class Robot extends TimedRobot {
private final XboxController m_controller = new XboxController(0);
private final Gamepad m_controller = new Gamepad(0);
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0
// to 1.
@@ -61,7 +61,7 @@ public class Robot extends TimedRobot {
@Override
public void teleopPeriodic() {
// Get the x speed. We are inverting this because Xbox controllers return
// Get the x speed. We are inverting this because gamepads return
// negative values when we push forward.
double xSpeed = -m_speedLimiter.calculate(m_controller.getLeftY()) * Drivetrain.kMaxSpeed;

View File

@@ -4,13 +4,13 @@
package org.wpilib.examples.swervebot;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.math.filter.SlewRateLimiter;
import org.wpilib.math.util.MathUtil;
public class Robot extends TimedRobot {
private final XboxController m_controller = new XboxController(0);
private final Gamepad m_controller = new Gamepad(0);
private final Drivetrain m_swerve = new Drivetrain();
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0 to 1.
@@ -30,7 +30,7 @@ public class Robot extends TimedRobot {
}
private void driveWithJoystick(boolean fieldRelative) {
// Get the x speed. We are inverting this because Xbox controllers return
// Get the x speed. We are inverting this because gamepads return
// negative values when we push forward.
final var xSpeed =
-m_xspeedLimiter.calculate(MathUtil.applyDeadband(m_controller.getLeftY(), 0.02))

View File

@@ -4,12 +4,12 @@
package org.wpilib.examples.swervedriveposeestimator;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.math.filter.SlewRateLimiter;
public class Robot extends TimedRobot {
private final XboxController m_controller = new XboxController(0);
private final Gamepad m_controller = new Gamepad(0);
private final Drivetrain m_swerve = new Drivetrain();
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0 to 1.
@@ -29,18 +29,18 @@ public class Robot extends TimedRobot {
}
private void driveWithJoystick(boolean fieldRelative) {
// Get the x speed. We are inverting this because Xbox controllers return
// Get the x speed. We are inverting this because gamepads return
// negative values when we push forward.
final var xSpeed = -m_xspeedLimiter.calculate(m_controller.getLeftY()) * Drivetrain.kMaxSpeed;
// Get the y speed or sideways/strafe speed. We are inverting this because
// we want a positive value when we pull to the left. Xbox controllers
// we want a positive value when we pull to the left. Gamepads
// return positive values when you pull to the right by default.
final var ySpeed = -m_yspeedLimiter.calculate(m_controller.getLeftX()) * Drivetrain.kMaxSpeed;
// Get the rate of angular rotation. We are inverting this because we want a
// positive value when we pull to the left (remember, CCW is positive in
// mathematics). Xbox controllers return positive values when you pull to
// mathematics). Gamepads return positive values when you pull to
// the right by default.
final var rot = -m_rotLimiter.calculate(m_controller.getRightX()) * Drivetrain.kMaxAngularSpeed;

View File

@@ -5,7 +5,7 @@
package org.wpilib.examples.sysidroutine;
import org.wpilib.command2.Command;
import org.wpilib.command2.button.CommandXboxController;
import org.wpilib.command2.button.CommandGamepad;
import org.wpilib.command2.button.Trigger;
import org.wpilib.command2.sysid.SysIdRoutine;
import org.wpilib.examples.sysidroutine.Constants.OIConstants;
@@ -24,8 +24,7 @@ public class SysIdRoutineBot {
private final Shooter m_shooter = new Shooter();
// The driver's controller
CommandXboxController m_driverController =
new CommandXboxController(OIConstants.kDriverControllerPort);
CommandGamepad m_driverController = new CommandGamepad(OIConstants.kDriverControllerPort);
/**
* Use this method to define bindings between conditions and commands. These are useful for
@@ -46,40 +45,40 @@ public class SysIdRoutineBot {
// Using bumpers as a modifier and combining it with the buttons so that we can have both sets
// of bindings at once
m_driverController
.a()
.and(m_driverController.rightBumper())
.southFace()
.and(m_driverController.rightShoulder())
.whileTrue(m_drive.sysIdQuasistatic(SysIdRoutine.Direction.kForward));
m_driverController
.b()
.and(m_driverController.rightBumper())
.eastFace()
.and(m_driverController.rightShoulder())
.whileTrue(m_drive.sysIdQuasistatic(SysIdRoutine.Direction.kReverse));
m_driverController
.x()
.and(m_driverController.rightBumper())
.westFace()
.and(m_driverController.rightShoulder())
.whileTrue(m_drive.sysIdDynamic(SysIdRoutine.Direction.kForward));
m_driverController
.y()
.and(m_driverController.rightBumper())
.northFace()
.and(m_driverController.rightShoulder())
.whileTrue(m_drive.sysIdDynamic(SysIdRoutine.Direction.kReverse));
// Control the shooter wheel with the left trigger
m_shooter.setDefaultCommand(m_shooter.runShooter(m_driverController::getLeftTriggerAxis));
m_driverController
.a()
.and(m_driverController.leftBumper())
.southFace()
.and(m_driverController.leftShoulder())
.whileTrue(m_shooter.sysIdQuasistatic(SysIdRoutine.Direction.kForward));
m_driverController
.b()
.and(m_driverController.leftBumper())
.eastFace()
.and(m_driverController.leftShoulder())
.whileTrue(m_shooter.sysIdQuasistatic(SysIdRoutine.Direction.kReverse));
m_driverController
.x()
.and(m_driverController.leftBumper())
.westFace()
.and(m_driverController.leftShoulder())
.whileTrue(m_shooter.sysIdDynamic(SysIdRoutine.Direction.kForward));
m_driverController
.y()
.and(m_driverController.leftBumper())
.northFace()
.and(m_driverController.leftShoulder())
.whileTrue(m_shooter.sysIdDynamic(SysIdRoutine.Direction.kReverse));
}

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.examples.arcadedrivexboxcontroller;
package org.wpilib.examples.tankdrivegamepad;
import org.wpilib.framework.RobotBase;

View File

@@ -2,24 +2,24 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package org.wpilib.examples.tankdrivexboxcontroller;
package org.wpilib.examples.tankdrivegamepad;
import org.wpilib.drive.DifferentialDrive;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.framework.TimedRobot;
import org.wpilib.hardware.motor.PWMSparkMax;
import org.wpilib.util.sendable.SendableRegistry;
/**
* This is a demo program showing the use of the DifferentialDrive class. Runs the motors with tank
* steering and an Xbox controller.
* steering and a gamepad.
*/
public class Robot extends TimedRobot {
private final PWMSparkMax m_leftMotor = new PWMSparkMax(0);
private final PWMSparkMax m_rightMotor = new PWMSparkMax(1);
private final DifferentialDrive m_robotDrive =
new DifferentialDrive(m_leftMotor::set, m_rightMotor::set);
private final XboxController m_driverController = new XboxController(0);
private final Gamepad m_driverController = new Gamepad(0);
/** Called once at the beginning of the robot program. */
public Robot() {

View File

@@ -9,9 +9,9 @@ import org.wpilib.command2.InstantCommand;
import org.wpilib.command2.PrintCommand;
import org.wpilib.command2.button.JoystickButton;
import org.wpilib.command2.button.Trigger;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.driverstation.GenericHID;
import org.wpilib.driverstation.Joystick;
import org.wpilib.driverstation.XboxController;
import org.wpilib.examples.xrpreference.commands.ArcadeDrive;
import org.wpilib.examples.xrpreference.commands.AutonomousDistance;
import org.wpilib.examples.xrpreference.commands.AutonomousTime;
@@ -48,7 +48,7 @@ public class RobotContainer {
/**
* Use this method to define your button->command mappings. Buttons can be created by
* instantiating a {@link GenericHID} or one of its subclasses ({@link
* org.wpilib.driverstation.Joystick} or {@link XboxController}), and then passing it to a {@link
* org.wpilib.driverstation.Joystick} or {@link Gamepad}), and then passing it to a {@link
* org.wpilib.command2.button.JoystickButton}.
*/
private void configureButtonBindings() {

View File

@@ -5,7 +5,7 @@
package org.wpilib.templates.commandv2;
import org.wpilib.command2.Command;
import org.wpilib.command2.button.CommandXboxController;
import org.wpilib.command2.button.CommandGamepad;
import org.wpilib.command2.button.Trigger;
import org.wpilib.templates.commandv2.Constants.OperatorConstants;
import org.wpilib.templates.commandv2.commands.Autos;
@@ -22,9 +22,8 @@ public class RobotContainer {
// The robot's subsystems and commands are defined here...
private final ExampleSubsystem m_exampleSubsystem = new ExampleSubsystem();
// Replace with CommandPS4Controller or CommandJoystick if needed
private final CommandXboxController m_driverController =
new CommandXboxController(OperatorConstants.kDriverControllerPort);
private final CommandGamepad m_driverController =
new CommandGamepad(OperatorConstants.kDriverControllerPort);
/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
@@ -36,8 +35,7 @@ public class RobotContainer {
* Use this method to define your trigger->command mappings. Triggers can be created via the
* {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary
* predicate, or via the named factories in {@link org.wpilib.command2.button.CommandGenericHID}'s
* subclasses for {@link CommandXboxController Xbox}/{@link
* org.wpilib.command2.button.CommandPS4Controller PS4} controllers or {@link
* subclasses for {@link CommandGamepad Gamepad} gamepads or {@link
* org.wpilib.command2.button.CommandJoystick Flight joysticks}.
*/
private void configureBindings() {
@@ -45,9 +43,9 @@ public class RobotContainer {
new Trigger(m_exampleSubsystem::exampleCondition)
.onTrue(new ExampleCommand(m_exampleSubsystem));
// Schedule `exampleMethodCommand` when the Xbox controller's B button is pressed,
// Schedule `exampleMethodCommand` when the Gamepad's east face button is pressed,
// cancelling on release.
m_driverController.b().whileTrue(m_exampleSubsystem.exampleMethodCommand());
m_driverController.eastFace().whileTrue(m_exampleSubsystem.exampleMethodCommand());
}
/**

View File

@@ -5,7 +5,7 @@
package org.wpilib.templates.romicommandv2;
import org.wpilib.command2.Command;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.templates.romicommandv2.commands.ExampleCommand;
import org.wpilib.templates.romicommandv2.subsystems.RomiDrivetrain;
@@ -30,7 +30,7 @@ public class RobotContainer {
/**
* Use this method to define your button->command mappings. Buttons can be created by
* instantiating a {@link org.wpilib.driverstation.GenericHID} or one of its subclasses ({@link
* org.wpilib.driverstation.Joystick} or {@link XboxController}), and then passing it to a {@link
* org.wpilib.driverstation.Joystick} or {@link Gamepad}), and then passing it to a {@link
* org.wpilib.command2.button.JoystickButton}.
*/
private void configureButtonBindings() {}

View File

@@ -5,7 +5,7 @@
package org.wpilib.templates.xrpcommandv2;
import org.wpilib.command2.Command;
import org.wpilib.driverstation.XboxController;
import org.wpilib.driverstation.Gamepad;
import org.wpilib.templates.xrpcommandv2.commands.ExampleCommand;
import org.wpilib.templates.xrpcommandv2.subsystems.XRPDrivetrain;
@@ -30,7 +30,7 @@ public class RobotContainer {
/**
* Use this method to define your button->command mappings. Buttons can be created by
* instantiating a {@link org.wpilib.driverstation.GenericHID} or one of its subclasses ({@link
* org.wpilib.driverstation.Joystick} or {@link XboxController}), and then passing it to a {@link
* org.wpilib.driverstation.Joystick} or {@link Gamepad}), and then passing it to a {@link
* org.wpilib.command2.button.JoystickButton}.
*/
private void configureButtonBindings() {}