Skip to content

Commit

Permalink
akit to main (#299)
Browse files Browse the repository at this point in the history
this pr is so absurdly far out of scope i think its about time we take him behind the barn
  • Loading branch information
Oliver-Cushman authored Sep 26, 2024
2 parents 4e951a9 + 00de768 commit a4634dc
Show file tree
Hide file tree
Showing 53 changed files with 1,408 additions and 630 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This gitignore has been specially created by the WPILib team.
# If you remove items from this file, intellisense might break.

BuildConstants.java

### C++ ###
# Prerequisites
*.d
Expand Down
36 changes: 36 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "com.peterabeles.gversion" version "1.10"
}

repositories {
Expand All @@ -17,6 +18,7 @@ def ROBOT_MAIN_CLASS = "frc.robot.Main"
// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project DeployUtils.
deploy {

targets {
roborio(getTargetTypeClass('RoboRIO')) {
// Team number is loaded either from the .wpilib/wpilib_preferences.json
Expand Down Expand Up @@ -72,6 +74,9 @@ dependencies {
simulationRelease wpi.sim.enableRelease()

implementation 'com.github.shueja:Monologue:v1.0.0-beta6'

def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text)
annotationProcessor "org.littletonrobotics.akit.junction:junction-autolog:$akitJson.version"
}

test {
Expand Down Expand Up @@ -102,3 +107,34 @@ wpi.java.configureTestTasks(test)
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}

repositories {
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"
}
}
mavenLocal()
}

configurations.all {
exclude group: "edu.wpi.first.wpilibj"
}

task(checkAkitInstall, dependsOn: "classes", type: JavaExec) {
mainClass = "org.littletonrobotics.junction.CheckInstall"
classpath = sourceSets.main.runtimeClasspath
}
compileJava.finalizedBy checkAkitInstall

project.compileJava.dependsOn(createVersionFile)
gversion {
srcDir = "src/main/java/"
classPackage = "frc.robot"
className = "BuildConstants"
dateFormat = "yyyy-MM-dd HH:mm:ss z"
timeZone = "America/Los_Angeles" // Use preferred time zone
indent = " "
}
12 changes: 6 additions & 6 deletions src/main/deploy/pathplanner/paths/S W3 New.path
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
},
{
"anchor": {
"x": 2.4787036360186945,
"y": 4.168998797124134
"x": 2.4553382440098215,
"y": 4.4758132069455625
},
"prevControl": {
"x": 2.317048184821597,
"y": 3.8636496115296164
"x": 2.293682792812724,
"y": 4.170464021351045
},
"nextControl": {
"x": 2.602808341115003,
"y": 4.403418795639383
"x": 2.57944294910613,
"y": 4.710233205460812
},
"isLocked": false,
"linkedName": "W3 Pickup"
Expand Down
34 changes: 17 additions & 17 deletions src/main/deploy/pathplanner/paths/S W3-1 Bayou.path
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
},
{
"anchor": {
"x": 2.4787036360186945,
"y": 4.168998797124134
"x": 2.4553382440098215,
"y": 4.4758132069455625
},
"prevControl": {
"x": 2.2313539056437075,
"y": 3.9274690604050284
"x": 2.2079885136348345,
"y": 4.2342834702264565
},
"nextControl": {
"x": 2.8694036335441093,
"y": 4.5505058535313045
"x": 2.8460382415352363,
"y": 4.857320263352733
},
"isLocked": false,
"linkedName": "W3 Pickup"
},
{
"anchor": {
"x": 2.377581283717999,
"y": 5.35
"x": 2.0113957958412367,
"y": 5.378253593386619
},
"prevControl": {
"x": 1.5110766903129929,
"y": 5.274190671183922
"x": 1.145914832282723,
"y": 5.291535853302232
},
"nextControl": {
"x": 3.051687332769572,
"y": 5.408976637306263
"x": 3.1606075951005406,
"y": 5.4934000313860505
},
"isLocked": false,
"linkedName": null
Expand All @@ -63,17 +63,17 @@
"rotationTargets": [
{
"waypointRelativePos": 0.7,
"rotationDegrees": 146.64239816427872,
"rotationDegrees": 158.25924699388764,
"rotateFast": false
},
{
"waypointRelativePos": 1.7999999999999998,
"rotationDegrees": -177.54423533374379,
"rotationDegrees": 170.6683195762387,
"rotateFast": false
},
{
"waypointRelativePos": 2.55,
"rotationDegrees": -159.93962834871448,
"rotationDegrees": -146.99446263627644,
"rotateFast": false
}
],
Expand All @@ -95,7 +95,7 @@
"maxWaypointRelativePos": 0.5499999999999999,
"constraints": {
"maxVelocity": 5.0,
"maxAcceleration": 3.0,
"maxAcceleration": 2.7,
"maxAngularVelocity": 1137.21,
"maxAngularAcceleration": 1492.9
}
Expand Down Expand Up @@ -150,7 +150,7 @@
},
"goalEndState": {
"velocity": 0,
"rotation": -149.36,
"rotation": -156.9427737708922,
"rotateFast": false
},
"reversed": false,
Expand Down
38 changes: 35 additions & 3 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

import java.util.Optional;

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 org.littletonrobotics.urcl.URCL;

import edu.wpi.first.wpilibj.DataLogManager;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.RobotController;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import frc.robot.util.Constants.AutoConstants;
import frc.robot.util.Constants.DriveConstants;
import frc.robot.util.Constants.FieldConstants;
import frc.robot.util.Constants.NeoMotorConstants;
import frc.robot.util.Constants.LoggingConstants;
import frc.robot.util.rev.Neo;
import frc.robot.util.rev.NeoPhysicsSim;
import monologue.Monologue;
Expand All @@ -28,7 +35,7 @@
* build.gradle file in the
* project.
*/
public class Robot extends TimedRobot {
public class Robot extends LoggedRobot {

private static Optional<Alliance> alliance = Optional.empty();
public static GameMode gameMode = GameMode.DISABLED;
Expand All @@ -48,8 +55,33 @@ public static enum GameMode {

@Override
public void robotInit() {

// Git metadata for tracking version for AKit
Logger.recordMetadata("ProjectName", BuildConstants.MAVEN_NAME);
Logger.recordMetadata("BuildDate", BuildConstants.BUILD_DATE);
Logger.recordMetadata("GitSHA", BuildConstants.GIT_SHA);
Logger.recordMetadata("GitDate", BuildConstants.GIT_DATE);
Logger.recordMetadata("GitBranch", BuildConstants.GIT_BRANCH);

switch (LoggingConstants.getMode()) {
case REAL:
Logger.addDataReceiver(new WPILOGWriter("/media/sda1/logs")); // Log to a USB stick ("/U/logs")
Logger.addDataReceiver(new NT4Publisher()); // Publish data to NetworkTables
break;
case REPLAY:
String logPath = LogFileUtil.findReplayLog(); // Pull the replay log from AdvantageScope (or prompt the user)
Logger.setReplaySource(new WPILOGReader(logPath)); // Read replay log
Logger.addDataReceiver(new WPILOGWriter(LogFileUtil
.addPathSuffix(logPath, "_sim"))); // Save outputs to a new log
break;
case SIM:
Logger.addDataReceiver(new NT4Publisher()); // Publish data to NetworkTables
break;
}

Logger.start();

robotContainer = new RobotContainer();
Monologue.setupMonologue(robotContainer, "Robot/Draggables", false, true);

DataLogManager.start();
DataLogManager.logNetworkTables(true);
Expand Down
Loading

0 comments on commit a4634dc

Please sign in to comment.