Skip to content

Commit eb62f0d

Browse files
authored
Merge branch 'main' into zhangal/phoenixpro
2 parents c797e4f + 48618e7 commit eb62f0d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/main/java/org/team1540/robot2024/Constants.java

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public static class SwerveConfig {
4848
// TODO: set this id
4949
public static final int PIGEON_ID = 0;
5050
}
51+
5152
public static class Drivetrain {
5253
public static final double DRIVE_GEAR_RATIO = (50.0 / 14.0) * (17.0 / 27.0) * (45.0 / 15.0);
5354
public static final double TURN_GEAR_RATIO = 150.0 / 7.0;
@@ -61,6 +62,10 @@ public static class Drivetrain {
6162
public static final double MAX_ANGULAR_SPEED = MAX_LINEAR_SPEED / DRIVE_BASE_RADIUS;
6263
}
6364

65+
public static class Elevator {
66+
public static final double ELEVATOR_MAX_HEIGHT = Units.inchesToMeters(21.0);
67+
}
68+
6469
public static class Shooter {
6570
public static class Flywheels {
6671
// TODO: determine ids

src/main/java/org/team1540/robot2024/Robot.java

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.littletonrobotics.junction.networktables.NT4Publisher;
1010
import org.littletonrobotics.junction.wpilog.WPILOGReader;
1111
import org.littletonrobotics.junction.wpilog.WPILOGWriter;
12+
import org.team1540.robot2024.util.MechanismVisualiser;
1213

1314
/**
1415
* The VM is configured to automatically run this class, and to call the functions corresponding to
@@ -90,6 +91,9 @@ public void robotPeriodic() {
9091
// the Command-based framework to work.
9192
CommandScheduler.getInstance().run();
9293
if (Constants.currentMode == Constants.Mode.REAL) robotContainer.odometrySignalRefresher.periodic();
94+
95+
// Update mechanism visualiser in sim
96+
if (Robot.isSimulation()) MechanismVisualiser.periodic();
9397
}
9498

9599
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.team1540.robot2024.util;
2+
3+
import edu.wpi.first.math.geometry.Pose3d;
4+
import edu.wpi.first.math.geometry.Rotation2d;
5+
import edu.wpi.first.math.geometry.Rotation3d;
6+
import org.littletonrobotics.junction.Logger;
7+
8+
public class MechanismVisualiser {
9+
private static Pose3d shooterPivot = new Pose3d();
10+
private static Pose3d elevator = new Pose3d();
11+
12+
public static void periodic() {
13+
Logger.recordOutput("Mechanisms", shooterPivot, elevator);
14+
}
15+
16+
public static void setElevatorPosition(double positionMeters) {
17+
elevator = new Pose3d(0.0, 0.0, positionMeters, new Rotation3d());
18+
}
19+
20+
public static void setShooterPivotRotation(Rotation2d rotation) {
21+
shooterPivot = new Pose3d(0.0, 0.0, 0.0, new Rotation3d(0, rotation.getRadians(), 0));
22+
}
23+
}

0 commit comments

Comments
 (0)