Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ out/
# Simulation GUI and other tools window save file
networktables.json
simgui.json
simgui-ds.json
*-window.json

# Simulation data log directory
Expand Down
2 changes: 1 addition & 1 deletion .wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2027_alpha5",
"projectYear": "2027_alpha7",
"teamNumber": 1138
}
39 changes: 20 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id "java"
id "org.wpilib.GradleRIO" version "2027.0.0-alpha-6"
id "com.gradleup.shadow" version "9.3.0"
id "application"
id "org.wpilib.GradleRIO" version "2027.0.0-alpha-7"
}

java {
Expand All @@ -18,8 +18,6 @@ deploy {
systemcore(getTargetTypeClass('SystemCore')) {
// Team number is loaded either from the .wpilib/wpilib_preferences.json
// or from command line. If not found an exception will be thrown.
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
// want to store a team number in this file.
team = project.wpilib.getTeamNumber()
// Use the default systemcore host name. This must be called after setting team
// as happens on the line above
Expand All @@ -31,6 +29,9 @@ deploy {
// getTargetTypeClass is a shortcut to get the class type using a string

wpilibJava(getArtifactTypeClass('WPILibJavaArtifact')) {
// Set to true to use debug including JNI, which will drastically impact
// performance.
debugJni = false
}

// Static files artifact
Expand All @@ -47,9 +48,8 @@ deploy {

def deployArtifact = deploy.targets.systemcore.artifacts.wpilibJava

// Set to true to use debug for all targets including JNI, which will drastically impact
// performance.
wpi.java.debugJni = false
// Set to true to use debug for simulation including JNI
wpi.java.runSimWithDebugJni = false

// Set this to true to enable desktop support.
def includeDesktopSupport = false
Expand Down Expand Up @@ -77,6 +77,12 @@ dependencies {

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// AdvantageKit's @AutoLog annotation processor. Version is read from the vendordep so the
// two can never drift apart.
def akitJson = new groovy.json.JsonSlurper()
.parseText(new File(projectDir, "vendordeps/AdvantageKit.json").text)
annotationProcessor "org.littletonrobotics.akit:akit-autolog:$akitJson.version"
}

test {
Expand All @@ -88,23 +94,18 @@ test {
wpi.sim.addGui().defaultEnabled = true
wpi.sim.addDriverstation()

// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat/shaded jar')
// in order to make them all available at runtime and merging service files to make JSON work.
// Also adding the manifest so WPILib knows where to look for our Robot Class.
shadowJar {
mergeServiceFiles()
application.mainClass = ROBOT_MAIN_CLASS

deployArtifact.configureApplication(application)
wpi.java.configureApplication(application)
wpi.java.configureTestTasks(test)

jar {
from('src') { into 'backup/src' }
from('vendordeps') { into 'backup/vendordeps' }
from('build.gradle') { into 'backup' }
manifest org.wpilib.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

// Configure jar and deploy tasks
deployArtifact.jarTask = shadowJar
wpi.java.configureExecutableTasks(shadowJar)
wpi.java.configureTestTasks(test)

// Configure string concat to always inline compile
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
23 changes: 16 additions & 7 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,28 @@ import org.gradle.internal.os.OperatingSystem

pluginManagement {
repositories {
String wpilibYear = '2027_alpha5'
String wpilibYear = '2027_alpha7'
File wpilibHome
if (OperatingSystem.current().isWindows()) {
def os = OperatingSystem.current()
if (os.isWindows()) {
String publicFolder = System.getenv('PUBLIC')
if (publicFolder == null) {
publicFolder = "C:\\Users\\Public"
}
def homeRoot = new File(publicFolder, "wpilib")
wpilibHome = new File(homeRoot, wpilibYear)
wpilibHome = new File(new File(publicFolder, "wpilib"), wpilibYear)
} else if (os.isLinux()) {
String xdgDataHome = System.getenv('XDG_DATA_HOME')
if (xdgDataHome == null || xdgDataHome.trim().isEmpty() || !new File(xdgDataHome).isAbsolute()) {
xdgDataHome = new File(System.getProperty("user.home"), ".local/share").getPath()
}
wpilibHome = new File(new File(xdgDataHome, "wpilib"), wpilibYear)
} else {
def userFolder = System.getProperty("user.home")
def homeRoot = new File(userFolder, "wpilib")
wpilibHome = new File(homeRoot, wpilibYear)
def userFolder = new File(System.getProperty("user.home"))
// The macOS installer has used both ~/.wpilib and ~/wpilib across alphas.
wpilibHome = new File(new File(userFolder, ".wpilib"), wpilibYear)
if (!wpilibHome.exists()) {
wpilibHome = new File(new File(userFolder, "wpilib"), wpilibYear)
}
}
def wpilibHomeMaven = new File(wpilibHome, 'maven')
maven {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/first/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ private Main() {}
* <p>If you change your main robot class, change the parameter type.
*/
public static void main(String... args) {
RobotBase.startRobot(first.robot.Robot.class);
RobotBase.startRobot(first.robot.Robot::new);
}
}
93 changes: 85 additions & 8 deletions src/main/java/first/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,93 @@

package first.robot;

import org.wpilib.framework.RobotBase;
import org.wpilib.util.Alert;
import org.wpilib.util.Alert.Level;

/**
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
* constants. This class should not be used for any other purpose. All constants should be declared
* globally (i.e. public static). Do not put anything functional in this class.
*
* <p>It is advised to statically import this class (or one of its inner classes) wherever the
* constants are needed, to reduce verbosity.
* This class defines the runtime mode used by AdvantageKit. The mode is always "real" when running
* on SystemCore. Change the value of {@link #simMode} to switch between "sim" (physics sim) and
* "replay" (log replay from a file).
*/
public final class Constants {
public static class OperatorConstants {
public static final int kDriverControllerPort = 0;
/**
* Robot loop period. This is handed to {@code LoggedRobot} in {@link Robot}, so the value used
* for velocity discretization and Phoenix status frame rates always matches the real loop rate.
*/
public static final double loopPeriodSecs = 0.02;

/** Which physical robot the code is running on. Selects hardware IDs. */
private static RobotType robotType = RobotType.DEVBOT;

/** Enables tuning dashboard inputs. Must be false when merging. */
public static final boolean tuningMode = false;

/** Mode used when not running on real hardware. Set to REPLAY to replay a log instead. */
public static final Mode simMode = Mode.SIM;

@SuppressWarnings("resource")
public static RobotType getRobot() {
if (!disableHAL && RobotBase.isReal() && robotType == RobotType.SIMBOT) {
new Alert(
"invalidRobotType",
"Invalid robot selected, using competition robot as default.",
Level.MEDIUM)
.set(true);
robotType = RobotType.DEVBOT;
}
return robotType;
}

/**
* Returns the current runtime mode. Real hardware is always {@link Mode#REAL}; off-robot this
* follows {@link #simMode} so that the physics simulation actually runs by default.
*/
public static Mode getMode() {
return RobotBase.isReal() ? Mode.REAL : simMode;
}

public enum Mode {
/** Running on a real robot. */
REAL,

/** Running a physics simulator. */
SIM,

/** Replaying from a log file. */
REPLAY
}

public enum RobotType {
DEVBOT,
SIMBOT
}

public static boolean disableHAL = false;

public static void disableHAL() {
disableHAL = true;
}

/** Checks whether the correct robot is selected when deploying. */
public static class CheckDeploy {
public static void main(String... args) {
if (robotType == RobotType.SIMBOT) {
System.err.println("Cannot deploy, invalid robot selected: " + robotType);
System.exit(1);
}
}
}

/** Checks that the default robot is selected and tuning mode is disabled. */
public static class CheckPullRequest {
public static void main(String... args) {
if (robotType != RobotType.DEVBOT || tuningMode) {
System.err.println("Do not merge, non-default constants are configured.");
System.exit(1);
}
}
}

private Constants() {}
}
Loading