mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Update and enable PMD 6.3.0 (#1107)
This commit is contained in:
committed by
Peter Johnson
parent
8eafe7f325
commit
e548a5f705
@@ -38,6 +38,7 @@ public class ReplaceMeCommand extends Command {
|
||||
|
||||
// Called when another command which requires one or more of the same
|
||||
// subsystems is scheduled to run
|
||||
@Override
|
||||
protected void interrupted() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import edu.wpi.first.wpilibj.examples.gearsbot.commands.SetWristSetpoint;
|
||||
* interface to the commands and command groups that allow control of the robot.
|
||||
*/
|
||||
public class OI {
|
||||
private Joystick m_joystick = new Joystick(0);
|
||||
private final Joystick m_joystick = new Joystick(0);
|
||||
|
||||
/**
|
||||
* Construct the OI and all of the buttons on it.
|
||||
|
||||
@@ -21,7 +21,7 @@ import edu.wpi.first.wpilibj.examples.gearsbot.Robot;
|
||||
* encoders.
|
||||
*/
|
||||
public class DriveStraight extends Command {
|
||||
private PIDController m_pid;
|
||||
private final PIDController m_pid;
|
||||
|
||||
/**
|
||||
* Create a new DriveStraight command.
|
||||
|
||||
@@ -21,7 +21,7 @@ import edu.wpi.first.wpilibj.examples.gearsbot.Robot;
|
||||
* encoders.
|
||||
*/
|
||||
public class SetDistanceToBox extends Command {
|
||||
private PIDController m_pid;
|
||||
private final PIDController m_pid;
|
||||
|
||||
/**
|
||||
* Create a new set distance to box command.
|
||||
|
||||
@@ -18,7 +18,7 @@ import edu.wpi.first.wpilibj.examples.gearsbot.Robot;
|
||||
* PID!
|
||||
*/
|
||||
public class SetElevatorSetpoint extends Command {
|
||||
private double m_setpoint;
|
||||
private final double m_setpoint;
|
||||
|
||||
public SetElevatorSetpoint(double setpoint) {
|
||||
m_setpoint = setpoint;
|
||||
|
||||
@@ -17,7 +17,7 @@ import edu.wpi.first.wpilibj.examples.gearsbot.Robot;
|
||||
* commands using the wrist should make sure they disable PID!
|
||||
*/
|
||||
public class SetWristSetpoint extends Command {
|
||||
private double m_setpoint;
|
||||
private final double m_setpoint;
|
||||
|
||||
public SetWristSetpoint(double setpoint) {
|
||||
m_setpoint = setpoint;
|
||||
|
||||
@@ -17,8 +17,8 @@ import edu.wpi.first.wpilibj.command.Subsystem;
|
||||
* don't stall.
|
||||
*/
|
||||
public class Claw extends Subsystem {
|
||||
private Victor m_motor = new Victor(7);
|
||||
private DigitalInput m_contact = new DigitalInput(5);
|
||||
private final Victor m_motor = new Victor(7);
|
||||
private final DigitalInput m_contact = new DigitalInput(5);
|
||||
|
||||
/**
|
||||
* Create a new claw subsystem.
|
||||
@@ -48,6 +48,7 @@ public class Claw extends Subsystem {
|
||||
/**
|
||||
* Set the claw motor to move in the close direction.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
m_motor.set(1);
|
||||
}
|
||||
|
||||
@@ -27,18 +27,18 @@ import edu.wpi.first.wpilibj.examples.gearsbot.commands.TankDriveWithJoystick;
|
||||
* and a gyro.
|
||||
*/
|
||||
public class DriveTrain extends Subsystem {
|
||||
private SpeedController m_leftMotor
|
||||
private final SpeedController m_leftMotor
|
||||
= new SpeedControllerGroup(new Spark(0), new Spark(1));
|
||||
private SpeedController m_rightMotor
|
||||
private final SpeedController m_rightMotor
|
||||
= new SpeedControllerGroup(new Spark(2), new Spark(3));
|
||||
|
||||
private DifferentialDrive m_drive
|
||||
private final DifferentialDrive m_drive
|
||||
= new DifferentialDrive(m_leftMotor, m_rightMotor);
|
||||
|
||||
private Encoder m_leftEncoder = new Encoder(1, 2);
|
||||
private Encoder m_rightEncoder = new Encoder(3, 4);
|
||||
private AnalogInput m_rangefinder = new AnalogInput(6);
|
||||
private AnalogGyro m_gyro = new AnalogGyro(1);
|
||||
private final Encoder m_leftEncoder = new Encoder(1, 2);
|
||||
private final Encoder m_rightEncoder = new Encoder(3, 4);
|
||||
private final AnalogInput m_rangefinder = new AnalogInput(6);
|
||||
private final AnalogGyro m_gyro = new AnalogGyro(1);
|
||||
|
||||
/**
|
||||
* Create a new drive train subsystem.
|
||||
|
||||
@@ -20,8 +20,8 @@ import edu.wpi.first.wpilibj.examples.gearsbot.Robot;
|
||||
* world do to minor differences.
|
||||
*/
|
||||
public class Elevator extends PIDSubsystem {
|
||||
private Victor m_motor;
|
||||
private AnalogPotentiometer m_pot;
|
||||
private final Victor m_motor;
|
||||
private final AnalogPotentiometer m_pot;
|
||||
|
||||
private static final double kP_real = 4;
|
||||
private static final double kI_real = 0.07;
|
||||
|
||||
@@ -19,8 +19,8 @@ import edu.wpi.first.wpilibj.examples.gearsbot.Robot;
|
||||
* of a linear joint.
|
||||
*/
|
||||
public class Wrist extends PIDSubsystem {
|
||||
private Victor m_motor;
|
||||
private AnalogPotentiometer m_pot;
|
||||
private final Victor m_motor;
|
||||
private final AnalogPotentiometer m_pot;
|
||||
|
||||
private static final double kP_real = 1;
|
||||
private static final double kP_simulation = 0.05;
|
||||
|
||||
@@ -21,10 +21,10 @@ import edu.wpi.first.wpilibj.drive.DifferentialDrive;
|
||||
* directory.
|
||||
*/
|
||||
public class Robot extends IterativeRobot {
|
||||
private DifferentialDrive m_robotDrive
|
||||
private final DifferentialDrive m_robotDrive
|
||||
= new DifferentialDrive(new Spark(0), new Spark(1));
|
||||
private Joystick m_stick = new Joystick(0);
|
||||
private Timer m_timer = new Timer();
|
||||
private final Joystick m_stick = new Joystick(0);
|
||||
private final Timer m_timer = new Timer();
|
||||
|
||||
/**
|
||||
* This function is run when the robot is first started up and should be
|
||||
|
||||
@@ -31,11 +31,11 @@ public class Robot extends IterativeRobot {
|
||||
private static final int kGyroPort = 0;
|
||||
private static final int kJoystickPort = 0;
|
||||
|
||||
private DifferentialDrive m_myRobot
|
||||
private final DifferentialDrive m_myRobot
|
||||
= new DifferentialDrive(new Spark(kLeftMotorPort),
|
||||
new Spark(kRightMotorPort));
|
||||
private AnalogGyro m_gyro = new AnalogGyro(kGyroPort);
|
||||
private Joystick m_joystick = new Joystick(kJoystickPort);
|
||||
private final AnalogGyro m_gyro = new AnalogGyro(kGyroPort);
|
||||
private final Joystick m_joystick = new Joystick(kJoystickPort);
|
||||
|
||||
@Override
|
||||
public void robotInit() {
|
||||
|
||||
@@ -31,8 +31,8 @@ public class Robot extends IterativeRobot {
|
||||
private static final int kJoystickPort = 0;
|
||||
|
||||
private MecanumDrive m_robotDrive;
|
||||
private AnalogGyro m_gyro = new AnalogGyro(kGyroPort);
|
||||
private Joystick m_joystick = new Joystick(kJoystickPort);
|
||||
private final AnalogGyro m_gyro = new AnalogGyro(kGyroPort);
|
||||
private final Joystick m_joystick = new Joystick(kJoystickPort);
|
||||
|
||||
@Override
|
||||
public void robotInit() {
|
||||
|
||||
@@ -16,8 +16,8 @@ import edu.wpi.first.wpilibj.examples.pacgoat.Robot;
|
||||
* control This command will drive a given distance limiting to a maximum speed.
|
||||
*/
|
||||
public class DriveForward extends Command {
|
||||
private double m_driveForwardSpeed;
|
||||
private double m_distance;
|
||||
private final double m_driveForwardSpeed;
|
||||
private final double m_distance;
|
||||
private double m_error;
|
||||
private static final double kTolerance = 0.1;
|
||||
private static final double kP = -1.0 / 5.0;
|
||||
|
||||
@@ -17,7 +17,7 @@ import edu.wpi.first.wpilibj.examples.pacgoat.Robot;
|
||||
* the spinners may still be adjusting their speed.
|
||||
*/
|
||||
public class SetCollectionSpeed extends InstantCommand {
|
||||
private double m_speed;
|
||||
private final double m_speed;
|
||||
|
||||
public SetCollectionSpeed(double speed) {
|
||||
requires(Robot.collector);
|
||||
|
||||
@@ -17,7 +17,7 @@ import edu.wpi.first.wpilibj.examples.pacgoat.Robot;
|
||||
* commands using the pivot should make sure they disable PID!
|
||||
*/
|
||||
public class SetPivotSetpoint extends Command {
|
||||
private double m_setpoint;
|
||||
private final double m_setpoint;
|
||||
|
||||
public SetPivotSetpoint(double setpoint) {
|
||||
this.m_setpoint = setpoint;
|
||||
|
||||
@@ -25,10 +25,10 @@ public class Collector extends Subsystem {
|
||||
public static final double kReverse = -1;
|
||||
|
||||
// Subsystem devices
|
||||
private SpeedController m_rollerMotor = new Victor(6);
|
||||
private DigitalInput m_ballDetector = new DigitalInput(10);
|
||||
private DigitalInput m_openDetector = new DigitalInput(6);
|
||||
private Solenoid m_piston = new Solenoid(1, 1);
|
||||
private final SpeedController m_rollerMotor = new Victor(6);
|
||||
private final DigitalInput m_ballDetector = new DigitalInput(10);
|
||||
private final DigitalInput m_openDetector = new DigitalInput(6);
|
||||
private final Solenoid m_piston = new Solenoid(1, 1);
|
||||
|
||||
/**
|
||||
* Create a new collector subsystem.
|
||||
@@ -89,6 +89,7 @@ public class Collector extends Subsystem {
|
||||
/**
|
||||
* Close the claw (For collecting and driving).
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
m_piston.set(false);
|
||||
}
|
||||
|
||||
@@ -27,18 +27,18 @@ import edu.wpi.first.wpilibj.examples.pacgoat.commands.DriveWithJoystick;
|
||||
*/
|
||||
public class DriveTrain extends Subsystem {
|
||||
// Subsystem devices
|
||||
private SpeedController m_frontLeftCIM = new Victor(1);
|
||||
private SpeedController m_frontRightCIM = new Victor(2);
|
||||
private SpeedController m_rearLeftCIM = new Victor(3);
|
||||
private SpeedController m_rearRightCIM = new Victor(4);
|
||||
private SpeedControllerGroup m_leftCIMs = new SpeedControllerGroup(
|
||||
private final SpeedController m_frontLeftCIM = new Victor(1);
|
||||
private final SpeedController m_frontRightCIM = new Victor(2);
|
||||
private final SpeedController m_rearLeftCIM = new Victor(3);
|
||||
private final SpeedController m_rearRightCIM = new Victor(4);
|
||||
private final SpeedControllerGroup m_leftCIMs = new SpeedControllerGroup(
|
||||
m_frontLeftCIM, m_rearLeftCIM);
|
||||
private SpeedControllerGroup m_rightCIMs = new SpeedControllerGroup(
|
||||
private final SpeedControllerGroup m_rightCIMs = new SpeedControllerGroup(
|
||||
m_frontRightCIM, m_rearRightCIM);
|
||||
private DifferentialDrive m_drive;
|
||||
private Encoder m_rightEncoder = new Encoder(1, 2, true, EncodingType.k4X);
|
||||
private Encoder m_leftEncoder = new Encoder(3, 4, false, EncodingType.k4X);
|
||||
private AnalogGyro m_gyro = new AnalogGyro(2);
|
||||
private final DifferentialDrive m_drive;
|
||||
private final Encoder m_rightEncoder = new Encoder(1, 2, true, EncodingType.k4X);
|
||||
private final Encoder m_leftEncoder = new Encoder(3, 4, false, EncodingType.k4X);
|
||||
private final AnalogGyro m_gyro = new AnalogGyro(2);
|
||||
|
||||
/**
|
||||
* Create a new drive train subsystem.
|
||||
|
||||
@@ -28,15 +28,15 @@ public class Pivot extends PIDSubsystem {
|
||||
public static final double kShootNear = 30;
|
||||
|
||||
// Sensors for measuring the position of the pivot.
|
||||
private DigitalInput m_upperLimitSwitch = new DigitalInput(13);
|
||||
private DigitalInput m_lowerLimitSwitch = new DigitalInput(12);
|
||||
private final DigitalInput m_upperLimitSwitch = new DigitalInput(13);
|
||||
private final DigitalInput m_lowerLimitSwitch = new DigitalInput(12);
|
||||
|
||||
// 0 degrees is vertical facing up.
|
||||
// Angle increases the more forward the pivot goes.
|
||||
private Potentiometer m_pot = new AnalogPotentiometer(1);
|
||||
private final Potentiometer m_pot = new AnalogPotentiometer(1);
|
||||
|
||||
// Motor to move the pivot.
|
||||
private SpeedController m_motor = new Victor(5);
|
||||
private final SpeedController m_motor = new Victor(5);
|
||||
|
||||
/**
|
||||
* Create a new pivot subsystem.
|
||||
|
||||
@@ -22,6 +22,7 @@ import edu.wpi.first.wpilibj.command.Subsystem;
|
||||
* <p>NOTE: Simulation currently approximates this as as single pneumatic
|
||||
* cylinder and ignores the latch.
|
||||
*/
|
||||
@SuppressWarnings("PMD.TooManyMethods")
|
||||
public class Shooter extends Subsystem {
|
||||
// Devices
|
||||
DoubleSolenoid m_piston1 = new DoubleSolenoid(1, 3, 4);
|
||||
|
||||
@@ -15,9 +15,9 @@ import edu.wpi.first.wpilibj.buttons.Trigger;
|
||||
* simultaneously pressed.
|
||||
*/
|
||||
public class DoubleButton extends Trigger {
|
||||
private Joystick m_joy;
|
||||
private int m_button1;
|
||||
private int m_button2;
|
||||
private final Joystick m_joy;
|
||||
private final int m_button1;
|
||||
private final int m_button2;
|
||||
|
||||
/**
|
||||
* Create a new double button trigger.
|
||||
|
||||
@@ -36,12 +36,14 @@ public class Robot extends IterativeRobot {
|
||||
private static final double kD = -2.0;
|
||||
|
||||
private PIDController m_pidController;
|
||||
@SuppressWarnings("PMD.SingularField")
|
||||
private AnalogInput m_potentiometer;
|
||||
@SuppressWarnings("PMD.SingularField")
|
||||
private SpeedController m_elevatorMotor;
|
||||
private Joystick m_joystick;
|
||||
|
||||
private int m_index = 0;
|
||||
private boolean m_previousButtonValue = false;
|
||||
private int m_index;
|
||||
private boolean m_previousButtonValue;
|
||||
|
||||
@Override
|
||||
public void robotInit() {
|
||||
@@ -49,8 +51,7 @@ public class Robot extends IterativeRobot {
|
||||
m_elevatorMotor = new Spark(kMotorChannel);
|
||||
m_joystick = new Joystick(kJoystickChannel);
|
||||
|
||||
m_pidController
|
||||
= new PIDController(kP, kI, kD, m_potentiometer, m_elevatorMotor);
|
||||
m_pidController = new PIDController(kP, kI, kD, m_potentiometer, m_elevatorMotor);
|
||||
m_pidController.setInputRange(0, 5);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ public class Robot extends IterativeRobot {
|
||||
private static final int kRightMotorPort = 1;
|
||||
private static final int kUltrasonicPort = 0;
|
||||
|
||||
private AnalogInput m_ultrasonic = new AnalogInput(kUltrasonicPort);
|
||||
private DifferentialDrive m_robotDrive
|
||||
private final AnalogInput m_ultrasonic = new AnalogInput(kUltrasonicPort);
|
||||
private final DifferentialDrive m_robotDrive
|
||||
= new DifferentialDrive(new Spark(kLeftMotorPort),
|
||||
new Spark(kRightMotorPort));
|
||||
|
||||
@@ -40,6 +40,7 @@ public class Robot extends IterativeRobot {
|
||||
* Tells the robot to drive to a set distance (in inches) from an object
|
||||
* using proportional control.
|
||||
*/
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
// sensor returns a value from 0-4095 that is scaled to inches
|
||||
double currentDistance = m_ultrasonic.getValue() * kValueToInches;
|
||||
|
||||
@@ -41,11 +41,11 @@ public class Robot extends IterativeRobot {
|
||||
private static final int kRightMotorPort = 1;
|
||||
private static final int kUltrasonicPort = 0;
|
||||
|
||||
private AnalogInput m_ultrasonic = new AnalogInput(kUltrasonicPort);
|
||||
private DifferentialDrive m_robotDrive
|
||||
private final AnalogInput m_ultrasonic = new AnalogInput(kUltrasonicPort);
|
||||
private final DifferentialDrive m_robotDrive
|
||||
= new DifferentialDrive(new Spark(kLeftMotorPort),
|
||||
new Spark(kRightMotorPort));
|
||||
private PIDController m_pidController
|
||||
private final PIDController m_pidController
|
||||
= new PIDController(kP, kI, kD, m_ultrasonic, new MyPidOutput());
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ public class ExampleSubsystem extends Subsystem {
|
||||
// Put methods for controlling this subsystem
|
||||
// here. Call these from Commands.
|
||||
|
||||
@Override
|
||||
public void initDefaultCommand() {
|
||||
// Set the default command for a subsystem here.
|
||||
// setDefaultCommand(new MySpecialCommand());
|
||||
|
||||
@@ -22,7 +22,7 @@ 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 final SendableChooser<String> m_chooser = new SendableChooser<>();
|
||||
|
||||
/**
|
||||
* This function is run when the robot is first started up and should be
|
||||
|
||||
@@ -36,10 +36,10 @@ public class Robot extends SampleRobot {
|
||||
private static final String kDefaultAuto = "Default";
|
||||
private static final String kCustomAuto = "My Auto";
|
||||
|
||||
private DifferentialDrive m_robotDrive
|
||||
private final 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 final Joystick m_stick = new Joystick(0);
|
||||
private final SendableChooser<String> m_chooser = new SendableChooser<>();
|
||||
|
||||
public Robot() {
|
||||
m_robotDrive.setExpiration(0.1);
|
||||
|
||||
@@ -22,7 +22,7 @@ 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 final SendableChooser<String> m_chooser = new SendableChooser<>();
|
||||
|
||||
/**
|
||||
* This function is run when the robot is first started up and should be
|
||||
|
||||
Reference in New Issue
Block a user