Skip to content

Commit

Permalink
got rid of robot container again
Browse files Browse the repository at this point in the history
  • Loading branch information
PGgit08 committed Nov 16, 2024
1 parent 331f204 commit 89352ba
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 81 deletions.
2 changes: 2 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Github
- Do this in command line (and push) after adding spotless checking to the github actions `git update-index --chmod=+x ./gradlew`.
42 changes: 31 additions & 11 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,67 @@

package frc.robot;

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

import com.ctre.phoenix6.SignalLogger;
import dev.doglog.DogLog;
import dev.doglog.DogLogOptions;
import edu.wpi.first.epilogue.Epilogue;
import edu.wpi.first.epilogue.Logged;
import edu.wpi.first.epilogue.Logged.Strategy;
import edu.wpi.first.epilogue.NotLogged;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.lib.InputStream;
import frc.robot.Constants.Ports;
import frc.robot.Constants.SwerveConstants;
import frc.robot.commands.Autos;
import frc.robot.generated.TunerConstants;
import frc.robot.subsystems.CommandSwerveDrivetrain;

/**
* The methods in this class are called automatically corresponding to each mode, as described in
* the TimedRobot documentation. If you change the name of this class or the package after creating
* this project, you must also update the Main.java file in the project.
*/
@Logged(strategy = Strategy.OPT_IN)
@Logged
public class Robot extends TimedRobot {
@Logged(name = "Robot Container")
private RobotContainer _robotContainer;
// controllers
private final CommandXboxController _driverController =
new CommandXboxController(Ports.driverController);

// subsystems
@Logged(name = "Swerve")
private CommandSwerveDrivetrain _swerve = TunerConstants.createDrivetrain();

private Command _autonomousCommand;
@NotLogged private Command _autonomousCommand = Autos.none();

/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
public Robot() {
_robotContainer = new RobotContainer();

// set up loggers
DogLog.setOptions(new DogLogOptions().withNtPublish(true));

Epilogue.bind(this);

SignalLogger.start();

DriverStation.silenceJoystickConnectionWarning(RobotBase.isSimulation());

_swerve.setDefaultCommand(
_swerve.drive(
InputStream.of(_driverController::getLeftY)
.negate()
.scale(SwerveConstants.maxTranslationSpeed.in(MetersPerSecond)),
InputStream.of(_driverController::getLeftX)
.negate()
.scale(SwerveConstants.maxTranslationSpeed.in(MetersPerSecond)),
InputStream.of(_driverController::getRightX)
.negate()
.scale(SwerveConstants.maxAngularSpeed.in(RadiansPerSecond))));
}

/**
Expand Down Expand Up @@ -71,8 +93,6 @@ public void disabledPeriodic() {}
/** This autonomous runs the autonomous command. */
@Override
public void autonomousInit() {
_autonomousCommand = _robotContainer.getAutonomousCommand();

// schedule the autonomous command (example)
if (_autonomousCommand != null) {
_autonomousCommand.schedule();
Expand Down
61 changes: 0 additions & 61 deletions src/main/java/frc/robot/RobotContainer.java

This file was deleted.

15 changes: 6 additions & 9 deletions src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,16 @@ public CommandSwerveDrivetrain(

registerTelemetry(
state -> {
DogLog.log("Robot Container/Swerve/Pose", state.Pose);
DogLog.log("Robot Container/Swerve/Speeds", state.Speeds);
DogLog.log(
"Robot Container/Swerve/Desired Speeds",
getKinematics().toChassisSpeeds(state.ModuleTargets));
DogLog.log("Robot Container/Swerve/Module States", state.ModuleStates);
DogLog.log("Robot Container/Swerve/Desired Module States", state.ModuleTargets);
DogLog.log("Swerve/Pose", state.Pose);
DogLog.log("Swerve/Speeds", state.Speeds);
DogLog.log("Swerve/Desired Speeds", getKinematics().toChassisSpeeds(state.ModuleTargets));
DogLog.log("Swerve/Module States", state.ModuleStates);
DogLog.log("Swerve/Desired Module States", state.ModuleTargets);

double totalDaqs = state.SuccessfulDaqs + state.FailedDaqs;
totalDaqs = totalDaqs == 0 ? 1 : totalDaqs;

DogLog.log(
"Robot Container/Swerve/Odometry Success %", state.SuccessfulDaqs / totalDaqs * 100);
DogLog.log("Swerve/Odometry Success %", state.SuccessfulDaqs / totalDaqs * 100);
});

if (RobotBase.isSimulation()) startSimThread();
Expand Down

0 comments on commit 89352ba

Please sign in to comment.