Skip to content

Commit

Permalink
trying to add io (unfinished
Browse files Browse the repository at this point in the history
  • Loading branch information
audreypj committed Oct 23, 2023
1 parent 6fb2707 commit 7e2f3ff
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 3 deletions.
30 changes: 28 additions & 2 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@

package frc.robot;

import edu.wpi.first.wpilibj.TimedRobot;
import org.littletonrobotics.junction.LogFileUtil;
import org.littletonrobotics.junction.LoggedRobot;
import org.littletonrobotics.junction.Logger;
import org.littletonrobotics.junction.networktables.NT4Publisher;
import org.littletonrobotics.junction.wpilog.WPILOGReader;
import org.littletonrobotics.junction.wpilog.WPILOGWriter;

import edu.wpi.first.wpilibj.PowerDistribution;
import edu.wpi.first.wpilibj.PowerDistribution.ModuleType;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
Expand All @@ -15,7 +23,7 @@
* the package after creating this project, you must also update the build.gradle file in the
* project.
*/
public class Robot extends TimedRobot {
public class Robot extends LoggedRobot {
private Command autonomousCommand;

private RobotContainer robotContainer;
Expand All @@ -30,6 +38,24 @@ public class Robot extends TimedRobot {
public void robotInit() {
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.

Logger.getInstance().recordMetadata("ProjectName", "MyProject"); // Set a metadata value

if (isReal()) {
Logger.getInstance().addDataReceiver(new WPILOGWriter("/U")); // Log to a USB stick
Logger.getInstance().addDataReceiver(new NT4Publisher()); // Publish data to NetworkTables
new PowerDistribution(1, ModuleType.kRev); // Enables power distribution logging
} else {
setUseTiming(false); // Run as fast as possible
String logPath = LogFileUtil.findReplayLog(); // Pull the replay log from AdvantageScope (or prompt the user)
Logger.getInstance().setReplaySource(new WPILOGReader(logPath)); // Read replay log
Logger.getInstance().addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(logPath, "_sim"))); // Save outputs to a new log
}

// Logger.getInstance().disableDeterministicTimestamps() // See "Deterministic Timestamps" in the "Understanding Data Flow" page
Logger.getInstance().start(); // Start logging! No more data receivers, replay sources, or metadata values may be added.


robotContainer = new RobotContainer();

LiveWindow.disableAllTelemetry();
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/frc/robot/subsystems/DrivebaseSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import static frc.robot.Constants.Drive.*;

import org.littletonrobotics.junction.Logger;

import com.kauailabs.navx.frc.AHRS;
import com.playingwithfusion.TimeOfFlight;
import com.playingwithfusion.TimeOfFlight.RangingMode;
Expand Down Expand Up @@ -61,6 +63,9 @@ public class DrivebaseSubsystem extends SubsystemBase {
// Not mission critical as it "technically" drives fine as of now; but I suspect this is a site
// for future improvements

private final DriveIO io;
private final DriveIOInputsAutoLogged inputs = new DriveIOInputsAutoLogged();

public AdvancedSwerveTrajectoryFollower getFollower() {
return follower;
}
Expand Down Expand Up @@ -150,8 +155,9 @@ private SwerveModule createModule(
}

/** Creates a new DrivebaseSubsystem. */
public DrivebaseSubsystem(VisionSubsystem visionSubsystem) {
public DrivebaseSubsystem(VisionSubsystem visionSubsystem, DriveIO io) {
this.visionSubsystem = visionSubsystem;
this.io = io;

if (!Config.DISABLE_SWERVE_MODULE_INIT) {

Expand Down
41 changes: 41 additions & 0 deletions vendordeps/AdvantageKit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"fileName": "AdvantageKit.json",
"name": "AdvantageKit",
"version": "2.2.4",
"uuid": "d820cc26-74e3-11ec-90d6-0242ac120003",
"mavenUrls": [],
"jsonUrl": "https://github.com/Mechanical-Advantage/AdvantageKit/releases/latest/download/AdvantageKit.json",
"javaDependencies": [
{
"groupId": "org.littletonrobotics.akit.junction",
"artifactId": "wpilib-shim",
"version": "2.2.4"
},
{
"groupId": "org.littletonrobotics.akit.junction",
"artifactId": "junction-core",
"version": "2.2.4"
},
{
"groupId": "org.littletonrobotics.akit.conduit",
"artifactId": "conduit-api",
"version": "2.2.4"
}
],
"jniDependencies": [
{
"groupId": "org.littletonrobotics.akit.conduit",
"artifactId": "conduit-wpilibio",
"version": "2.2.4",
"skipInvalidPlatforms": false,
"isJar": false,
"validPlatforms": [
"linuxathena",
"windowsx86-64",
"linuxx86-64",
"osxuniversal"
]
}
],
"cppDependencies": []
}

0 comments on commit 7e2f3ff

Please sign in to comment.