Skip to content

Commit 58f8db8

Browse files
committed
Autos
1 parent 74eed28 commit 58f8db8

File tree

7 files changed

+313
-241
lines changed

7 files changed

+313
-241
lines changed

.vscode/launch.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"type": "java",
9+
"name": "Launch Test",
10+
"request": "launch",
11+
"mainClass": "frc.robot.drive.commands.Test",
12+
"projectName": "RapidReact"
13+
},
714
{
815
"type": "wpilib",
916
"name": "WPILib Desktop Debug",

src/main/java/frc/paths/FiveBallPartTwo.java

Lines changed: 201 additions & 201 deletions
Large diffs are not rendered by default.

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import frc.robot.drive.Drivetrain;
5656
import frc.robot.drive.commands.AbsoluteOrientation;
5757
import frc.robot.drive.commands.JoystickDrive;
58+
import frc.robot.drive.commands.MotionProfileTurn;
5859
import frc.robot.drive.commands.RelativeOrientation;
5960
import frc.robot.drive.commands.ResetEncoders;
6061
import frc.robot.drive.commands.TurnToAngle;
@@ -342,9 +343,10 @@ public void configureButtonBindings() {
342343
// .alongWith(new TurnOffLEDs(mLimelight))
343344
// .alongWith(new IdleCommand()));
344345

345-
xBoxX.whenHeld(new VisionShooter(mShooter, mLimelight));
346+
// xBoxX.whenHeld(new VisionShooter(mShooter, mLimelight));
347+
xBoxX.whenHeld(new MotionProfileTurn(mDrive, Math.PI/2));
346348

347-
xBoxX.whenReleased(new StopShooter(mShooter));
349+
// xBoxX.whenReleased(new StopShooter(mShooter));
348350

349351
JoystickButton xBoxY = new JoystickButton(operator, X_BOX_Y);
350352
xBoxY.whenHeld(new PresetFlywheelController(mShooter, "TUR")

src/main/java/frc/robot/auto/groups/FiveBallAuto.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@
3838
public class FiveBallAuto extends SequentialCommandGroup {
3939
public FiveBallAuto(Drivetrain drive, Intake intake, Shooter shooter) {
4040
addCommands(
41-
new ResetOdometry(drive, new Pose2d(new Translation2d(0, 0), Rotation2d.fromDegrees(-90.0))),
41+
new ResetOdometry(drive, new Pose2d(new Translation2d(-0.7, 0), Rotation2d.fromDegrees(-90.0))),
4242
new ResetEncoder(shooter),
4343
new ParallelDeadlineGroup(
4444
new SequentialCommandGroup(
4545
new WaitCommand(0.8), // Give shooter time to spin up & hood to move
4646
new PullTrigger(shooter),
4747
new WaitCommand(0.5)),
4848
// new ActionCommand(new ImageAction("THfade.png", 0.01).brightness(0.7)),
49-
new TrajectoryFollower(drive, new FiveBallPartOne()), // Turn to point at center
5049
new FlywheelController(shooter, 1810, 77.90)),
5150
new ParallelDeadlineGroup(
5251
new StopShooter(shooter),
@@ -65,27 +64,27 @@ public FiveBallAuto(Drivetrain drive, Intake intake, Shooter shooter) {
6564
new WaitCommand(4.0),
6665
new RetractIntake(intake))),
6766
new StopShooter(shooter),
68-
new StopTrigger(shooter),
69-
new ParallelDeadlineGroup(
70-
new TrajectoryFollower(drive, new FiveBallPartThree()),
71-
new FastIntake(intake)),
72-
new WaitCommand(0.9), // Pick up balls 4 & 5
73-
new ParallelDeadlineGroup(
74-
new WaitCommand(4.5),
75-
new SequentialCommandGroup(
76-
new WaitCommand(1.75),
77-
new FlywheelController(shooter, 1795, 77.60)),
78-
new SequentialCommandGroup(
79-
new WaitCommand(2.9),
80-
new PullTrigger(shooter)),
81-
new SequentialCommandGroup(
82-
new WaitCommand(1.5),
83-
new RetractIntake(intake)),
84-
new TrajectoryFollower(drive, new FiveBallPartFour())),
85-
new StopShooter(shooter),
86-
new StopTrigger(shooter),
87-
new ResetHood(shooter),
88-
new SetColor(Status.getInstance(), Color.kBlack)
67+
new StopTrigger(shooter)
68+
// new ParallelDeadlineGroup(
69+
// new TrajectoryFollower(drive, new FiveBallPartThree()),
70+
// new FastIntake(intake)),
71+
// new WaitCommand(0.9), // Pick up balls 4 & 5
72+
// new ParallelDeadlineGroup(
73+
// new WaitCommand(4.5),
74+
// new SequentialCommandGroup(
75+
// new WaitCommand(1.75),
76+
// new FlywheelController(shooter, 1795, 77.60)),
77+
// new SequentialCommandGroup(
78+
// new WaitCommand(2.9),
79+
// new PullTrigger(shooter)),
80+
// new SequentialCommandGroup(
81+
// new WaitCommand(1.5),
82+
// new RetractIntake(intake)),
83+
// new TrajectoryFollower(drive, new FiveBallPartFour())),
84+
// new StopShooter(shooter),
85+
// new StopTrigger(shooter),
86+
// new ResetHood(shooter),
87+
// new SetColor(Status.getInstance(), Color.kBlack)
8988
);
9089
}
9190
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.drive.commands;
6+
7+
import edu.wpi.first.math.controller.ProfiledPIDController;
8+
import edu.wpi.first.math.geometry.Rotation2d;
9+
import edu.wpi.first.math.kinematics.ChassisSpeeds;
10+
import edu.wpi.first.math.trajectory.TrapezoidProfile;
11+
import edu.wpi.first.wpilibj2.command.CommandBase;
12+
import frc.robot.drive.Drivetrain;
13+
14+
public class MotionProfileTurn extends CommandBase {
15+
Drivetrain drive;
16+
double offset;
17+
double target;
18+
ProfiledPIDController controller;
19+
20+
public MotionProfileTurn(Drivetrain drive, double offset) {
21+
this.drive = drive;
22+
this.offset = offset;
23+
addRequirements(drive);
24+
controller = new ProfiledPIDController(0.0, 0.0, 0.0, new TrapezoidProfile.Constraints(10, 10));
25+
controller.enableContinuousInput(-Math.PI, Math.PI);
26+
}
27+
28+
@Override
29+
public void initialize() {
30+
target = offset + drive.getPose().getRotation().getRadians();
31+
}
32+
33+
@Override
34+
public void execute() {
35+
double theta = drive.getPose().getRotation().getRadians();
36+
double feedback = controller.calculate(theta, 0);
37+
double feedforward = controller.getSetpoint().velocity;
38+
drive.drive(new ChassisSpeeds(0, 0, feedforward), false);
39+
}
40+
41+
// Called once the command ends or is interrupted.
42+
@Override
43+
public void end(boolean interrupted) {
44+
drive.brake();
45+
}
46+
47+
// Returns true when the command should end.
48+
@Override
49+
public boolean isFinished() {
50+
return false;
51+
}
52+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package frc.robot.drive.commands;
2+
3+
import edu.wpi.first.math.controller.ProfiledPIDController;
4+
import edu.wpi.first.math.trajectory.TrapezoidProfile;
5+
6+
public class Test {
7+
public static void main(String[] args) {
8+
ProfiledPIDController controller = new ProfiledPIDController(1,0,0,new TrapezoidProfile.Constraints(1, 1));
9+
System.out.println(controller.calculate(1, 2));
10+
11+
}
12+
}

src/main/python/paths.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,23 @@ def main():
8585
# [0,0.00000001,-1.85]],
8686
# "FiveBallPartOne")
8787

88-
# generator.generate([
89-
# [0,0,-1.85],
90-
# [-0.2,0.9,-1.85],
91-
# [1.85,-0.5,-math.pi+0.6]
92-
# ],
93-
# "FiveBallPartTwo")
94-
9588
generator.generate([
96-
[1.85,-0.5,-math.pi+0.6],
97-
[6.15,0.3,-math.pi+0.7]
89+
[-0.7,0,-math.pi/2],
90+
[-0.2,0.9,-math.pi/2+0.15],
91+
[1.85,-0.5,-math.pi+0.6]
9892
],
99-
"FiveBallPartThree")
93+
"FiveBallPartTwo")
10094

101-
generator.generate([
102-
[6.15,0.3,-math.pi+0.7],
103-
[0.10,-0.375,-math.pi+1.25]
104-
],
105-
"FiveBallPartFour")
95+
# generator.generate([
96+
# [1.85,-0.5,-math.pi+0.6],
97+
# [6.15,0.3,-math.pi+0.7]
98+
# ],
99+
# "FiveBallPartThree")
100+
101+
# generator.generate([
102+
# [6.15,0.3,-math.pi+0.7],
103+
# [0.10,-0.375,-math.pi+1.25]
104+
# ],
105+
# "FiveBallPartFour")
106106

107107
main()

0 commit comments

Comments
 (0)