Skip to content

Commit b31f505

Browse files
committed
so teleopInit wasn't in robot.java...
1 parent 407af19 commit b31f505

File tree

10 files changed

+70
-24
lines changed

10 files changed

+70
-24
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This gitignore has been specially created by the WPILib team.
22
# If you remove items from this file, intellisense might break.
3-
*src/main/java/frc/robot/BuildConstants.java
3+
# *src/main/java/frc/robot/BuildConstants.java
44
simgui-ds.json
55
simgui.json
66
networktables.json

build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,15 @@ tasks.withType(JavaCompile) {
151151
}
152152

153153
// Create version file
154-
// project.compileJava.dependsOn(createVersionFile)
155-
// gversion {
156-
// srcDir = "src/main/java/"
157-
// classPackage = "frc.robot"
158-
// className = "BuildConstants"
159-
// dateFormat = "yyyy-MM-dd HH:mm:ss z"
160-
// timeZone = "America/New_York"
161-
// indent = " "
162-
// }
154+
project.compileJava.dependsOn(createVersionFile)
155+
gversion {
156+
srcDir = "src/main/java/"
157+
classPackage = "frc.robot"
158+
className = "BuildConstants"
159+
dateFormat = "yyyy-MM-dd HH:mm:ss z"
160+
timeZone = "America/New_York"
161+
indent = " "
162+
}
163163

164164
// TODO: set this shit up
165165
// Create commit with working changes on event branches
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package frc.robot;
2+
3+
/** Automatically generated file containing build version information. */
4+
public final class BuildConstants {
5+
public static final String MAVEN_GROUP = "";
6+
public static final String MAVEN_NAME = "offseason-robot-code-2024-4";
7+
public static final String VERSION = "unspecified";
8+
public static final int GIT_REVISION = 460;
9+
public static final String GIT_SHA = "407af199c2fcc39f00d180058fa4bb5040ba980a";
10+
public static final String GIT_DATE = "2024-12-16 16:34:08 EST";
11+
public static final String GIT_BRANCH = "shooter-pivot-sim";
12+
public static final String BUILD_DATE = "2024-12-20 17:10:49 EST";
13+
public static final long BUILD_UNIX_TIME = 1734732649398L;
14+
public static final int DIRTY = 1;
15+
16+
private BuildConstants() {}
17+
}

src/main/java/frc/robot/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static final class LogPaths {
1414
public static final String APRIL_TAGS_VISION_PATH = "Vision/AprilTags/";
1515
}
1616

17-
public static final Mode currentMode = Mode.SIM;
17+
public static final Mode CURRENT_MODE = Mode.SIM;
1818

1919
public static enum Mode {
2020
/** Running on a real robot. */

src/main/java/frc/robot/Robot.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Robot() {
4040
}
4141

4242
// Set up data receivers & replay source
43-
switch (Constants.currentMode) {
43+
switch (Constants.CURRENT_MODE) {
4444
case REAL:
4545
// Running on a real robot, log to a USB stick ("/U/logs")
4646
Logger.addDataReceiver(new WPILOGWriter());
@@ -113,6 +113,7 @@ public void autonomousPeriodic() {}
113113
/** This function is called once when teleop is enabled. */
114114
@Override
115115
public void teleopInit() {
116+
m_robotContainer.teleopInit();
116117
// This makes sure that the autonomous stops running when
117118
// teleop starts running. If you want the autonomous to
118119
// continue until interrupted by another command, remove

src/main/java/frc/robot/RobotContainer.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
1010
import edu.wpi.first.wpilibj2.command.button.Trigger;
1111
import frc.robot.commands.drive.DriveCommand;
12+
import frc.robot.commands.pivot.ManualPivot;
1213
import frc.robot.extras.simulation.field.SimulatedField;
1314
import frc.robot.extras.simulation.mechanismSim.swerve.GyroSimulation;
1415
import frc.robot.extras.simulation.mechanismSim.swerve.SwerveDriveSimulation;
1516
import frc.robot.extras.simulation.mechanismSim.swerve.SwerveModuleSimulation;
1617
import frc.robot.extras.simulation.mechanismSim.swerve.SwerveModuleSimulation.WHEEL_GRIP;
1718
import frc.robot.extras.util.JoystickUtil;
19+
import frc.robot.subsystems.pivot.Pivot;
20+
import frc.robot.subsystems.pivot.PivotIOSim;
21+
import frc.robot.subsystems.pivot.PivotIOTalonFX;
1822
import frc.robot.subsystems.swerve.SwerveConstants;
1923
import frc.robot.subsystems.swerve.SwerveConstants.DriveConstants;
2024
import frc.robot.subsystems.swerve.SwerveConstants.ModuleConstants;
@@ -36,9 +40,10 @@ public class RobotContainer {
3640
private final Vision visionSubsystem;
3741
private final SwerveDrive swerveDrive;
3842
private final CommandXboxController operatorController = new CommandXboxController(1);
43+
// private final Pivot pivot;
3944
// private final Indexer indexer = new Indexer(new IndexerIOTalonFX());
4045
// private final Intake intake = new Intake(new IntakeIOTalonFX());
41-
// private final Pivot pivot = new Pivot(new PivotIOTalonFX());
46+
private final Pivot pivot;
4247
// private final Flywheel flywheel = new Flywheel(new FlywheelIOTalonFX());
4348
private final CommandXboxController driverController = new CommandXboxController(0);
4449

@@ -51,7 +56,7 @@ public class RobotContainer {
5156
// private final XboxController driverController = new XboxController(0);
5257

5358
public RobotContainer() {
54-
switch (Constants.currentMode) {
59+
switch (Constants.CURRENT_MODE) {
5560
case REAL -> {
5661
/* Real robot, instantiate hardware IO implementations */
5762

@@ -68,12 +73,14 @@ public RobotContainer() {
6873
new PhysicalModule(SwerveConstants.moduleConfigs[2]),
6974
new PhysicalModule(SwerveConstants.moduleConfigs[3]));
7075
visionSubsystem = new Vision(new VisionIOReal());
76+
pivot = new Pivot(new PivotIOTalonFX());
7177
}
7278

7379
case SIM -> {
7480
/* Sim robot, instantiate physics sim IO implementations */
7581

7682
/* create simulations */
83+
pivot = new Pivot(new PivotIOSim());
7784
/* create simulation for pigeon2 IMU (different IMUs have different measurement erros) */
7885
this.gyroSimulation = GyroSimulation.createNavX2();
7986
/* create a swerve drive simulation */
@@ -128,6 +135,7 @@ public RobotContainer() {
128135
new ModuleInterface() {},
129136
new ModuleInterface() {},
130137
new ModuleInterface() {});
138+
pivot = null;
131139
}
132140
}
133141
}
@@ -190,7 +198,7 @@ private void configureButtonBindings() {
190198
// Trigger driverRightTrigger = new Trigger(()->driverController.getRightTriggerAxis() > 0.2);
191199

192200
// // manual pivot and intake rollers
193-
// Trigger operatorAButton = new Trigger(operatorController::getAButton);
201+
Trigger operatorAButton = new Trigger(operatorController.a());
194202
// Trigger operatorXButton = new Trigger(operatorController::getXButton);
195203
// Trigger operatorYButton = new Trigger(operatorController::getYButton);
196204
// DoubleSupplier operatorRightStickY = operatorController::getRightY;
@@ -202,7 +210,7 @@ private void configureButtonBindings() {
202210
Trigger driverLeftBumper = new Trigger(driverController.leftBumper());
203211
// Trigger driverBButton = new Trigger(driverController::getBButton);
204212
// Trigger driverYButton = new Trigger(driverController::getYButton);
205-
// DoubleSupplier operatorLeftStickY = operatorController::getLeftY;
213+
DoubleSupplier operatorLeftStickY = operatorController::getLeftY;
206214

207215
// //DRIVER BUTTONS
208216

@@ -285,8 +293,8 @@ private void configureButtonBindings() {
285293
// operatorLeftBumper.whileTrue(new TowerIntake(intakeSubsystem, pivotSubsystem,
286294
// shooterSubsystem, true, ledSubsystem, this::intakeCallback));
287295
// // manual pivot (possible climb, unlikely)
288-
// operatorAButton.whileTrue(new ManualPivot(pivotSubsystem,
289-
// ()->modifyAxisCubed(operatorRightStickY)));
296+
operatorAButton.whileTrue(
297+
new ManualPivot(pivot, () -> JoystickUtil.modifyAxisCubed(operatorLeftStickY)));
290298
// operatorDownDirectionPad.whileTrue(new ManualPivot(pivotSubsystem, ()->-0.2));
291299
// // manual rollers
292300
// operatorYButton.whileTrue(new ManualIntake(intakeSubsystem, true));

src/main/java/frc/robot/commands/pivot/ManualPivot.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package frc.robot.commands.pivot;
66

7+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
78
import edu.wpi.first.wpilibj2.command.Command;
89
import frc.robot.subsystems.pivot.*;
910
import java.util.function.DoubleSupplier;
@@ -29,6 +30,7 @@ public void initialize() {}
2930
@Override
3031
public void execute() {
3132
pivot.setPivotSpeed(speed.getAsDouble());
33+
SmartDashboard.putNumber("command speed for pivot", speed.getAsDouble());
3234
}
3335

3436
// Called once the command ends or is interrupted.

src/main/java/frc/robot/subsystems/pivot/PivotConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import com.ctre.phoenix6.signals.SensorDirectionValue;
44

55
public class PivotConstants {
6-
public static final double PIVOT_MASS = 0 - 9;
7-
public static final double PIVOT_LENGTH = 0 - 9;
6+
public static final double PIVOT_MASS = 5;
7+
public static final double PIVOT_LENGTH = 5;
88

99
public static final double PIVOT_GEAR_RATIO = 8.0;
1010

src/main/java/frc/robot/subsystems/pivot/PivotIOSim.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
package frc.robot.subsystems.pivot;
66

7+
import static edu.wpi.first.units.Units.Radians;
8+
import static edu.wpi.first.units.Units.Rotations;
9+
710
import edu.wpi.first.math.controller.ArmFeedforward;
811
import edu.wpi.first.math.controller.ProfiledPIDController;
912
import edu.wpi.first.math.system.plant.DCMotor;
1013
import edu.wpi.first.math.trajectory.TrapezoidProfile.Constraints;
1114
import edu.wpi.first.math.util.Units;
1215
import edu.wpi.first.wpilibj.simulation.SingleJointedArmSim;
16+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1317
import frc.robot.Constants.HardwareConstants;
1418

1519
public class PivotIOSim implements PivotIO {
@@ -22,9 +26,16 @@ public class PivotIOSim implements PivotIO {
2226

2327
private SingleJointedArmSim pivotSim =
2428
new SingleJointedArmSim(
25-
DCMotor.getKrakenX60(2), pivotGearing, pivotMass, pivotLength, 0, 0, true, 0);
29+
DCMotor.getKrakenX60(2),
30+
pivotGearing,
31+
0.01,
32+
pivotLength,
33+
Rotations.of(0).in(Radians),
34+
Rotations.of(1).in(Radians),
35+
true,
36+
Rotations.of(0).in(Radians));
2637

27-
private final Constraints pivotConstraints = new Constraints(0, 0);
38+
private final Constraints pivotConstraints = new Constraints(0.8, 0.8);
2839
private final ArmFeedforward armFeedforward = new ArmFeedforward(armkS, armkG, armkV);
2940
private final ProfiledPIDController pivotController =
3041
new ProfiledPIDController(0, 0, 0, pivotConstraints);
@@ -49,6 +60,8 @@ public void updateInputs(PivotIOInputs inputs) {
4960
inputs.followerVelocity = Units.radiansToRotations(pivotSim.getVelocityRadPerSec());
5061
inputs.followerAppliedVolts = followerAppliedVolts;
5162
inputs.followerSupplyCurrentAmps = pivotSim.getCurrentDrawAmps();
63+
SmartDashboard.putNumber("Pivot Angle Rads", pivotSim.getAngleRads());
64+
SmartDashboard.putNumber("Pivot Speed Rads Per Sec", pivotSim.getVelocityRadPerSec());
5265
}
5366

5467
/**
@@ -72,6 +85,11 @@ public void setVoltage(double volts) {
7285
public void setPivotAngle(double angleRots) {
7386
double currentPivotAngleRots = Units.radiansToRotations(pivotSim.getAngleRads());
7487
double armFF = armFeedforward.calculate(angleRots, pivotController.getSetpoint().velocity);
75-
setVoltage(pivotController.calculate(angleRots, currentPivotAngleRots) + armFF);
88+
setVoltage(pivotController.calculate(currentPivotAngleRots, angleRots) + armFF);
89+
}
90+
91+
@Override
92+
public void setPivotSpeed(double output) {
93+
pivotSim.setInput(output);
7694
}
7795
}

src/main/java/frc/robot/subsystems/swerve/odometryThread/OdometryThread.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static Queue<Angle> registerInput(Supplier<Angle> supplier) {
4848
}
4949

5050
static OdometryThread createInstance(DeviceCANBus canBus) {
51-
return switch (Constants.currentMode) {
51+
return switch (Constants.CURRENT_MODE) {
5252
case REAL ->
5353
new OdometryThreadReal(
5454
canBus,

0 commit comments

Comments
 (0)