Skip to content

Commit 0a55205

Browse files
committed
Fixed bugs
1 parent f5cb13a commit 0a55205

File tree

5 files changed

+45
-70
lines changed

5 files changed

+45
-70
lines changed

src/main/java/frc/robot/Autos.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
import frc.robot.subsystems.drive.Drive;
55

66
public class Autos {
7-
AutoFactory autoFactory;
8-
Drive drivesubsystem;
7+
AutoFactory autoFactory;
8+
Drive drivesubsystem;
99

10-
public Autos(
11-
Drive drivesubsystem) {
12-
autoFactory = new AutoFactory(
13-
drivesubsystem::getPose, // A function that returns the current robot pose
14-
drivesubsystem::resetOdometry, // A function that resets the current robot pose to the provided Pose2d
15-
drivesubsystem::followTrajectory, // The drive subsystem trajectory follower
16-
true, // If alliance flipping should be enabled
17-
drivesubsystem, // The drive subsystem
18-
);
10+
public Autos(Drive drivesubsystem) {
11+
autoFactory =
12+
new AutoFactory(
13+
drivesubsystem::getPose, // A function that returns the current robot pose
14+
drivesubsystem
15+
::setPose, // A function that resets the current robot pose to the provided Pose2d
16+
drivesubsystem::followTrajectory, // The drive subsystem trajectory follower
17+
true, // If alliance flipping should be enabled
18+
drivesubsystem // The drive subsystem
19+
);
1920
this.drivesubsystem = drivesubsystem;
2021
}
2122
}

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

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77

88
package frc.robot;
99

10-
10+
import choreo.auto.AutoChooser;
1111
import edu.wpi.first.math.geometry.Pose2d;
1212
import edu.wpi.first.math.geometry.Rotation2d;
1313
import edu.wpi.first.wpilibj.GenericHID;
1414
import edu.wpi.first.wpilibj.XboxController;
15+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1516
import edu.wpi.first.wpilibj2.command.Command;
1617
import edu.wpi.first.wpilibj2.command.Commands;
1718
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
18-
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
19+
import edu.wpi.first.wpilibj2.command.button.RobotModeTriggers;
1920
import frc.robot.commands.DriveCommands;
2021
import frc.robot.generated.TunerConstants;
2122
import frc.robot.subsystems.drive.Drive;
@@ -24,10 +25,6 @@
2425
import frc.robot.subsystems.drive.ModuleIO;
2526
import frc.robot.subsystems.drive.ModuleIOSim;
2627
import frc.robot.subsystems.drive.ModuleIOTalonFX;
27-
import org.littletonrobotics.junction.networktables.LoggedDashboardChooser;
28-
29-
import choreo.auto.AutoChooser;
30-
import choreo.auto.AutoFactory;
3128

3229
/**
3330
* This class is where the bulk of the robot should be declared. Since Command-based is a
@@ -43,8 +40,8 @@ public class RobotContainer {
4340
private final CommandXboxController controller = new CommandXboxController(0);
4441

4542
// Dashboard inputs
46-
// private final LoggedDashboardChooser<Command> autoChooser;
47-
private final AutoChooser autoChooser;
43+
// private final LoggedDashboardChooser<Command> autoChooser;
44+
private final AutoChooser autoChooser;
4845
/** The container for the robot. Contains subsystems, OI devices, and commands. */
4946
public RobotContainer() {
5047
switch (Constants.currentMode) {
@@ -103,23 +100,11 @@ public RobotContainer() {
103100
}
104101

105102
// Set up auto routines
106-
// autoChooser = new LoggedDashboardChooser<>("Auto Choices", AutoFactory.buildAutoChooser());
107-
autoChooser = new AutoChooser();
103+
// autoChooser = new LoggedDashboardChooser<>("Auto Choices", AutoFactory.buildAutoChooser());
104+
autoChooser = new AutoChooser();
108105
// Set up SysId routines
109-
autoChooser.addCmd(
110-
"Drive Wheel Radius Characterization", DriveCommands.wheelRadiusCharacterization(drive));
111-
autoChooser.addCmd(
112-
"Drive Simple FF Characterization", DriveCommands.feedforwardCharacterization(drive));
113-
autoChooser.addOption(
114-
"Drive SysId (Quasistatic Forward)",
115-
drive.sysIdQuasistatic(SysIdRoutine.Direction.kForward));
116-
autoChooser.addOption(
117-
"Drive SysId (Quasistatic Reverse)",
118-
drive.sysIdQuasistatic(SysIdRoutine.Direction.kReverse));
119-
autoChooser.addOption(
120-
"Drive SysId (Dynamic Forward)", drive.sysIdDynamic(SysIdRoutine.Direction.kForward));
121-
autoChooser.addOption(
122-
"Drive SysId (Dynamic Reverse)", drive.sysIdDynamic(SysIdRoutine.Direction.kReverse));
106+
SmartDashboard.putData(autoChooser);
107+
RobotModeTriggers.autonomous().whileTrue(autoChooser.selectedCommandScheduler());
123108

124109
// Configure the button bindings
125110
configureButtonBindings();
@@ -171,6 +156,6 @@ private void configureButtonBindings() {
171156
* @return the command to run in autonomous
172157
*/
173158
public Command getAutonomousCommand() {
174-
return autoChooser.get();
159+
return autoChooser.selectedCommand();
175160
}
176161
}

src/main/java/frc/robot/subsystems/drive/Drive.java

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99

1010
import static edu.wpi.first.units.Units.*;
1111

12-
// import com.pathplanner.lib.auto.AutoBuilder;
13-
// import com.pathplanner.lib.config.ModuleConfig;
14-
// import com.pathplanner.lib.config.PIDConstants;
15-
// import com.pathplanner.lib.config.RobotConfig;
16-
// import com.pathplanner.lib.controllers.PPHolonomicDriveController;
17-
// import com.pathplanner.lib.pathfinding.Pathfinding;
18-
// import com.pathplanner.lib.util.PathPlannerLogging;
12+
import choreo.trajectory.SwerveSample;
1913
import edu.wpi.first.hal.FRCNetComm.tInstances;
2014
import edu.wpi.first.hal.FRCNetComm.tResourceType;
2115
import edu.wpi.first.hal.HAL;
@@ -32,31 +26,26 @@
3226
import edu.wpi.first.math.kinematics.SwerveModuleState;
3327
import edu.wpi.first.math.numbers.N1;
3428
import edu.wpi.first.math.numbers.N3;
35-
import edu.wpi.first.math.system.plant.DCMotor;
3629
import edu.wpi.first.wpilibj.Alert;
3730
import edu.wpi.first.wpilibj.Alert.AlertType;
3831
import edu.wpi.first.wpilibj.DriverStation;
39-
import edu.wpi.first.wpilibj.DriverStation.Alliance;
4032
import edu.wpi.first.wpilibj2.command.Command;
4133
import edu.wpi.first.wpilibj2.command.SubsystemBase;
4234
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
4335
import frc.robot.Constants;
4436
import frc.robot.Constants.Mode;
4537
import frc.robot.generated.TunerConstants;
46-
//import frc.robot.util.LocalADStarAK;
38+
// import frc.robot.util.LocalADStarAK;
4739
import java.util.concurrent.locks.Lock;
4840
import java.util.concurrent.locks.ReentrantLock;
4941
import org.littletonrobotics.junction.AutoLogOutput;
5042
import org.littletonrobotics.junction.Logger;
5143

52-
import choreo.auto.AutoFactory;
53-
import choreo.trajectory.SwerveSample;
54-
5544
public class Drive extends SubsystemBase {
5645
private final PIDController xController = new PIDController(10.0, 0.0, 0.0);
5746
private final PIDController yController = new PIDController(10.0, 0.0, 0.0);
5847
private final PIDController headingController = new PIDController(7.5, 0.0, 0.0);
59-
48+
6049
// TunerConstants doesn't include these constants, so they are declared locally
6150
static final double ODOMETRY_FREQUENCY = TunerConstants.kCANBus.isNetworkFD() ? 250.0 : 100.0;
6251
public static final double DRIVE_BASE_RADIUS =
@@ -117,7 +106,7 @@ public Drive(
117106
modules[1] = new Module(frModuleIO, 1, TunerConstants.FrontRight);
118107
modules[2] = new Module(blModuleIO, 2, TunerConstants.BackLeft);
119108
modules[3] = new Module(brModuleIO, 3, TunerConstants.BackRight);
120-
109+
121110
headingController.enableContinuousInput(-Math.PI, Math.PI);
122111

123112
// Usage reporting for swerve template
@@ -147,7 +136,6 @@ public Drive(
147136
// Logger.recordOutput("Odometry/TrajectorySetpoint", targetPose);
148137
// });
149138

150-
151139
// Configure SysId
152140
sysId =
153141
new SysIdRoutine(
@@ -160,19 +148,18 @@ public Drive(
160148
(voltage) -> runCharacterization(voltage.in(Volts)), null, this));
161149
}
162150

163-
public void followTrajectory(SwerveSample sample) {
164-
// Get the current pose of the robot
165-
Pose2d pose = getPose();
151+
public void followTrajectory(SwerveSample sample) {
152+
// Get the current pose of the robot
153+
Pose2d pose = getPose();
166154

167-
// Generate the next speeds for the robot
168-
ChassisSpeeds speeds = new ChassisSpeeds(
155+
// Generate the next speeds for the robot
156+
ChassisSpeeds speeds =
157+
new ChassisSpeeds(
169158
sample.vx + xController.calculate(pose.getX(), sample.x),
170159
sample.vy + yController.calculate(pose.getY(), sample.y),
171-
sample.omega + headingController.calculate(pose.getRotation().getRadians(), sample.heading)
172-
);
173-
174-
175-
}
160+
sample.omega
161+
+ headingController.calculate(pose.getRotation().getRadians(), sample.heading));
162+
}
176163

177164
@Override
178165
public void periodic() {

src/main/java/frc/robot/util/LocalADStarAK.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
// /**
8383
// * Set the goal position to pathfind to
8484
// *
85-
// * @param goalPosition Goal position on the field. f this is within an obstacle it will be moved
85+
// * @param goalPosition Goal position on the field. f this is within an obstacle it will be
86+
// moved
8687
// * to the nearest non-obstacle node.
8788
// */
8889
// @Override
@@ -95,7 +96,8 @@
9596
// /**
9697
// * Set the dynamic obstacles that should be avoided while pathfinding.
9798
// *
98-
// * @param obs A List of Translation2d pairs representing obstacles. Each Translation2d represents
99+
// * @param obs A List of Translation2d pairs representing obstacles. Each Translation2d
100+
// represents
99101
// * opposite corners of a bounding box.
100102
// * @param currentRobotPos The current position of the robot. This is needed to change the start
101103
// * position of the path to properly avoid obstacles

vendordeps/photonlib.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"fileName": "photonlib.json",
33
"name": "photonlib",
4-
"version": "v2026.1.1-rc-3",
4+
"version": "v2026.1.1",
55
"uuid": "515fe07e-bfc6-11fa-b3de-0242ac130004",
66
"frcYear": "2026",
77
"mavenUrls": [
@@ -13,7 +13,7 @@
1313
{
1414
"groupId": "org.photonvision",
1515
"artifactId": "photontargeting-cpp",
16-
"version": "v2026.1.1-rc-3",
16+
"version": "v2026.1.1",
1717
"skipInvalidPlatforms": true,
1818
"isJar": false,
1919
"validPlatforms": [
@@ -28,7 +28,7 @@
2828
{
2929
"groupId": "org.photonvision",
3030
"artifactId": "photonlib-cpp",
31-
"version": "v2026.1.1-rc-3",
31+
"version": "v2026.1.1",
3232
"libName": "photonlib",
3333
"headerClassifier": "headers",
3434
"sharedLibrary": true,
@@ -43,7 +43,7 @@
4343
{
4444
"groupId": "org.photonvision",
4545
"artifactId": "photontargeting-cpp",
46-
"version": "v2026.1.1-rc-3",
46+
"version": "v2026.1.1",
4747
"libName": "photontargeting",
4848
"headerClassifier": "headers",
4949
"sharedLibrary": true,
@@ -60,12 +60,12 @@
6060
{
6161
"groupId": "org.photonvision",
6262
"artifactId": "photonlib-java",
63-
"version": "v2026.1.1-rc-3"
63+
"version": "v2026.1.1"
6464
},
6565
{
6666
"groupId": "org.photonvision",
6767
"artifactId": "photontargeting-java",
68-
"version": "v2026.1.1-rc-3"
68+
"version": "v2026.1.1"
6969
}
7070
]
7171
}

0 commit comments

Comments
 (0)