Skip to content

2025 - draft #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
517ae75
initial
FriedLongJohns Jan 12, 2025
d279fe3
fix swerve stuff
FriedLongJohns Jan 13, 2025
c52cbd7
that wasn't supposed to be commented out!
FriedLongJohns Jan 13, 2025
5d10c7f
make it build (when tests excluded)
FriedLongJohns Jan 15, 2025
67bac62
update swerve modueljava
sofiebudman Feb 8, 2025
8ad7479
0
sofiebudman Feb 8, 2025
987fb94
d
sofiebudman Feb 8, 2025
b546166
d
sofiebudman Feb 8, 2025
256b86c
s
sofiebudman Feb 8, 2025
c782a71
remove comment
FriedLongJohns Feb 8, 2025
b712b84
remove space
FriedLongJohns Feb 8, 2025
8d0248d
dubious fixes
FriedLongJohns Feb 8, 2025
f6017cb
revert gradle to before initial commit
FriedLongJohns Feb 9, 2025
e3f8b5c
delete lib199/path*
FriedLongJohns Feb 9, 2025
d7f6b9b
check raw bits instead of pointer values
FriedLongJohns Feb 9, 2025
193cd3f
add baseSparkConfig and deriatives
FriedLongJohns Feb 9, 2025
0e27e13
update calculateWithVelocities
FriedLongJohns Feb 9, 2025
dbfca96
factor in antiGravitationalAcceleration into drivePeriodic
FriedLongJohns Feb 11, 2025
a7a4b9b
add comments to baseSparkXConfig methods
FriedLongJohns Feb 11, 2025
90fc642
remove dummySparkMaxAnswer
FriedLongJohns Feb 16, 2025
f140495
fix and apply drive pos/vel constants
FriedLongJohns Feb 16, 2025
9646d2a
bring back sim support
FriedLongJohns Feb 16, 2025
589ae57
update createDummySparkMax
FriedLongJohns Feb 16, 2025
c13146d
fix average depth not being gotten correctly
FriedLongJohns Feb 16, 2025
bc5e330
put encoder back
FriedLongJohns Feb 18, 2025
32da183
simplify sparkmax factory
FriedLongJohns Mar 5, 2025
7fc3dd2
mae confiogs public
DriverStationComputer Mar 15, 2025
57a5d84
fix sparkflex constructor
FriedLongJohns Mar 30, 2025
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
2 changes: 1 addition & 1 deletion WPILib-License.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2009-2023 FIRST and other WPILib contributors
Copyright (c) 2009-2024 FIRST and other WPILib contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
36 changes: 20 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.3.1"
id "edu.wpi.first.GradleRIO" version "2025.2.1"
id "maven-publish"
id "eclipse"
}
Expand All @@ -11,7 +11,6 @@ java {
}

group 'org.carlmontrobotics'

def ROBOT_MAIN_CLASS = ""

// Define my targets (RoboRIO) and artifacts (deployable files)
Expand All @@ -37,6 +36,8 @@ deploy {
frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) {
files = project.fileTree('src/main/deploy')
directory = '/home/lvuser/deploy'
deleteOldFiles = false // Change to true to delete files on roboRIO that no
// longer exist in deploy directory of this project
}
}
}
Expand All @@ -54,6 +55,7 @@ def includeDesktopSupport = true
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 5.
dependencies {
annotationProcessor wpi.java.deps.wpilibAnnotations()
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()

Expand All @@ -71,27 +73,30 @@ dependencies {
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()

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

implementation 'org.mockito:mockito-core:5.11.0'
implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.6'
}

test {
useJUnitPlatform()
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
}

// Simulation configuration (e.g. environment variables).
wpi.sim.addGui().defaultEnabled = true
wpi.sim.addDriverstation()

// Setting up my Jar File.
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
jar {
// Note: Do NOT add all the libraries to the jar. Doing so will cause robot programs to have
// 2 copies of each of the libraries classes, one from lib199 and one from the robot program.
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from sourceSets.main.allSource

// Add the manifest so WPILib knows where to look for our Robot Class.
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)

// There shouldn't be any duplicate classes.
duplicatesStrategy = DuplicatesStrategy.FAIL
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

publishing {
Expand All @@ -111,11 +116,6 @@ deployArtifact.jarTask = jar
wpi.java.configureExecutableTasks(jar)
wpi.java.configureTestTasks(test)

// Configure string concat to always inline compile
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}

// Allow the generated javadocs to link to the documentation of WPILib and vendor libraries
javadoc {
options.with {
Expand All @@ -129,3 +129,7 @@ javadoc {
}
}

// Configure string concat to always inline compile
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=permwrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
6 changes: 3 additions & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
String frcYear = '2024'
String frcYear = '2025'
File frcHome
if (OperatingSystem.current().isWindows()) {
String publicFolder = System.getenv('PUBLIC')
Expand All @@ -20,8 +20,8 @@ pluginManagement {
}
def frcHomeMaven = new File(frcHome, 'maven')
maven {
name 'frcHome'
url frcHomeMaven
name = 'frcHome'
url = frcHomeMaven
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/carlmontrobotics/lib199/CachedSparkMax.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.carlmontrobotics.lib199;

import com.revrobotics.CANSparkMax;
import com.revrobotics.RelativeEncoder;
import com.revrobotics.SparkPIDController;
import com.revrobotics.spark.SparkClosedLoopController;
import com.revrobotics.spark.SparkMax;

@Deprecated
public class CachedSparkMax extends CANSparkMax {
public class CachedSparkMax extends SparkMax {

private RelativeEncoder encoder;
private SparkPIDController pidController;
private SparkClosedLoopController pidController;

public CachedSparkMax(int deviceId, MotorType type) {
super(deviceId, type);
Expand All @@ -22,8 +22,8 @@ public RelativeEncoder getEncoder() {
}

@Override
public SparkPIDController getPIDController() {
return pidController == null ? (pidController = super.getPIDController()) : pidController;
public SparkClosedLoopController getClosedLoopController() {
return pidController == null ? (pidController = super.getClosedLoopController()) : pidController;
}

}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some additional work probably has to be done here to make sure all types/methods are covered. At a glance, I don't see Faults implemented, but there are probably others. Given all the other changes, it's probably also worthwhile to see if Rev's fixed the crash when controller doesn't exist bug so we can get rid of this class too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can I test this?
as far as I know, sim motors are automatically given controllers and I'm not sure how to remove them.

...or do I have to run the robot and rip out the wires while it's running?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The basic test procedure is:

  1. Unplug all Spark Max/Flex devices from the test board
  2. Write some code that attempts to drive a Spark Max/Flex
  3. Deploy and Run

In the past, this caused the code to crash, which is why we created this class. Hopefully, they've fixed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update: it appears to work without crash!
Unsure what I'd need to modify to remove this class, however. I'll take a look at it.

Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.carlmontrobotics.lib199;

import com.revrobotics.CANSparkMax;
import com.revrobotics.RelativeEncoder;
import com.revrobotics.SparkAbsoluteEncoder;
import com.revrobotics.SparkAnalogSensor;
import com.revrobotics.SparkLimitSwitch;
import com.revrobotics.SparkPIDController;
import com.revrobotics.CANSparkBase.IdleMode;
import com.revrobotics.CANSparkLowLevel.MotorType;
import com.revrobotics.SparkPIDController.AccelStrategy;
import com.revrobotics.spark.SparkAbsoluteEncoder;
import com.revrobotics.spark.SparkAnalogSensor;
import com.revrobotics.spark.SparkClosedLoopController;
import com.revrobotics.spark.SparkLimitSwitch;
import com.revrobotics.spark.SparkLowLevel;
import com.revrobotics.spark.SparkLowLevel.MotorType;
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode;
import com.revrobotics.spark.config.MAXMotionConfig;
import com.revrobotics.spark.SparkMax;

import org.mockito.invocation.InvocationOnMock;

Expand All @@ -18,12 +19,12 @@ public class DummySparkMaxAnswer extends REVLibErrorAnswer {

public static final DummySparkMaxAnswer ANSWER = new DummySparkMaxAnswer();

public static final CANSparkMax DUMMY_SPARK_MAX = Mocks.mock(CANSparkMax.class, ANSWER);
public static final SparkMax DUMMY_SPARK_MAX = Mocks.mock(SparkMax.class, ANSWER);

public static final RelativeEncoder DUMMY_ENCODER = Mocks.mock(RelativeEncoder.class, REVLibErrorAnswer.ANSWER);
public static final SparkAnalogSensor DUMMY_ANALOG_SENSOR = Mocks.mock(SparkAnalogSensor.class, REVLibErrorAnswer.ANSWER);
public static final SparkLimitSwitch DUMMY_LIMIT_SWITCH = Mocks.mock(SparkLimitSwitch.class, REVLibErrorAnswer.ANSWER);
public static final SparkPIDController DUMMY_PID_CONTROLLER = Mocks.mock(SparkPIDController.class, ANSWER);
public static final SparkClosedLoopController DUMMY_PID_CONTROLLER = Mocks.mock(SparkClosedLoopController.class, ANSWER);
public static final SparkAbsoluteEncoder DUMMY_ABSOLUTE_ENCODER = Mocks.mock(SparkAbsoluteEncoder.class, ANSWER);


Expand All @@ -36,14 +37,14 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
return DUMMY_ANALOG_SENSOR;
} else if(returnType == SparkLimitSwitch.class) {
return DUMMY_LIMIT_SWITCH;
} else if(returnType == SparkPIDController.class) {
} else if(returnType == SparkClosedLoopController.class) {
return DUMMY_PID_CONTROLLER;
} else if(returnType == MotorType.class) {
return MotorType.kBrushless;
} else if(returnType == IdleMode.class) {
return IdleMode.kBrake;
} else if(returnType == AccelStrategy.class) {
return AccelStrategy.kTrapezoidal;
} else if(returnType == MAXMotionConfig.MAXMotionPositionMode.class) {
return MAXMotionConfig.MAXMotionPositionMode.kMAXMotionTrapezoidal;
} else if(returnType == SparkAbsoluteEncoder.class) {
return DUMMY_ABSOLUTE_ENCODER;
}
Expand Down
Loading
Loading