diff --git a/build.gradle b/build.gradle index 6fa8d95c..c2b8440b 100644 --- a/build.gradle +++ b/build.gradle @@ -144,6 +144,20 @@ allprojects { // REV maven { url = uri('https://maven.revrobotics.com/') } + + // AdvantageKit + maven { + url = uri("https://maven.pkg.github.com/Mechanical-Advantage/AdvantageKit") + credentials { + username = "Mechanical-Advantage-Bot" + password = "\u0067\u0068\u0070\u005f\u006e\u0056\u0051\u006a\u0055\u004f\u004c\u0061\u0079\u0066\u006e\u0078\u006e\u0037\u0051\u0049\u0054\u0042\u0032\u004c\u004a\u006d\u0055\u0070\u0073\u0031\u006d\u0037\u004c\u005a\u0030\u0076\u0062\u0070\u0063\u0051" + } + } + } + + //AdvantageKit code + configurations.all { + exclude group: "edu.wpi.first.wpilibj" } } diff --git a/src/main/java/com/team766/hal/wpilib/RobotMain.java b/src/main/java/com/team766/hal/wpilib/RobotMain.java index e928f7a1..e228873c 100755 --- a/src/main/java/com/team766/hal/wpilib/RobotMain.java +++ b/src/main/java/com/team766/hal/wpilib/RobotMain.java @@ -4,16 +4,21 @@ //import java.nio.file.Files; import java.nio.file.Path; import java.util.function.Supplier; +import org.littletonrobotics.junction.LoggedRobot; +import org.littletonrobotics.junction.Logger; +import org.littletonrobotics.junction.networktables.NT4Publisher; +import org.littletonrobotics.junction.wpilog.WPILOGWriter; import com.team766.config.ConfigFileReader; import com.team766.framework.Scheduler; import com.team766.hal.GenericRobotMain; import com.team766.hal.RobotProvider; import com.team766.logging.LoggerExceptionUtils; import edu.wpi.first.wpilibj.Filesystem; +import edu.wpi.first.wpilibj.PowerDistribution; import edu.wpi.first.wpilibj.RobotBase; -import edu.wpi.first.wpilibj.TimedRobot; +import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; -public class RobotMain extends TimedRobot { +public class RobotMain extends LoggedRobot { // this file, if present, will be a symlink to one of several config files in the deploy directory. // this allows for the same code to be deployed to multiple physical robots, each with their own // config file with CAN bus port mappings, etc, with the actual file used for a specific robot @@ -81,6 +86,17 @@ public void robotInit() { RobotProvider.instance = new WPIRobotProvider(); robot = new GenericRobotMain(); + 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 { + // TODO: add support for simulation logging/replay + } + + Logger.getInstance().start(); + robot.robotInit(); } catch (Exception e) { e.printStackTrace(); diff --git a/vendordeps/AdvantageKit.json b/vendordeps/AdvantageKit.json new file mode 100644 index 00000000..fa08705a --- /dev/null +++ b/vendordeps/AdvantageKit.json @@ -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": [] +} \ No newline at end of file