|
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. |
| 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 | 4 |
|
5 | | -package frc.robot.commands; |
| 5 | +// package frc.robot.commands; |
6 | 6 |
|
7 | | -import com.pathplanner.lib.auto.AutoBuilder; |
8 | | -import com.pathplanner.lib.path.GoalEndState; |
9 | | -import com.pathplanner.lib.path.PathConstraints; |
10 | | -import com.pathplanner.lib.path.PathPlannerPath; |
11 | | -import edu.wpi.first.math.geometry.Pose2d; |
12 | | -import edu.wpi.first.math.geometry.Rotation2d; |
13 | | -import edu.wpi.first.math.geometry.Translation2d; |
14 | | -import edu.wpi.first.math.util.Units; |
15 | | -import edu.wpi.first.wpilibj.DriverStation; |
16 | | -import edu.wpi.first.wpilibj2.command.Command; |
17 | | -import frc.robot.subsystems.drive.Drive; |
18 | | -import frc.robot.util.FieldConstants; |
19 | | -import java.util.List; |
| 7 | +// import com.pathplanner.lib.auto.AutoBuilder; |
| 8 | +// import com.pathplanner.lib.path.GoalEndState; |
| 9 | +// import com.pathplanner.lib.path.PathConstraints; |
| 10 | +// import com.pathplanner.lib.path.PathPlannerPath; |
| 11 | +// import edu.wpi.first.math.geometry.Pose2d; |
| 12 | +// import edu.wpi.first.math.geometry.Rotation2d; |
| 13 | +// import edu.wpi.first.math.geometry.Translation2d; |
| 14 | +// import edu.wpi.first.math.util.Units; |
| 15 | +// import edu.wpi.first.wpilibj.DriverStation; |
| 16 | +// import edu.wpi.first.wpilibj2.command.Command; |
| 17 | +// import frc.robot.subsystems.drive.Drive; |
| 18 | +// import frc.robot.util.FieldConstants; |
| 19 | +// import java.util.List; |
20 | 20 |
|
21 | | -public class AlignToAmp extends Command { |
22 | | - private final Drive drive; |
| 21 | +// public class AlignToAmp extends Command { |
| 22 | +// private final Drive drive; |
23 | 23 |
|
24 | | - private List<Translation2d> pointsToAmp; |
25 | | - private Command pathCommand; |
26 | | - private PathPlannerPath path; |
| 24 | +// private List<Translation2d> pointsToAmp; |
| 25 | +// private Command pathCommand; |
| 26 | +// private PathPlannerPath path; |
27 | 27 |
|
28 | | - private Rotation2d targetRotation = new Rotation2d(); |
29 | | - /** Creates a new AlignToAmp. */ |
30 | | - public AlignToAmp(Drive drive) { |
31 | | - // Use addRequirements() here to declare subsystem dependencies. |
32 | | - this.drive = drive; |
| 28 | +// private Rotation2d targetRotation = new Rotation2d(); |
| 29 | +// /** Creates a new AlignToAmp. */ |
| 30 | +// public AlignToAmp(Drive drive) { |
| 31 | +// // Use addRequirements() here to declare subsystem dependencies. |
| 32 | +// this.drive = drive; |
33 | 33 |
|
34 | | - addRequirements(drive); |
| 34 | +// addRequirements(drive); |
35 | 35 |
|
36 | | - targetRotation = drive.getRotation(); |
37 | | - } |
| 36 | +// targetRotation = drive.getRotation(); |
| 37 | +// } |
38 | 38 |
|
39 | | - // Called when the command is initially scheduled. |
40 | | - @Override |
41 | | - public void initialize() { |
42 | | - if (DriverStation.getAlliance().get() == DriverStation.Alliance.Blue) { |
43 | | - targetRotation = |
44 | | - new Rotation2d( |
45 | | - (Units.degreesToRadians( |
46 | | - new Rotation2d(FieldConstants.ampCenter.getX(), FieldConstants.ampCenter.getY()) |
47 | | - .getDegrees() |
48 | | - + 13))); |
49 | | - pointsToAmp = |
50 | | - PathPlannerPath.bezierFromPoses( |
51 | | - new Pose2d( |
52 | | - drive.getPose().getX(), drive.getPose().getY(), drive.getPose().getRotation()), |
53 | | - new Pose2d( |
54 | | - FieldConstants.ampCenter.getX(), |
55 | | - FieldConstants.ampCenter.getY() - 0.5, |
56 | | - targetRotation)); |
57 | | - path = |
58 | | - new PathPlannerPath( |
59 | | - pointsToAmp, |
60 | | - new PathConstraints(3, 3, Units.degreesToRadians(540), Units.degreesToRadians(720)), |
61 | | - new GoalEndState(0, targetRotation, true)); |
62 | | - } else { |
63 | | - targetRotation = |
64 | | - new Rotation2d( |
65 | | - Units.degreesToRadians( |
66 | | - new Rotation2d( |
67 | | - FieldConstants.fieldLength - FieldConstants.ampCenter.getX(), |
68 | | - FieldConstants.ampCenter.getY()) |
69 | | - .getDegrees() |
70 | | - + 62)); |
| 39 | +// // Called when the command is initially scheduled. |
| 40 | +// @Override |
| 41 | +// public void initialize() { |
| 42 | +// if (DriverStation.getAlliance().get() == DriverStation.Alliance.Blue) { |
| 43 | +// targetRotation = |
| 44 | +// new Rotation2d( |
| 45 | +// (Units.degreesToRadians( |
| 46 | +// new Rotation2d(FieldConstants.ampCenter.getX(), FieldConstants.ampCenter.getY()) |
| 47 | +// .getDegrees() |
| 48 | +// + 13))); |
| 49 | +// pointsToAmp = |
| 50 | +// PathPlannerPath.bezierFromPoses( |
| 51 | +// new Pose2d( |
| 52 | +// drive.getPose().getX(), drive.getPose().getY(), drive.getPose().getRotation()), |
| 53 | +// new Pose2d( |
| 54 | +// FieldConstants.ampCenter.getX(), |
| 55 | +// FieldConstants.ampCenter.getY() - 0.5, |
| 56 | +// targetRotation)); |
| 57 | +// path = |
| 58 | +// new PathPlannerPath( |
| 59 | +// pointsToAmp, |
| 60 | +// new PathConstraints(3, 3, Units.degreesToRadians(540), Units.degreesToRadians(720)), |
| 61 | +// new GoalEndState(0, targetRotation, true)); |
| 62 | +// } else { |
| 63 | +// targetRotation = |
| 64 | +// new Rotation2d( |
| 65 | +// Units.degreesToRadians( |
| 66 | +// new Rotation2d( |
| 67 | +// FieldConstants.fieldLength - FieldConstants.ampCenter.getX(), |
| 68 | +// FieldConstants.ampCenter.getY()) |
| 69 | +// .getDegrees() |
| 70 | +// + 62)); |
71 | 71 |
|
72 | | - pointsToAmp = |
73 | | - PathPlannerPath.bezierFromPoses( |
74 | | - new Pose2d( |
75 | | - FieldConstants.fieldLength - drive.getPose().getX(), |
76 | | - drive.getPose().getY(), |
77 | | - drive.getPose().getRotation()), |
78 | | - new Pose2d( |
79 | | - FieldConstants.fieldLength - FieldConstants.ampCenter.getX(), |
80 | | - FieldConstants.ampCenter.getY() - 0.5, |
81 | | - targetRotation)); |
| 72 | +// pointsToAmp = |
| 73 | +// PathPlannerPath.bezierFromPoses( |
| 74 | +// new Pose2d( |
| 75 | +// FieldConstants.fieldLength - drive.getPose().getX(), |
| 76 | +// drive.getPose().getY(), |
| 77 | +// drive.getPose().getRotation()), |
| 78 | +// new Pose2d( |
| 79 | +// FieldConstants.fieldLength - FieldConstants.ampCenter.getX(), |
| 80 | +// FieldConstants.ampCenter.getY() - 0.5, |
| 81 | +// targetRotation)); |
82 | 82 |
|
83 | | - path = |
84 | | - new PathPlannerPath( |
85 | | - pointsToAmp, |
86 | | - new PathConstraints(3, 3, Units.degreesToRadians(540), Units.degreesToRadians(720)), |
87 | | - new GoalEndState(0, targetRotation, true)); |
88 | | - } |
| 83 | +// path = |
| 84 | +// new PathPlannerPath( |
| 85 | +// pointsToAmp, |
| 86 | +// new PathConstraints(3, 3, Units.degreesToRadians(540), Units.degreesToRadians(720)), |
| 87 | +// new GoalEndState(0, targetRotation, true)); |
| 88 | +// } |
89 | 89 |
|
90 | | - path.preventFlipping = true; |
91 | | - pathCommand = AutoBuilder.followPath(path); |
| 90 | +// path.preventFlipping = true; |
| 91 | +// pathCommand = AutoBuilder.followPath(path); |
92 | 92 |
|
93 | | - pathCommand.initialize(); |
94 | | - } |
| 93 | +// pathCommand.initialize(); |
| 94 | +// } |
95 | 95 |
|
96 | | - // Called every time the scheduler runs while the command is scheduled. |
97 | | - @Override |
98 | | - public void execute() { |
99 | | - pathCommand.execute(); |
100 | | - } |
| 96 | +// // Called every time the scheduler runs while the command is scheduled. |
| 97 | +// @Override |
| 98 | +// public void execute() { |
| 99 | +// pathCommand.execute(); |
| 100 | +// } |
101 | 101 |
|
102 | | - // Called once the command ends or is interrupted. |
103 | | - @Override |
104 | | - public void end(boolean interrupted) { |
105 | | - pathCommand.cancel(); |
106 | | - } |
| 102 | +// // Called once the command ends or is interrupted. |
| 103 | +// @Override |
| 104 | +// public void end(boolean interrupted) { |
| 105 | +// pathCommand.cancel(); |
| 106 | +// } |
107 | 107 |
|
108 | | - // Returns true when the command should end. |
109 | | - @Override |
110 | | - public boolean isFinished() { |
111 | | - return false; |
112 | | - } |
113 | | -} |
| 108 | +// // Returns true when the command should end. |
| 109 | +// @Override |
| 110 | +// public boolean isFinished() { |
| 111 | +// return false; |
| 112 | +// } |
| 113 | +// } |
0 commit comments