Skip to content

Commit

Permalink
meh
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishan1522 committed Jan 7, 2025
1 parent 53f23aa commit 50e407e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import edu.wpi.first.networktables.NetworkTableEvent.Kind;
import edu.wpi.first.wpilibj.DataLogManager;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import frc.robot.extras.util.Force;

@Logged
public class RepulsorFieldPlanner {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/extras/util/AlertsUtil.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package frc.robot.util;
package frc.robot.extras.util;

import java.util.function.BooleanSupplier;

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/frc/robot/subsystems/swerve/SwerveDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import edu.wpi.first.math.system.plant.DCMotor;
import edu.wpi.first.wpilibj.Alert;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.extras.simulation.mechanismSim.swerve.SwerveModuleSimulation.WHEEL_GRIP;
import frc.robot.extras.swerve.RepulsorFieldPlanner;
import frc.robot.extras.swerve.setpointGen.SwerveSetpoint;
import frc.robot.extras.swerve.setpointGen.SwerveSetpointGenerator;
import frc.robot.extras.util.DeviceCANBus;
Expand All @@ -28,9 +30,13 @@
import frc.robot.subsystems.swerve.odometryThread.OdometryThreadInputsAutoLogged;
import frc.robot.subsystems.vision.VisionConstants;
import java.util.Optional;
import java.util.function.Supplier;

import org.littletonrobotics.junction.AutoLogOutput;
import org.littletonrobotics.junction.Logger;

import choreo.trajectory.SwerveSample;

public class SwerveDrive extends SubsystemBase {
private final GyroInterface gyroIO;
private final GyroInputsAutoLogged gyroInputs;
Expand Down Expand Up @@ -58,6 +64,8 @@ public class SwerveDrive extends SubsystemBase {

private Optional<DriverStation.Alliance> alliance;

private RepulsorFieldPlanner repulsor = new RepulsorFieldPlanner();

private final Alert gyroDisconnectedAlert =
new Alert("Gyro Hardware Fault", Alert.AlertType.kError);

Expand Down Expand Up @@ -203,6 +211,41 @@ xSpeed, ySpeed, rotationSpeed, getOdometryAllianceRelativeRotation2d())
Logger.recordOutput("SwerveStates/DesiredStates", setpoint.moduleStates());
}

/*
* @return The current ChassisSpeeds of the robot.
*/
public ChassisSpeeds getChassisSpeeds() {
return setpoint.chassisSpeeds();
}

// public Command repulsorCommand(Supplier<Pose2d> target) {
// return run(()->{
// repulsor.setGoal(target.get().getTranslation());
// followPath(getPose(), repulsor.getCmd(getPose(), getChassisSpeeds(), 4, true, target.get().getRotation()));
// });
// }

// public void followPath(Pose2d pose, SwerveSample sample) {
// m_pathThetaController.enableContinuousInput(-Math.PI, Math.PI);

// var targetSpeeds = sample.getChassisSpeeds();
// targetSpeeds.vxMetersPerSecond += m_pathXController.calculate(
// pose.getX(), sample.x
// );
// targetSpeeds.vyMetersPerSecond += m_pathYController.calculate(
// pose.getY(), sample.y
// );
// targetSpeeds.omegaRadiansPerSecond += m_pathThetaController.calculate(
// pose.getRotation().getRadians(), sample.heading
// );

// setControl(
// m_pathApplyFieldSpeeds.withSpeeds(targetSpeeds)
// .withWheelForceFeedforwardsX(sample.moduleForcesX())
// .withWheelForceFeedforwardsY(sample.moduleForcesY())
// );
// }

/**
* Returns the heading of the robot in degrees from 0 to 360.
*
Expand Down

0 comments on commit 50e407e

Please sign in to comment.