Skip to content
This repository was archived by the owner on Dec 6, 2025. It is now read-only.

Commit 74fe7f4

Browse files
Update vendordeps.
Signed-off-by: thenetworkgrinch <[email protected]>
1 parent de932a4 commit 74fe7f4

File tree

11 files changed

+696
-838
lines changed

11 files changed

+696
-838
lines changed

src/main/deploy/swerve/falcon/swervedrive.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/swervedrive_schema.json",
23
"imu": {
34
"type": "navx",
45
"id": 13,

src/main/deploy/swerve/neo/swervedrive.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/swervedrive_schema.json",
23
"imu": {
34
"type": "pigeon2",
45
"id": 13,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ public void teleopInit()
131131
{
132132
CommandScheduler.getInstance().cancelAll();
133133
}
134-
m_robotContainer.setDriveMode();
135134
}
136135

137136
/**
@@ -147,7 +146,6 @@ public void testInit()
147146
{
148147
// Cancels all running commands at the start of test mode.
149148
CommandScheduler.getInstance().cancelAll();
150-
m_robotContainer.setDriveMode();
151149
}
152150

153151
/**

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ public class RobotContainer
109109

110110
Command driveFieldOrientedDirectAngleSim = drivebase.driveFieldOriented(driveDirectAngleSim);
111111

112+
Command driveFieldOrientedAnglularVelocitySim = drivebase.driveFieldOriented(driveAngularVelocitySim);
113+
112114
Command driveSetpointGenSim = drivebase.driveWithSetpointGeneratorFieldRelative(driveDirectAngleSim);
113115

114116
/**
@@ -133,18 +135,19 @@ private void configureBindings()
133135
{
134136
// (Condition) ? Return-On-True : Return-on-False
135137
drivebase.setDefaultCommand(!RobotBase.isSimulation() ?
136-
driveFieldOrientedDirectAngle :
137-
driveFieldOrientedDirectAngleSim);
138+
driveFieldOrientedAnglularVelocity :
139+
driveFieldOrientedAnglularVelocitySim);
138140

139141
if (Robot.isSimulation())
140142
{
141143
driverXbox.start().onTrue(Commands.runOnce(() -> drivebase.resetOdometry(new Pose2d(3, 3, new Rotation2d()))));
144+
driverXbox.button(1).whileTrue(drivebase.sysIdDriveMotorCommand());
145+
142146
}
143147
if (DriverStation.isTest())
144148
{
145149
drivebase.setDefaultCommand(driveFieldOrientedAnglularVelocity); // Overrides drive command above!
146150

147-
driverXbox.b().whileTrue(drivebase.sysIdDriveMotorCommand());
148151
driverXbox.x().whileTrue(Commands.runOnce(drivebase::lock, drivebase).repeatedly());
149152
driverXbox.y().whileTrue(drivebase.driveToDistanceCommand(1.0, 0.2));
150153
driverXbox.start().onTrue((Commands.runOnce(drivebase::zeroGyro)));
@@ -159,7 +162,6 @@ private void configureBindings()
159162
drivebase.driveToPose(
160163
new Pose2d(new Translation2d(4, 4), Rotation2d.fromDegrees(0)))
161164
);
162-
driverXbox.y().whileTrue(drivebase.aimAtSpeaker(2));
163165
driverXbox.start().whileTrue(Commands.none());
164166
driverXbox.back().whileTrue(Commands.none());
165167
driverXbox.leftBumper().whileTrue(Commands.runOnce(drivebase::lock, drivebase).repeatedly());
@@ -179,11 +181,6 @@ public Command getAutonomousCommand()
179181
return drivebase.getAutonomousCommand("New Auto");
180182
}
181183

182-
public void setDriveMode()
183-
{
184-
configureBindings();
185-
}
186-
187184
public void setMotorBrake(boolean brake)
188185
{
189186
drivebase.setMotorBrake(brake);

src/main/java/frc/robot/subsystems/swervedrive/SwerveSubsystem.java

Lines changed: 36 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import edu.wpi.first.wpilibj2.command.SubsystemBase;
3737
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Config;
3838
import frc.robot.Constants;
39-
import frc.robot.subsystems.swervedrive.Vision.Cameras;
39+
//import frc.robot.subsystems.swervedrive.Vision.Cameras;
4040
import java.io.File;
4141
import java.io.IOException;
4242
import java.util.Arrays;
@@ -45,7 +45,7 @@
4545
import java.util.function.DoubleSupplier;
4646
import java.util.function.Supplier;
4747
import org.json.simple.parser.ParseException;
48-
import org.photonvision.targeting.PhotonPipelineResult;
48+
//import org.photonvision.targeting.PhotonPipelineResult;
4949
import swervelib.SwerveController;
5050
import swervelib.SwerveDrive;
5151
import swervelib.SwerveDriveTest;
@@ -74,7 +74,7 @@ public class SwerveSubsystem extends SubsystemBase
7474
/**
7575
* PhotonVision class to keep an accurate odometry.
7676
*/
77-
private Vision vision;
77+
// private Vision vision;
7878

7979
/**
8080
* Initialize {@link SwerveDrive} with the directory provided.
@@ -83,20 +83,6 @@ public class SwerveSubsystem extends SubsystemBase
8383
*/
8484
public SwerveSubsystem(File directory)
8585
{
86-
// Angle conversion factor is 360 / (GEAR RATIO * ENCODER RESOLUTION)
87-
// In this case the gear ratio is 12.8 motor revolutions per wheel rotation.
88-
// The encoder resolution per motor revolution is 1 per motor revolution.
89-
double angleConversionFactor = SwerveMath.calculateDegreesPerSteeringRotation(12.8);
90-
// Motor conversion factor is (PI * WHEEL DIAMETER IN METERS) / (GEAR RATIO * ENCODER RESOLUTION).
91-
// In this case the wheel diameter is 4 inches, which must be converted to meters to get meters/second.
92-
// The gear ratio is 6.75 motor revolutions per wheel rotation.
93-
// The encoder resolution per motor revolution is 1 per motor revolution.
94-
double driveConversionFactor = SwerveMath.calculateMetersPerRotation(Units.inchesToMeters(4), 6.75);
95-
System.out.println("\"conversionFactors\": {");
96-
System.out.println("\t\"angle\": {\"factor\": " + angleConversionFactor + " },");
97-
System.out.println("\t\"drive\": {\"factor\": " + driveConversionFactor + " }");
98-
System.out.println("}");
99-
10086
// Configure the Telemetry before creating the SwerveDrive to avoid unnecessary objects being created.
10187
SwerveDriveTelemetry.verbosity = TelemetryVerbosity.HIGH;
10288
try
@@ -118,10 +104,10 @@ public SwerveSubsystem(File directory)
118104
0.1); //Correct for skew that gets worse as angular velocity increases. Start with a coefficient of 0.1.
119105
swerveDrive.setModuleEncoderAutoSynchronize(false,
120106
1); // Enable if you want to resynchronize your absolute encoders and motor encoders periodically when they are not moving.
121-
swerveDrive.pushOffsetsToEncoders(); // Set the absolute encoder to be used over the internal encoder and push the offsets onto it. Throws warning if not possible
107+
// swerveDrive.pushOffsetsToEncoders(); // Set the absolute encoder to be used over the internal encoder and push the offsets onto it. Throws warning if not possible
122108
if (visionDriveTest)
123109
{
124-
setupPhotonVision();
110+
// setupPhotonVision();
125111
// Stop the odometry thread if we are using vision that way we can synchronize updates better.
126112
swerveDrive.stopOdometryThread();
127113
}
@@ -143,13 +129,13 @@ public SwerveSubsystem(SwerveDriveConfiguration driveCfg, SwerveControllerConfig
143129
Rotation2d.fromDegrees(0)));
144130
}
145131

146-
/**
147-
* Setup the photon vision class.
148-
*/
149-
public void setupPhotonVision()
150-
{
151-
vision = new Vision(swerveDrive::getPose, swerveDrive.field);
152-
}
132+
// /**
133+
// * Setup the photon vision class.
134+
// */
135+
// public void setupPhotonVision()
136+
// {
137+
// vision = new Vision(swerveDrive::getPose, swerveDrive.field);
138+
// }
153139

154140
@Override
155141
public void periodic()
@@ -158,7 +144,7 @@ public void periodic()
158144
if (visionDriveTest)
159145
{
160146
swerveDrive.updateOdometry();
161-
vision.updatePoseEstimation(swerveDrive);
147+
// vision.updatePoseEstimation(swerveDrive);
162148
}
163149
}
164150

@@ -238,75 +224,29 @@ public void setupPathPlanner()
238224
PathfindingCommand.warmupCommand().schedule();
239225
}
240226

241-
/**
242-
* Get the distance to the speaker.
243-
*
244-
* @return Distance to speaker in meters.
245-
*/
246-
public double getDistanceToSpeaker()
247-
{
248-
int allianceAprilTag = DriverStation.getAlliance().get() == Alliance.Blue ? 7 : 4;
249-
// Taken from PhotonUtils.getDistanceToPose
250-
Pose3d speakerAprilTagPose = aprilTagFieldLayout.getTagPose(allianceAprilTag).get();
251-
return getPose().getTranslation().getDistance(speakerAprilTagPose.toPose2d().getTranslation());
252-
}
253-
254-
/**
255-
* Get the yaw to aim at the speaker.
256-
*
257-
* @return {@link Rotation2d} of which you need to achieve.
258-
*/
259-
public Rotation2d getSpeakerYaw()
260-
{
261-
int allianceAprilTag = DriverStation.getAlliance().get() == Alliance.Blue ? 7 : 4;
262-
// Taken from PhotonUtils.getYawToPose()
263-
Pose3d speakerAprilTagPose = aprilTagFieldLayout.getTagPose(allianceAprilTag).get();
264-
Translation2d relativeTrl = speakerAprilTagPose.toPose2d().relativeTo(getPose()).getTranslation();
265-
return new Rotation2d(relativeTrl.getX(), relativeTrl.getY()).plus(swerveDrive.getOdometryHeading());
266-
}
267-
268-
/**
269-
* Aim the robot at the speaker.
270-
*
271-
* @param tolerance Tolerance in degrees.
272-
* @return Command to turn the robot to the speaker.
273-
*/
274-
public Command aimAtSpeaker(double tolerance)
275-
{
276-
SwerveController controller = swerveDrive.getSwerveController();
277-
return run(
278-
() -> {
279-
ChassisSpeeds speeds = ChassisSpeeds.fromFieldRelativeSpeeds(0, 0,
280-
controller.headingCalculate(getHeading().getRadians(),
281-
getSpeakerYaw().getRadians()),
282-
getHeading());
283-
drive(speeds);
284-
}).until(() -> Math.abs(getSpeakerYaw().minus(getHeading()).getDegrees()) < tolerance);
285-
}
286-
287-
/**
288-
* Aim the robot at the target returned by PhotonVision.
289-
*
290-
* @return A {@link Command} which will run the alignment.
291-
*/
292-
public Command aimAtTarget(Cameras camera)
293-
{
294-
295-
return run(() -> {
296-
Optional<PhotonPipelineResult> resultO = camera.getBestResult();
297-
if (resultO.isPresent())
298-
{
299-
var result = resultO.get();
300-
if (result.hasTargets())
301-
{
302-
drive(getTargetSpeeds(0,
303-
0,
304-
Rotation2d.fromDegrees(result.getBestTarget()
305-
.getYaw()))); // Not sure if this will work, more math may be required.
306-
}
307-
}
308-
});
309-
}
227+
// /**
228+
// * Aim the robot at the target returned by PhotonVision.
229+
// *
230+
// * @return A {@link Command} which will run the alignment.
231+
// */
232+
// public Command aimAtTarget(Cameras camera)
233+
// {
234+
//
235+
// return run(() -> {
236+
// Optional<PhotonPipelineResult> resultO = camera.getBestResult();
237+
// if (resultO.isPresent())
238+
// {
239+
// var result = resultO.get();
240+
// if (result.hasTargets())
241+
// {
242+
// drive(getTargetSpeeds(0,
243+
// 0,
244+
// Rotation2d.fromDegrees(result.getBestTarget()
245+
// .getYaw()))); // Not sure if this will work, more math may be required.
246+
// }
247+
// }
248+
// });
249+
// }
310250

311251
/**
312252
* Get the path follower with events.

0 commit comments

Comments
 (0)