Skip to content

Commit 0da4515

Browse files
committed
Fix flywheel and pivot logic after the testing on 12/2
1 parent 047ff0e commit 0da4515

File tree

2 files changed

+42
-47
lines changed

2 files changed

+42
-47
lines changed

src/main/kotlin/com/frcteam3636/bunnybots2025/Robot.kt

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -289,23 +289,23 @@ object Robot : LoggedRobot() {
289289
)
290290

291291
controller.leftTrigger().whileTrue(Intake.bulldoze())
292-
controller.rightTrigger().whileTrue(
293-
Commands.parallel(
294-
Shooter.Flywheels.shoot(),
295-
Commands.sequence(
296-
Commands.waitUntil(Shooter.Flywheels.atDesiredVelocity),
297-
Commands.waitUntil(Shooter.Pivot.atDesiredPosition),
298-
Commands.waitTime(0.5.seconds),
299-
Commands.parallel(
300-
Shooter.Feeder.feed()
301-
)
302-
),
303-
Commands.sequence(
304-
Shooter.Pivot.setTarget(Target.PETTINGZOO),
305-
Shooter.Pivot.moveToActiveTarget()
306-
)
307-
)
308-
)
292+
// controller.rightTrigger().whileTrue(
293+
// Commands.parallel(
294+
// Shooter.Flywheels.shoot(),
295+
// Commands.sequence(
296+
// Commands.waitUntil(Shooter.Flywheels.atDesiredVelocity),
297+
// Commands.waitUntil(Shooter.Pivot.atDesiredPosition),
298+
// Commands.waitTime(0.5.seconds),
299+
// Commands.parallel(
300+
// Shooter.Feeder.feed()
301+
// )
302+
// ),
303+
// Commands.sequence(
304+
// Shooter.Pivot.setTarget(Target.PETTINGZOO),
305+
// Shooter.Pivot.moveToActiveTarget()
306+
// )
307+
// )
308+
// )
309309

310310
controller.a().onTrue(Shooter.Pivot.setTarget(Target.STOWED))
311311
controller.b().onTrue(Shooter.Pivot.setTarget(Target.PETTINGZOO))
@@ -329,21 +329,20 @@ object Robot : LoggedRobot() {
329329
controllerDev.x().whileTrue(Shooter.Flywheels.sysIdDynamic(SysIdRoutine.Direction.kReverse))
330330

331331

332-
// controller.rightTrigger()
333-
// .whileTrue(Commands.parallel(
334-
// Shooter.Flywheels.shoot(),
335-
// Commands.sequence(
336-
// Commands.waitUntil(Shooter.Flywheels.atDesiredVelocity),
337-
// Commands.waitUntil(Shooter.Pivot.atDesiredPosition),
338-
// Commands.parallel(
339-
// Shooter.Feeder.feed(),
340-
// Indexer.index()
341-
// )
342-
// )
343-
// ))
344-
// .onTrue(Shooter.Pivot.setTarget(Target.TUNING))
345-
// .onFalse(Shooter.Pivot.setTarget(Target.STOWED))
346-
// .onFalse(Shooter.Pivot.setTarget(Target.STOWED))
332+
controllerDev.rightTrigger()
333+
.whileTrue(Commands.parallel(
334+
Shooter.Flywheels.shoot(),
335+
Commands.sequence(
336+
Commands.waitUntil(Shooter.Flywheels.atDesiredVelocity),
337+
Commands.waitUntil(Shooter.Pivot.atDesiredPosition),
338+
Commands.parallel(
339+
Shooter.Feeder.feed(),
340+
Indexer.index()
341+
)
342+
)
343+
))
344+
.onTrue(Shooter.Pivot.setTarget(Target.TUNING))
345+
.onFalse(Shooter.Pivot.setTarget(Target.STOWED))
347346
// controllerDev.leftTrigger()
348347
// .onTrue(Shooter.Pivot.setTarget(Target.AIM))
349348
// .onFalse(Shooter.Pivot.setTarget(Target.STOWED))

src/main/kotlin/com/frcteam3636/bunnybots2025/subsystems/shooter/Shooter.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ object Shooter {
5151
Logger.recordOutput("Shooter/Flywheels/Velocity Difference", velocityDifference)
5252
Logger.recordOutput(
5353
"Shooter/Flywheels/At Desired Velocity",
54-
velocityDifference < FLYWHEEL_VELOCITY_TOLERANCE
54+
abs(velocityDifference.inRPM()) < FLYWHEEL_VELOCITY_TOLERANCE.inRPM()
5555
)
56-
velocityDifference < FLYWHEEL_VELOCITY_TOLERANCE
56+
abs(velocityDifference.inRPM()) < FLYWHEEL_VELOCITY_TOLERANCE.inRPM()
5757
}
5858

5959
val speedInterpolationTable = InterpolatingDoubleTreeMap()
@@ -96,8 +96,8 @@ object Shooter {
9696

9797
Logger.processInputs("Shooter/Flywheels", inputs)
9898

99-
Logger.recordOutput("Shooter/Flywheels/upperSetpoint", upperSetpoint.inRPM())
100-
Logger.recordOutput("Shooter/Flywheels/lowerSetpoint", lowerSetpoint.inRPM())
99+
Logger.recordOutput("Shooter/Flywheels/upperSetpoint", upperSetpoint)
100+
Logger.recordOutput("Shooter/Flywheels/lowerSetpoint", lowerSetpoint)
101101
io.setVelocity(upperSetpoint, lowerSetpoint) // move this into commands?
102102
}
103103

@@ -115,16 +115,10 @@ object Shooter {
115115

116116
fun shoot(): Command =
117117
//TODO: Fix
118-
startEnd(
119-
{
120-
upperSetpoint = 500.radiansPerSecond
121-
lowerSetpoint = 500.radiansPerSecond
122-
},
123-
{
124-
upperSetpoint = 0.radiansPerSecond
125-
lowerSetpoint = 0.radiansPerSecond
126-
}
127-
)
118+
run {
119+
upperSetpoint = Pivot.target.profile.getVelocity()
120+
lowerSetpoint = Pivot.target.profile.getVelocity()
121+
}
128122

129123
val signals: Array<BaseStatusSignal>
130124
get() = io.signals
@@ -175,12 +169,14 @@ object Shooter {
175169
pivotAngleLigament.angle = inputs.pivotAngle.inDegrees()
176170
Logger.recordOutput("Shooter/Pivot/Mechanism", mechanism)
177171
Logger.recordOutput("Shooter/Pivot/Active Profile", target)
172+
Logger.recordOutput("Shooter/Pivot/Reference", target.profile.getPosition())
178173
}
179174

180175
val atDesiredPosition =
181176
Trigger {
182177
val difference = inputs.pivotAngle.inDegrees() - target.profile.getPosition().inDegrees()
183-
abs(difference) < 2.0
178+
Logger.recordOutput("Shooter/Pivot/At Desired Position", abs(difference) < 3.0)
179+
abs(difference) < 3.0
184180
}
185181

186182
val signals: Array<BaseStatusSignal>

0 commit comments

Comments
 (0)