Skip to content

Commit

Permalink
Finish teleop swerve
Browse files Browse the repository at this point in the history
  • Loading branch information
twangodev committed Mar 2, 2024
1 parent b55720d commit 90b5fd8
Show file tree
Hide file tree
Showing 51 changed files with 5,840 additions and 396 deletions.
2 changes: 1 addition & 1 deletion .run/Build Robot.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" />
<option name="scriptParameters" value="--stacktrace" />
<option name="taskDescriptions">
<list />
</option>
Expand Down
10 changes: 5 additions & 5 deletions .wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2024",
"teamNumber": 2204
}
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2024",
"teamNumber": 2204
}
92 changes: 89 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import groovy.json.JsonSlurper

plugins {
id "java"
id "org.jetbrains.kotlin.jvm" version "1.9.22"
id "edu.wpi.first.GradleRIO" version "2024.1.1"
id "edu.wpi.first.GradleRIO" version "2024.3.1"
id "com.peterabeles.gversion" version "1.10.2"
id "com.diffplug.spotless" version "6.25.0"
id "idea"
}

Expand Down Expand Up @@ -52,6 +55,29 @@ wpi.java.debugJni = false
// Set this to true to enable desktop support.
def includeDesktopSupport = true

// Configuration for AdvantageKit
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

dependencies {
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()
Expand All @@ -70,6 +96,9 @@ dependencies {
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()

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

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

testImplementation platform("org.junit:junit-bom:5.10.1")
Expand All @@ -91,7 +120,11 @@ wpi.sim.addDriverstation()
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
}
from sourceSets.main.allSource
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
duplicatesStrategy = DuplicatesStrategy.INCLUDE
Expand Down Expand Up @@ -127,4 +160,57 @@ idea {
// Exclude the .vscode directory from indexing and search
excludeDirs+=file(".vscode" )
}
}
}

// Create version file
project.compileJava.dependsOn(createVersionFile)
gversion {
srcDir = "src/main/java/"
classPackage = "org.rambots"
className = "BuildConstants"
dateFormat = "yyyy-MM-dd HH:mm:ss z"
timeZone = "America/Los_Angeles"
indent = " "
}

// Spotless formatting
project.compileJava.dependsOn(spotlessApply)
spotless {
java {
target fileTree(".") {
include "**/*.java"
exclude "**/build/**", "**/build-*/**"
}
toggleOffOn()
googleJavaFormat()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
groovyGradle {
target fileTree(".") {
include "**/*.gradle"
exclude "**/build/**", "**/build-*/**"
}
greclipse()
indentWithSpaces(4)
trimTrailingWhitespace()
endWithNewline()
}
json {
target fileTree(".") {
include "**/*.json"
exclude "**/build/**", "**/build-*/**"
}
gson().indentWithSpaces(2)
}
format "misc", {
target fileTree(".") {
include "**/*.md", "**/.gitignore"
exclude "**/build/**", "**/build-*/**"
}
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
1 change: 1 addition & 0 deletions networktables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
98 changes: 98 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
],
"robotJoysticks": [
{
"guid": "78696e70757401000000000000000000",
"useGamepad": true
}
]
}
12 changes: 12 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo",
"/SmartDashboard/Auto Choices": "String Chooser",
"/SmartDashboard/VisionSystemSim-main/Sim Field": "Field2d"
}
},
"NetworkTables Info": {
"visible": true
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/rambots/BuildConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.rambots;

/** Automatically generated file containing build version information. */
public final class BuildConstants {
public static final String MAVEN_GROUP = "";
public static final String MAVEN_NAME = "frc-2024";
public static final String VERSION = "unspecified";
public static final int GIT_REVISION = 1;
public static final String GIT_SHA = "b55720df88c29f28dfcd9e76a0256378797c67ac";
public static final String GIT_DATE = "2024-01-12 08:28:13 PST";
public static final String GIT_BRANCH = "james/swerve";
public static final String BUILD_DATE = "2024-03-02 15:32:31 PST";
public static final long BUILD_UNIX_TIME = 1709422351326L;
public static final int DIRTY = 1;

private BuildConstants() {}
}
72 changes: 72 additions & 0 deletions src/main/java/org/rambots/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright 2021-2024 FRC 6328
// http://github.com/Mechanical-Advantage
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 3 as published by the Free Software Foundation or
// available in the root directory of this project.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

package org.rambots;

import edu.wpi.first.wpilibj.RobotBase;
import org.rambots.util.Alert;

/**
* 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.
*/
public final class Constants {
public static final int loopPeriodMs = 20;
private static RobotType robotType = RobotType.SIMBOT;
public static final boolean tuningMode = true;
public static final boolean characterizationMode = false;

public static RobotType getRobot() {
if (RobotBase.isReal() && robotType == RobotType.SIMBOT) {
new Alert("Invalid Robot Selected, using COMPBOT as default", Alert.AlertType.ERROR)
.set(true);
robotType = RobotType.COMPBOT;
}
return robotType;
}

public static Mode getMode() {
return switch (getRobot()) {
case COMPBOT -> RobotBase.isReal() ? Mode.REAL : Mode.REPLAY;
case SIMBOT -> Mode.SIM;
};
}

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

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

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

public enum RobotType {
SIMBOT,
COMPBOT
}

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

0 comments on commit 90b5fd8

Please sign in to comment.