Skip to content

Commit 05e55bd

Browse files
committed
e
Signed-off-by: Dasun Abeykoon <[email protected]>
1 parent 674c3a1 commit 05e55bd

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) 2025 FRC 6423 - Ward Melville Iron Patriots
2+
// https://github.com/wmironpatriots
3+
//
4+
// Open Source Software; you can modify and/or share it under the terms of
5+
// MIT license file in the root directory of this project
6+
7+
package org.frc6423.robot.subsystems.superstructure;
8+
9+
import static edu.wpi.first.units.Units.Centimeters;
10+
11+
import edu.wpi.first.epilogue.Logged;
12+
import edu.wpi.first.wpilibj2.command.SubsystemBase;
13+
import org.frc6423.robot.subsystems.superstructure.arm.Arm;
14+
import org.frc6423.robot.subsystems.superstructure.elevator.Elevator;
15+
16+
public class Superstructure extends SubsystemBase {
17+
@Logged private final Elevator elevator = Elevator.create();
18+
@Logged private final Arm arm = Arm.create();
19+
20+
private final Visualizer visualizer = Visualizer.getInstance();
21+
22+
public Superstructure() {}
23+
24+
public void periodic() {
25+
/** Set visualizer poses */
26+
visualizer.setCarriageHeight(elevator.getCarriageHeight().in(Centimeters));
27+
visualizer.setStageHeight(elevator.getStageHeight().in(Centimeters));
28+
visualizer.setArmAngle(arm.getRotation2d());
29+
}
30+
}

src/main/java/org/frc6423/robot/subsystems/superstructure/Visualizer.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.MAX_EXTENSION_HEIGHT;
1212

1313
import edu.wpi.first.math.geometry.Rotation2d;
14+
import edu.wpi.first.units.measure.Distance;
1415
import edu.wpi.first.wpilibj.smartdashboard.Mechanism2d;
1516
import edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d;
1617
import edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d;
@@ -65,6 +66,15 @@ private Visualizer() {
6566
SmartDashboard.putData("GlobalVisualizer", mech2d);
6667
}
6768

69+
public void setStageHeight(Distance height) {
70+
stageRoot.setPosition((MAX_EXTENSION_HEIGHT.in(Centimeters) / 2) - 2, height.in(Centimeters));
71+
}
72+
73+
public void setCarriageHeight(Distance height) {
74+
carriageRoot.setPosition(
75+
(MAX_EXTENSION_HEIGHT.in(Centimeters) / 2) - 4, height.in(Centimeters));
76+
}
77+
6878
public void setStageHeight(double heightCentimeters) {
6979
stageRoot.setPosition((MAX_EXTENSION_HEIGHT.in(Centimeters) / 2) - 2, heightCentimeters);
7080
}
@@ -73,6 +83,10 @@ public void setCarriageHeight(double heightCentimeters) {
7383
carriageRoot.setPosition((MAX_EXTENSION_HEIGHT.in(Centimeters) / 2) - 4, heightCentimeters);
7484
}
7585

86+
public void setArmAngle(Rotation2d angle) {
87+
arm.setAngle(angle.unaryMinus().plus(Rotation2d.kCCW_90deg));
88+
}
89+
7690
public void setArmAngle(double angleRads) {
7791
arm.setAngle(Rotation2d.fromRadians(angleRads).unaryMinus().plus(Rotation2d.kCCW_90deg));
7892
}

0 commit comments

Comments
 (0)