Update RLIs to 2027.0.0-alpha-4#3272
Conversation
|
\inspector fix all |
|
\inspector fix all |
|
\inspector fix all |
|
\inspector fix all |
Inspector ReportUp To DateDetailsOutdated - Automatically FixedDetailsInvalid - Manual Intervention NeededDetails
- 40 void RobotPeriodic() override {
41 40 // update the dashboard mechanism's state
42 41 m_elevator->SetLength(kElevatorMinimumLength +
43 42 m_elevatorEncoder.GetDistance());
44 43 m_wrist->SetAngle(wpi::units::degree_t{m_wristPotentiometer.Get()});
45 44 }
+ 45
- 7 import org.wpilib.opmode.TimedRobot;
+ 7 import org.wpilib.framework.TimedRobot;
8 8
9 9 /**
10 10 * The methods in this class are called automatically corresponding to each mode, as described in
11 11 * the TimedRobot documentation. If you change the name of this class or the package after creating
12 12 * this project, you must also update the Main.java file in the project.
13 13 */
14 14 public class Robot extends TimedRobot {
15 15 /**
16 16 * This function is run when the robot is first started up and should be used for any
17 17 * initialization code.
18 18 */
19 19 public Robot() {}
20 20
21 21 @Override
22 22 public void robotPeriodic() {}
23 23
24 24 @Override
25 25 public void autonomousInit() {}
26 26
27 27 @Override
28 28 public void autonomousPeriodic() {}
29 29
30 30 @Override
31 31 public void teleopInit() {}
32 32
33 33 @Override
34 34 public void teleopPeriodic() {}
35 35
36 36 @Override
37 37 public void disabledInit() {}
38 38
39 39 @Override
40 40 public void disabledPeriodic() {}
41 41
42 42 @Override
43 43 public void testInit() {}
44 44
45 45 @Override
46 46 public void testPeriodic() {}
47 47
48 48 @Override
49 49 public void simulationInit() {}
50 50
51 51 @Override
52 52 public void simulationPeriodic() {}
53 53 }
- 42 void Elevator::ReachGoal(wpi::units::meter_t goal) {
43 42 m_controller.SetGoal(goal);
44 43 // With the setpoint value we run PID control like normal
45 44 double pidOutput =
46 45 m_controller.Calculate(wpi::units::meter_t{m_encoder.GetDistance()});
47 46 wpi::units::volt_t feedforwardOutput =
48 47 m_feedforward.Calculate(m_controller.GetSetpoint().velocity);
49 48 m_motor.SetVoltage(wpi::units::volt_t{pidOutput} + feedforwardOutput);
50 49 }
+ 50
7 7 import org.wpilib.examples.unittest.Constants.IntakeConstants;
8 8 import org.wpilib.hardware.motor.PWMSparkMax;
9 9 import org.wpilib.hardware.pneumatic.DoubleSolenoid;
10 10 import org.wpilib.hardware.pneumatic.PneumaticsModuleType;
11 11
12 12 public class Intake implements AutoCloseable {
13 13 private final PWMSparkMax m_motor;
14 14 private final DoubleSolenoid m_piston;
15 15
16 16 public Intake() {
17 17 m_motor = new PWMSparkMax(IntakeConstants.kMotorPort);
18 18 m_piston =
19 19 new DoubleSolenoid(
20 20 0,
21 21 PneumaticsModuleType.CTREPCM,
22 22 IntakeConstants.kPistonFwdChannel,
23 23 IntakeConstants.kPistonRevChannel);
24 24 }
25 25
26 26 public void deploy() {
27 27 m_piston.set(DoubleSolenoid.Value.kForward);
28 28 }
29 29
30 30 public void retract() {
31 31 m_piston.set(DoubleSolenoid.Value.kReverse);
- 32 m_motor.set(0); // turn off the motor
+ 32 m_motor.setDutyCycle(0); // turn off the motor
33 33 }
34 34
- 35 public void activate(double speed) {
+ 35 public void activate(double velocity) {
36 36 if (isDeployed()) {
- 37 m_motor.set(speed);
+ 37 m_motor.setDutyCycle(velocity);
38 38 } else { // if piston isn't open, do nothing
- 39 m_motor.set(0);
+ 39 m_motor.setDutyCycle(0);
40 40 }
41 41 }
42 42
43 43 public boolean isDeployed() {
44 44 return m_piston.get() == DoubleSolenoid.Value.kForward;
45 45 }
46 46
47 47 @Override
48 48 public void close() {
49 49 m_piston.close();
50 50 m_motor.close();
51 51 }
52 52 }
53 53
- 7 #include <wpi/hardware/motor/PWMSparkMax.hpp>
- 8 #include <wpi/hardware/pneumatic/DoubleSolenoid.hpp>
- 9
10 7 #include "Constants.hpp"
+ 8 #include "wpi/hardware/motor/PWMSparkMax.hpp"
+ 9 #include "wpi/hardware/pneumatic/DoubleSolenoid.hpp"
11 10
12 11 class Intake {
13 12 public:
14 13 void Deploy();
15 14 void Retract();
- 16 void Activate(double speed);
+ 15 void Activate(double velocity);
17 16 bool IsDeployed() const;
18 17
19 18 private:
20 19 wpi::PWMSparkMax m_motor{IntakeConstants::kMotorPort};
21 20 wpi::DoubleSolenoid m_piston{0, wpi::PneumaticsModuleType::CTREPCM,
22 21 IntakeConstants::kPistonFwdChannel,
23 22 IntakeConstants::kPistonRevChannel};
24 23 };
25 24
5 5 #include "subsystems/Intake.hpp"
6 6
7 7 void Intake::Deploy() {
8 8 m_piston.Set(wpi::DoubleSolenoid::Value::kForward);
9 9 }
10 10
11 11 void Intake::Retract() {
12 12 m_piston.Set(wpi::DoubleSolenoid::Value::kReverse);
- 13 m_motor.Set(0); // turn off the motor
+ 13 m_motor.SetDutyCycle(0); // turn off the motor
14 14 }
15 15
- 16 void Intake::Activate(double speed) {
+ 16 void Intake::Activate(double velocity) {
17 17 if (IsDeployed()) {
- 18 m_motor.Set(speed);
+ 18 m_motor.SetDutyCycle(velocity);
19 19 } else { // if piston isn't open, do nothing
- 20 m_motor.Set(0);
+ 20 m_motor.SetDutyCycle(0);
21 21 }
22 22 }
23 23
24 24 bool Intake::IsDeployed() const {
25 25 return m_piston.Get() == wpi::DoubleSolenoid::Value::kForward;
26 26 }
27 27
7 7 import static org.junit.jupiter.api.Assertions.assertEquals;
8 8
9 9 import org.junit.jupiter.api.AfterEach;
10 10 import org.junit.jupiter.api.BeforeEach;
11 11 import org.junit.jupiter.api.Test;
12 12 import org.wpilib.examples.unittest.Constants.IntakeConstants;
13 13 import org.wpilib.hardware.hal.HAL;
14 14 import org.wpilib.hardware.pneumatic.DoubleSolenoid;
15 15 import org.wpilib.hardware.pneumatic.PneumaticsModuleType;
16 16 import org.wpilib.simulation.DoubleSolenoidSim;
17 17 import org.wpilib.simulation.PWMMotorControllerSim;
18 18
19 19 class IntakeTest {
20 20 static final double DELTA = 1e-2; // acceptable deviation range
21 21 Intake m_intake;
22 22 PWMMotorControllerSim m_simMotor;
23 23 DoubleSolenoidSim m_simPiston;
24 24
25 25 @BeforeEach // this method will run before each test
26 26 void setup() {
27 27 assert HAL.initialize(500, 0); // initialize the HAL, crash if failed
28 28 m_intake = new Intake(); // create our intake
29 29 m_simMotor =
30 30 new PWMMotorControllerSim(
31 31 IntakeConstants.kMotorPort); // create our simulation PWM motor controller
32 32 m_simPiston =
33 33 new DoubleSolenoidSim(
34 34 PneumaticsModuleType.CTREPCM,
35 35 IntakeConstants.kPistonFwdChannel,
36 36 IntakeConstants.kPistonRevChannel); // create our simulation solenoid
37 37 }
38 38
39 39 @SuppressWarnings("PMD.SignatureDeclareThrowsException")
40 40 @AfterEach // this method will run after each test
41 41 void shutdown() throws Exception {
42 42 m_intake.close(); // destroy our intake object
43 43 }
44 44
45 45 @Test // marks this method as a test
46 46 void doesntWorkWhenClosed() {
47 47 m_intake.retract(); // close the intake
48 48 m_intake.activate(0.5); // try to activate the motor
49 49 assertEquals(
- 50 0.0, m_simMotor.getSpeed(), DELTA); // make sure that the value set to the motor is 0
+ 50 0.0, m_simMotor.getDutyCycle(), DELTA); // make sure that the value set to the motor is 0
51 51 }
52 52
53 53 @Test
54 54 void worksWhenOpen() {
55 55 m_intake.deploy();
56 56 m_intake.activate(0.5);
- 57 assertEquals(0.5, m_simMotor.getSpeed(), DELTA);
+ 57 assertEquals(0.5, m_simMotor.getDutyCycle(), DELTA);
58 58 }
59 59
60 60 @Test
61 61 void retractTest() {
62 62 m_intake.retract();
63 63 assertEquals(DoubleSolenoid.Value.kReverse, m_simPiston.get());
64 64 }
65 65
66 66 @Test
67 67 void deployTest() {
68 68 m_intake.deploy();
69 69 assertEquals(DoubleSolenoid.Value.kForward, m_simPiston.get());
70 70 }
71 71 }
72 72
+ 5 #include "subsystems/Intake.hpp"
+ 6
5 7 #include <gtest/gtest.h>
- 6 #include <wpi/hardware/pneumatic/DoubleSolenoid.hpp>
- 7 #include <wpi/simulation/DoubleSolenoidSim.hpp>
- 8 #include <wpi/simulation/PWMMotorControllerSim.hpp>
9 8
10 9 #include "Constants.hpp"
- 11 #include "subsystems/Intake.hpp"
+ 10 #include "wpi/hardware/pneumatic/DoubleSolenoid.hpp"
+ 11 #include "wpi/simulation/DoubleSolenoidSim.hpp"
+ 12 #include "wpi/simulation/PWMMotorControllerSim.hpp"
12 13
13 14 class IntakeTest : public testing::Test {
14 15 protected:
15 16 Intake intake; // create our intake
16 17 wpi::sim::PWMMotorControllerSim simMotor{
17 18 IntakeConstants::kMotorPort}; // create our simulation PWM
18 19 wpi::sim::DoubleSolenoidSim simPiston{
19 20 wpi::PneumaticsModuleType::CTREPCM, IntakeConstants::kPistonFwdChannel,
20 21 IntakeConstants::kPistonRevChannel}; // create our simulation solenoid
21 22 };
22 23
23 24 TEST_F(IntakeTest, DoesntWorkWhenClosed) {
24 25 intake.Retract(); // close the intake
25 26 intake.Activate(0.5); // try to activate the motor
26 27 EXPECT_DOUBLE_EQ(
27 28 0.0,
- 28 simMotor.GetSpeed()); // make sure that the value set to the motor is 0
+ 29 simMotor
+ 30 .GetDutyCycle()); // make sure that the value set to the motor is 0
29 31 }
30 32
31 33 TEST_F(IntakeTest, WorksWhenOpen) {
32 34 intake.Deploy();
33 35 intake.Activate(0.5);
- 34 EXPECT_DOUBLE_EQ(0.5, simMotor.GetSpeed());
+ 36 EXPECT_DOUBLE_EQ(0.5, simMotor.GetDutyCycle());
35 37 }
36 38
37 39 TEST_F(IntakeTest, Retract) {
38 40 intake.Retract();
39 41 EXPECT_EQ(wpi::DoubleSolenoid::Value::kReverse, simPiston.Get());
40 42 }
41 43
42 44 TEST_F(IntakeTest, Deploy) {
43 45 intake.Deploy();
44 46 EXPECT_EQ(wpi::DoubleSolenoid::Value::kForward, simPiston.Get());
45 47 }
46 48
25 25 void AutonomousInit() override { m_timer.Restart(); }
26 26
27 27 void AutonomousPeriodic() override {
28 28 // Drive for 2 seconds
29 29 if (m_timer.Get() < 2_s) {
- 30 // Drive forwards half speed, make sure to turn input squaring off
+ 30 // Drive forwards half velocity, make sure to turn input squaring off
31 31 m_robotDrive.ArcadeDrive(0.5, 0.0, false);
32 32 } else {
33 33 // Stop robot
34 34 m_robotDrive.ArcadeDrive(0.0, 0.0, false);
35 35 }
36 36 } |
|
\inspector fix all |
|
\inspector check all |
No description provided.