From 40329c5d2fb28ef513231693b502248b88a47ede Mon Sep 17 00:00:00 2001 From: Junyu Zhu <120147135+junyu101@users.noreply.github.com> Date: Sat, 18 Jan 2025 11:49:17 -0800 Subject: [PATCH 1/7] Basic Elevator Skeleton Setup Done --- .../elevator/ElevatorSubsystem.java | 66 +++++++++++++++++++ .../commands/ElevatorMaintainerCommand.java | 35 ++++++++++ .../commands/LowerElevatorCommand.java | 29 ++++++++ .../commands/RiseElevatorCommand.java | 27 ++++++++ 4 files changed, 157 insertions(+) create mode 100644 src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java create mode 100644 src/main/java/competition/subsystems/elevator/commands/ElevatorMaintainerCommand.java create mode 100644 src/main/java/competition/subsystems/elevator/commands/LowerElevatorCommand.java create mode 100644 src/main/java/competition/subsystems/elevator/commands/RiseElevatorCommand.java diff --git a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java new file mode 100644 index 0000000..cce72a4 --- /dev/null +++ b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java @@ -0,0 +1,66 @@ +package competition.subsystems.elevator; + +import competition.electrical_contract.Contract2025; +import xbot.common.command.BaseSetpointSubsystem; +import xbot.common.command.BaseSubsystem; +import xbot.common.controls.actuators.XCANTalon; +import xbot.common.injection.electrical_contract.CANTalonInfo; +import xbot.common.properties.DoubleProperty; +import xbot.common.properties.PropertyFactory; + +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton +public class ElevatorSubsystem extends BaseSubsystem { + + public enum ElevatorGoal{ + //common TargetHeights + } + double defaultElevatorPower; + final DoubleProperty elevatorPower; + + //assuming we'll have a master and follower motors + public XCANTalon master; + public XCANTalon follower; + + + @Inject + public ElevatorSubsystem(XCANTalon.XCANTalonFactory talonFactory, PropertyFactory pf, Contract2025 contract){ + + defaultElevatorPower = 0.5; + elevatorPower = pf.createPersistentProperty("Standard Power", 0.5); + + + } + + public Object getCurrentValue() { + return null; + } + + + public Object getTargetValue() { + return null; + } + + public void setTargetValue(Object value) { + + } + + public void setPower(double power) { + elevatorPower.set(power); + } + + public void rise(){ + setPower(elevatorPower.get()); + } + + public void lower(){ + setPower(-elevatorPower.get()); + } + + public boolean isCalibrated() { + return false; + } + +} diff --git a/src/main/java/competition/subsystems/elevator/commands/ElevatorMaintainerCommand.java b/src/main/java/competition/subsystems/elevator/commands/ElevatorMaintainerCommand.java new file mode 100644 index 0000000..3972e03 --- /dev/null +++ b/src/main/java/competition/subsystems/elevator/commands/ElevatorMaintainerCommand.java @@ -0,0 +1,35 @@ +package competition.subsystems.elevator.commands; + +import competition.subsystems.elevator.ElevatorSubsystem; +import xbot.common.command.BaseCommand; +import xbot.common.command.BaseSubsystem; +import xbot.common.properties.PropertyFactory; + +import javax.inject.Inject; + +public class ElevatorMaintainerCommand extends BaseCommand { + + public enum MaintainerMode{ + Calibrating, + GaveUp, + Calibrated, + } + + ElevatorSubsystem elevator; + + @Inject + public ElevatorMaintainerCommand(ElevatorSubsystem elevator, PropertyFactory pf){ + + } + + @Override + public void initialize() { + log.info("initializing"); + } + + @Override + public void execute(){ + + } + +} diff --git a/src/main/java/competition/subsystems/elevator/commands/LowerElevatorCommand.java b/src/main/java/competition/subsystems/elevator/commands/LowerElevatorCommand.java new file mode 100644 index 0000000..1a76f69 --- /dev/null +++ b/src/main/java/competition/subsystems/elevator/commands/LowerElevatorCommand.java @@ -0,0 +1,29 @@ +package competition.subsystems.elevator.commands; + +import competition.subsystems.elevator.ElevatorSubsystem; +import xbot.common.command.BaseCommand; + +import javax.inject.Inject; + +public class LowerElevatorCommand extends BaseCommand { + + ElevatorSubsystem elevator; + + @Inject + public LowerElevatorCommand(ElevatorSubsystem elevator){ + this.elevator = elevator; + addRequirements(elevator); + } + + @Override + public void initialize() { + log.info("initializing"); + } + + @Override + public void execute(){ + elevator.lower(); + } +} + + diff --git a/src/main/java/competition/subsystems/elevator/commands/RiseElevatorCommand.java b/src/main/java/competition/subsystems/elevator/commands/RiseElevatorCommand.java new file mode 100644 index 0000000..3976305 --- /dev/null +++ b/src/main/java/competition/subsystems/elevator/commands/RiseElevatorCommand.java @@ -0,0 +1,27 @@ +package competition.subsystems.elevator.commands; + +import competition.subsystems.elevator.ElevatorSubsystem; +import xbot.common.command.BaseCommand; + +import javax.inject.Inject; + +public class RiseElevatorCommand extends BaseCommand { + + ElevatorSubsystem elevator; + + @Inject + public RiseElevatorCommand(ElevatorSubsystem elevator){ + this.elevator = elevator; + addRequirements(elevator); + } + + @Override + public void initialize() { + log.info("initializing"); + } + + @Override + public void execute(){ + elevator.rise(); + } +} From e2db5f45f5dd82a99142547f7de7e90541cf351e Mon Sep 17 00:00:00 2001 From: Junyu Zhu <120147135+junyu101@users.noreply.github.com> Date: Sat, 18 Jan 2025 13:36:43 -0800 Subject: [PATCH 2/7] Basic Elevator Skeleton Setup --- .../electrical_contract/Contract2025.java | 18 ++++++++ .../ElectricalContract.java | 6 +++ .../elevator/ElevatorSubsystem.java | 45 ++++++++++++------- .../commands/ElevatorMaintainerCommand.java | 2 +- .../SetElevatorTargetHeightCommand.java | 33 ++++++++++++++ .../commands/StopElevatorCommand.java | 29 ++++++++++++ 6 files changed, 116 insertions(+), 17 deletions(-) create mode 100644 src/main/java/competition/subsystems/elevator/commands/SetElevatorTargetHeightCommand.java create mode 100644 src/main/java/competition/subsystems/elevator/commands/StopElevatorCommand.java diff --git a/src/main/java/competition/electrical_contract/Contract2025.java b/src/main/java/competition/electrical_contract/Contract2025.java index 3ec0042..e79d639 100644 --- a/src/main/java/competition/electrical_contract/Contract2025.java +++ b/src/main/java/competition/electrical_contract/Contract2025.java @@ -9,6 +9,7 @@ import edu.wpi.first.math.geometry.Rotation3d; import competition.subsystems.pose.PoseSubsystem; +import xbot.common.controls.actuators.XCANTalon; import xbot.common.injection.electrical_contract.CANBusId; import xbot.common.injection.electrical_contract.CANMotorControllerInfo; import xbot.common.injection.electrical_contract.CANMotorControllerOutputConfig; @@ -36,6 +37,23 @@ public boolean areCanCodersReady() { return true; } + @Override + public boolean isElevatorReady() { + return false; + } + + @Override + public CANMotorControllerInfo getElevatorMaster() { + return new CANMotorControllerInfo( + "Master Motor", MotorControllerType.TalonFx, new CANBusId("99"), 99, new CANMotorControllerOutputConfig()); + } + + @Override + public CANMotorControllerInfo getElevatorFollower() { + return new CANMotorControllerInfo( + "Follower Motor", MotorControllerType.TalonFx, new CANBusId("98"), 98, new CANMotorControllerOutputConfig()); + } + protected String getDriveControllerName(SwerveInstance swerveInstance) { return "DriveSubsystem/" + swerveInstance.label() + "/Drive"; } diff --git a/src/main/java/competition/electrical_contract/ElectricalContract.java b/src/main/java/competition/electrical_contract/ElectricalContract.java index 645f211..8cc598f 100644 --- a/src/main/java/competition/electrical_contract/ElectricalContract.java +++ b/src/main/java/competition/electrical_contract/ElectricalContract.java @@ -20,4 +20,10 @@ public abstract class ElectricalContract implements XSwerveDriveElectricalContra public abstract DeviceInfo getSteeringEncoder(SwerveInstance swerveInstance); public abstract XYPair getSwerveModuleOffsetsInInches(SwerveInstance swerveInstance); + + public abstract boolean isElevatorReady(); + + public abstract CANMotorControllerInfo getElevatorMaster(); + + public abstract CANMotorControllerInfo getElevatorFollower(); } diff --git a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java index cce72a4..ac00905 100644 --- a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java +++ b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java @@ -1,8 +1,10 @@ package competition.subsystems.elevator; import competition.electrical_contract.Contract2025; +import competition.electrical_contract.ElectricalContract; import xbot.common.command.BaseSetpointSubsystem; import xbot.common.command.BaseSubsystem; +import xbot.common.controls.actuators.XCANMotorController; import xbot.common.controls.actuators.XCANTalon; import xbot.common.injection.electrical_contract.CANTalonInfo; import xbot.common.properties.DoubleProperty; @@ -19,36 +21,43 @@ public enum ElevatorGoal{ } double defaultElevatorPower; final DoubleProperty elevatorPower; + final ElectricalContract contract; + + private boolean isCalibrated; + + final DoubleProperty elevatorTargetHeight; //assuming we'll have a master and follower motors - public XCANTalon master; - public XCANTalon follower; + public XCANMotorController master; + public XCANMotorController follower; @Inject - public ElevatorSubsystem(XCANTalon.XCANTalonFactory talonFactory, PropertyFactory pf, Contract2025 contract){ + public ElevatorSubsystem(XCANMotorController.XCANMotorControllerFactory motorFactory, PropertyFactory pf, ElectricalContract contract){ defaultElevatorPower = 0.5; elevatorPower = pf.createPersistentProperty("Standard Power", 0.5); + this.contract = contract; + //was going to make this ephermeral but cant find it + elevatorTargetHeight = pf.createPersistentProperty("Elevator Target", 0); + if(contract.isElevatorReady()){ + this.master = motorFactory.create(contract.getElevatorMaster(), this.getPrefix(), "Elevator Motor"); + this.follower = motorFactory.create(contract.getElevatorFollower(), this.getPrefix(), "Elevator Motor"); + } } - public Object getCurrentValue() { - return null; - } - - - public Object getTargetValue() { - return null; - } - - public void setTargetValue(Object value) { - + public void setTargetHeight(double height) { + elevatorTargetHeight.set(height); } + //will implement logic later public void setPower(double power) { - elevatorPower.set(power); + if (contract.isElevatorReady()) { + master.setPower(power); + follower.setPower(power); + } } public void rise(){ @@ -59,8 +68,12 @@ public void lower(){ setPower(-elevatorPower.get()); } + public void stop(){ + setPower(0); + } + public boolean isCalibrated() { - return false; + return isCalibrated; } } diff --git a/src/main/java/competition/subsystems/elevator/commands/ElevatorMaintainerCommand.java b/src/main/java/competition/subsystems/elevator/commands/ElevatorMaintainerCommand.java index 3972e03..77c5033 100644 --- a/src/main/java/competition/subsystems/elevator/commands/ElevatorMaintainerCommand.java +++ b/src/main/java/competition/subsystems/elevator/commands/ElevatorMaintainerCommand.java @@ -19,7 +19,7 @@ public enum MaintainerMode{ @Inject public ElevatorMaintainerCommand(ElevatorSubsystem elevator, PropertyFactory pf){ - + this.elevator = elevator; } @Override diff --git a/src/main/java/competition/subsystems/elevator/commands/SetElevatorTargetHeightCommand.java b/src/main/java/competition/subsystems/elevator/commands/SetElevatorTargetHeightCommand.java new file mode 100644 index 0000000..021ae6d --- /dev/null +++ b/src/main/java/competition/subsystems/elevator/commands/SetElevatorTargetHeightCommand.java @@ -0,0 +1,33 @@ +package competition.subsystems.elevator.commands; + +import competition.subsystems.elevator.ElevatorSubsystem; +import xbot.common.command.BaseCommand; + +import javax.inject.Inject; + +public class SetElevatorTargetHeightCommand extends BaseCommand { + + double height; + ElevatorSubsystem elevator; + + @Inject + public SetElevatorTargetHeightCommand(ElevatorSubsystem elevator){ + this.elevator = elevator; + addRequirements(elevator); + } + + @Override + public void initialize() { + log.info("initializing"); + elevator.setTargetHeight(height); + } + + @Override + public void execute() { + elevator.setTargetHeight(height); + } + + public void setHeight(double height) { + this.height = height; + } +} diff --git a/src/main/java/competition/subsystems/elevator/commands/StopElevatorCommand.java b/src/main/java/competition/subsystems/elevator/commands/StopElevatorCommand.java new file mode 100644 index 0000000..dd408f5 --- /dev/null +++ b/src/main/java/competition/subsystems/elevator/commands/StopElevatorCommand.java @@ -0,0 +1,29 @@ +package competition.subsystems.elevator.commands; + +import competition.subsystems.elevator.ElevatorSubsystem; +import xbot.common.command.BaseCommand; + +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton +public class StopElevatorCommand extends BaseCommand { + + ElevatorSubsystem elevator; + + @Inject + public StopElevatorCommand(ElevatorSubsystem elevator) { + this.elevator = elevator; + addRequirements(elevator); + } + + @Override + public void initialize() { + log.info("initializing"); + } + + @Override + public void execute() { + elevator.stop(); + } +} \ No newline at end of file From 126bae9e1c4e70933a9ec30b5fad2185c32209a2 Mon Sep 17 00:00:00 2001 From: Junyu Zhu <120147135+junyu101@users.noreply.github.com> Date: Sat, 18 Jan 2025 14:25:17 -0800 Subject: [PATCH 3/7] Small updates to naming --- .../competition/subsystems/elevator/ElevatorSubsystem.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java index ac00905..7953b65 100644 --- a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java +++ b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java @@ -16,10 +16,10 @@ @Singleton public class ElevatorSubsystem extends BaseSubsystem { - public enum ElevatorGoal{ + public enum ElevatorGoals{ //common TargetHeights } - double defaultElevatorPower; + final DoubleProperty elevatorPower; final ElectricalContract contract; @@ -35,7 +35,6 @@ public enum ElevatorGoal{ @Inject public ElevatorSubsystem(XCANMotorController.XCANMotorControllerFactory motorFactory, PropertyFactory pf, ElectricalContract contract){ - defaultElevatorPower = 0.5; elevatorPower = pf.createPersistentProperty("Standard Power", 0.5); this.contract = contract; From ee1d8534958f45d7f54712ae8eec104e615efceb Mon Sep 17 00:00:00 2001 From: Junyu Zhu <120147135+junyu101@users.noreply.github.com> Date: Sat, 18 Jan 2025 14:42:39 -0800 Subject: [PATCH 4/7] Delete unneeded imports --- .../java/competition/subsystems/elevator/ElevatorSubsystem.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java index 7953b65..03f4ed3 100644 --- a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java +++ b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java @@ -5,8 +5,6 @@ import xbot.common.command.BaseSetpointSubsystem; import xbot.common.command.BaseSubsystem; import xbot.common.controls.actuators.XCANMotorController; -import xbot.common.controls.actuators.XCANTalon; -import xbot.common.injection.electrical_contract.CANTalonInfo; import xbot.common.properties.DoubleProperty; import xbot.common.properties.PropertyFactory; From c19b9c13dcf670ad43deb3495357e01f887c8246 Mon Sep 17 00:00:00 2001 From: Junyu Zhu <120147135+junyu101@users.noreply.github.com> Date: Sat, 18 Jan 2025 14:48:59 -0800 Subject: [PATCH 5/7] Deleting MORE unneeded imports... --- .../java/competition/electrical_contract/Contract2025.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/competition/electrical_contract/Contract2025.java b/src/main/java/competition/electrical_contract/Contract2025.java index e79d639..1b7f73d 100644 --- a/src/main/java/competition/electrical_contract/Contract2025.java +++ b/src/main/java/competition/electrical_contract/Contract2025.java @@ -9,7 +9,6 @@ import edu.wpi.first.math.geometry.Rotation3d; import competition.subsystems.pose.PoseSubsystem; -import xbot.common.controls.actuators.XCANTalon; import xbot.common.injection.electrical_contract.CANBusId; import xbot.common.injection.electrical_contract.CANMotorControllerInfo; import xbot.common.injection.electrical_contract.CANMotorControllerOutputConfig; @@ -45,13 +44,13 @@ public boolean isElevatorReady() { @Override public CANMotorControllerInfo getElevatorMaster() { return new CANMotorControllerInfo( - "Master Motor", MotorControllerType.TalonFx, new CANBusId("99"), 99, new CANMotorControllerOutputConfig()); + "Master Elevator Motor", MotorControllerType.TalonFx, new CANBusId("99"), 99, new CANMotorControllerOutputConfig()); } @Override public CANMotorControllerInfo getElevatorFollower() { return new CANMotorControllerInfo( - "Follower Motor", MotorControllerType.TalonFx, new CANBusId("98"), 98, new CANMotorControllerOutputConfig()); + "Follower Elevator Motor", MotorControllerType.TalonFx, new CANBusId("98"), 98, new CANMotorControllerOutputConfig()); } protected String getDriveControllerName(SwerveInstance swerveInstance) { From 4bcfeac477a971cc4dcec6ff58eea9b372ddf38a Mon Sep 17 00:00:00 2001 From: Junyu Zhu <120147135+junyu101@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:39:05 -0800 Subject: [PATCH 6/7] Refactor Code to BaseSetpointSubsystem --- .../electrical_contract/Contract2025.java | 6 +- .../elevator/ElevatorSubsystem.java | 71 ++++++++++++++----- .../SetElevatorTargetHeightCommand.java | 6 +- 3 files changed, 58 insertions(+), 25 deletions(-) diff --git a/src/main/java/competition/electrical_contract/Contract2025.java b/src/main/java/competition/electrical_contract/Contract2025.java index 1b7f73d..248fe38 100644 --- a/src/main/java/competition/electrical_contract/Contract2025.java +++ b/src/main/java/competition/electrical_contract/Contract2025.java @@ -38,18 +38,18 @@ public boolean areCanCodersReady() { @Override public boolean isElevatorReady() { - return false; + return false; //return true when ready } @Override public CANMotorControllerInfo getElevatorMaster() { - return new CANMotorControllerInfo( + return new CANMotorControllerInfo( //change CANBUS ID's later "Master Elevator Motor", MotorControllerType.TalonFx, new CANBusId("99"), 99, new CANMotorControllerOutputConfig()); } @Override public CANMotorControllerInfo getElevatorFollower() { - return new CANMotorControllerInfo( + return new CANMotorControllerInfo( //same as above "Follower Elevator Motor", MotorControllerType.TalonFx, new CANBusId("98"), 98, new CANMotorControllerOutputConfig()); } diff --git a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java index 03f4ed3..21e4d8e 100644 --- a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java +++ b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java @@ -1,9 +1,8 @@ package competition.subsystems.elevator; -import competition.electrical_contract.Contract2025; import competition.electrical_contract.ElectricalContract; +import xbot.common.advantage.DataFrameRefreshable; import xbot.common.command.BaseSetpointSubsystem; -import xbot.common.command.BaseSubsystem; import xbot.common.controls.actuators.XCANMotorController; import xbot.common.properties.DoubleProperty; import xbot.common.properties.PropertyFactory; @@ -12,10 +11,15 @@ import javax.inject.Singleton; @Singleton -public class ElevatorSubsystem extends BaseSubsystem { +public class ElevatorSubsystem extends BaseSetpointSubsystem implements DataFrameRefreshable { public enum ElevatorGoals{ - //common TargetHeights + ScoreL1, + ScoreL2, + ScoreL3, + ScoreL4, + CoralCollection, + ReturnToBase } final DoubleProperty elevatorPower; @@ -24,36 +28,35 @@ public enum ElevatorGoals{ private boolean isCalibrated; final DoubleProperty elevatorTargetHeight; + final DoubleProperty currentHeight; //assuming we'll have a master and follower motors - public XCANMotorController master; - public XCANMotorController follower; + public XCANMotorController masterMotor; + public XCANMotorController followerMotor; @Inject public ElevatorSubsystem(XCANMotorController.XCANMotorControllerFactory motorFactory, PropertyFactory pf, ElectricalContract contract){ - elevatorPower = pf.createPersistentProperty("Standard Power", 0.5); + this.elevatorPower = pf.createPersistentProperty("Elevator Power", 0.5); this.contract = contract; - //was going to make this ephermeral but cant find it - elevatorTargetHeight = pf.createPersistentProperty("Elevator Target", 0); + //was going to make this ephemeral but cant find it + this.elevatorTargetHeight = pf.createPersistentProperty("Elevator Target", 0.0); + this.currentHeight = pf.createPersistentProperty("Current Height", 0.0); + if(contract.isElevatorReady()){ - this.master = motorFactory.create(contract.getElevatorMaster(), this.getPrefix(), "Elevator Motor"); - this.follower = motorFactory.create(contract.getElevatorFollower(), this.getPrefix(), "Elevator Motor"); + this.masterMotor = motorFactory.create(contract.getElevatorMaster(), this.getPrefix(), "Elevator Motor"); + this.followerMotor = motorFactory.create(contract.getElevatorFollower(), this.getPrefix(), "Elevator Motor"); } } - public void setTargetHeight(double height) { - elevatorTargetHeight.set(height); - } - //will implement logic later - public void setPower(double power) { + public void setPower(Double power) { if (contract.isElevatorReady()) { - master.setPower(power); - follower.setPower(power); + masterMotor.setPower(power); + followerMotor.setPower(power); } } @@ -66,11 +69,41 @@ public void lower(){ } public void stop(){ - setPower(0); + setPower(0.0); + } + + + @Override + public Double getCurrentValue() { + if (contract.isElevatorReady()){ + return this.currentHeight.get(); + } + return 0.0; + } + + @Override + public void setTargetValue(Double targetHeight) { + this.elevatorTargetHeight.set(targetHeight); + } + + @Override + public Double getTargetValue() { + return this.elevatorTargetHeight.get(); } public boolean isCalibrated() { return isCalibrated; } + @Override + protected boolean areTwoTargetsEquivalent(Double target1, Double target2) { + return BaseSetpointSubsystem.areTwoDoublesEquivalent(target1, target2, 1); + } + + @Override + public void refreshDataFrame() { + //to be implemented later + } + + } diff --git a/src/main/java/competition/subsystems/elevator/commands/SetElevatorTargetHeightCommand.java b/src/main/java/competition/subsystems/elevator/commands/SetElevatorTargetHeightCommand.java index 021ae6d..1a492ba 100644 --- a/src/main/java/competition/subsystems/elevator/commands/SetElevatorTargetHeightCommand.java +++ b/src/main/java/competition/subsystems/elevator/commands/SetElevatorTargetHeightCommand.java @@ -7,7 +7,7 @@ public class SetElevatorTargetHeightCommand extends BaseCommand { - double height; + Double height; ElevatorSubsystem elevator; @Inject @@ -19,12 +19,12 @@ public SetElevatorTargetHeightCommand(ElevatorSubsystem elevator){ @Override public void initialize() { log.info("initializing"); - elevator.setTargetHeight(height); + elevator.setTargetValue(height); } @Override public void execute() { - elevator.setTargetHeight(height); + elevator.setTargetValue(height); } public void setHeight(double height) { From 6683a8816b26780ecaf6a4c495f371a11fe9e34c Mon Sep 17 00:00:00 2001 From: Junyu Zhu <120147135+junyu101@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:46:25 -0800 Subject: [PATCH 7/7] Add Overrides --- .../java/competition/subsystems/elevator/ElevatorSubsystem.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java index 21e4d8e..9a07009 100644 --- a/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java +++ b/src/main/java/competition/subsystems/elevator/ElevatorSubsystem.java @@ -53,6 +53,7 @@ public ElevatorSubsystem(XCANMotorController.XCANMotorControllerFactory motorFac } //will implement logic later + @Override public void setPower(Double power) { if (contract.isElevatorReady()) { masterMotor.setPower(power); @@ -91,6 +92,7 @@ public Double getTargetValue() { return this.elevatorTargetHeight.get(); } + @Override public boolean isCalibrated() { return isCalibrated; }