Skip to content
Merged
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
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,28 @@ git submodule add -b master https://github.com/Armada2508/Library library
```
Of course if you want to track commits from a different branch then replace master with a branch of your choice.

Add `implementation ':library'` to your dependencies block in build.gradle. <br>
Add `includeBuild 'library'` to the end of your settings.gradle.
Add this block to your build.gradle.
```groovy
sourceSets {
main {
java {
srcDirs 'library/src/main/java/'
}
}
test {
java {
srcDirs 'library/src/test/java'
}
}
}
```
Add `ignoreFailures = true` to the test block in your build.gradle. Otherwise failing tests could stop a build/deploy.

Make sure source and target compatibility in build.gradle match that of the library, right now it's Java 17. <br>
Make sure GradleRIO version matches. <br>
Make sure you have all vendor deps installed for the library to work and that they're all up to date. Currently only CTRE Phoenix 6. <br>

#### Tests
If you want the tests within the library to be checked/ran when you build the project you must add this to your test block in the build.gradle.
```
dependsOn gradle.includedBuilds*.task(":test")
```

**Important** - I would run `./gradlew build` before continuing. <br>
### Updating your submodules
If you're at the root directory and you want to update the commit that the submodule points to on the branch specified in .gitmodules. (Pull from upstream)<br>
Expand Down
2 changes: 1 addition & 1 deletion 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 "2025.3.1"
id "edu.wpi.first.GradleRIO" version "2025.3.2"
id 'com.diffplug.spotless' version '6.25.0'
}

Expand Down
36 changes: 36 additions & 0 deletions src/main/java/frc/robot/lib/util/RangeTransformer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package frc.robot.lib.util;

import edu.wpi.first.math.MathUtil;

/**
* Helper class for mapping the range [a,b] onto the range [c,d]
*/
public class RangeTransformer {

public final double a;
public final double b;
public final double c;
public final double d;
public final boolean clamp;

public RangeTransformer(double a, double b, double c, double d, boolean clamp) {
if (a == b) throw new IllegalArgumentException("A != B");
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.clamp = clamp;
}

/**
* Takes a number in the range [a,b] and puts it in the range [c,d]
* @param x number in the range [a,b]
* @return number in the range [c,d]
*/
public double calculate(double x) {
double result = (c + ((d - c)/(b - a)) * (x - a));
if (clamp) return MathUtil.clamp(result, Math.min(c, d), Math.max(c, d));
return result;
}

}
60 changes: 30 additions & 30 deletions vendordeps/Phoenix6-frc2025-latest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"fileName": "Phoenix6-frc2025-latest.json",
"name": "CTRE-Phoenix (v6)",
"version": "25.3.1",
"version": "25.3.2",
"frcYear": "2025",
"uuid": "e995de00-2c64-4df5-8831-c1441420ff19",
"mavenUrls": [
Expand All @@ -19,14 +19,14 @@
{
"groupId": "com.ctre.phoenix6",
"artifactId": "wpiapi-java",
"version": "25.3.1"
"version": "25.3.2"
}
],
"jniDependencies": [
{
"groupId": "com.ctre.phoenix6",
"artifactId": "api-cpp",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -40,7 +40,7 @@
{
"groupId": "com.ctre.phoenix6",
"artifactId": "tools",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -54,7 +54,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "api-cpp-sim",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -68,7 +68,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "tools-sim",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -82,7 +82,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simTalonSRX",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -96,7 +96,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simVictorSPX",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -110,7 +110,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simPigeonIMU",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -124,7 +124,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simCANCoder",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -138,7 +138,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProTalonFX",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -152,7 +152,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProTalonFXS",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -166,7 +166,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProCANcoder",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -180,7 +180,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProPigeon2",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -194,7 +194,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProCANrange",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -208,7 +208,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProCANdi",
"version": "25.3.1",
"version": "25.3.2",
"isJar": false,
"skipInvalidPlatforms": true,
"validPlatforms": [
Expand All @@ -224,7 +224,7 @@
{
"groupId": "com.ctre.phoenix6",
"artifactId": "wpiapi-cpp",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_Phoenix6_WPI",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -240,7 +240,7 @@
{
"groupId": "com.ctre.phoenix6",
"artifactId": "tools",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_PhoenixTools",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -256,7 +256,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "wpiapi-cpp-sim",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_Phoenix6_WPISim",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -272,7 +272,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "tools-sim",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_PhoenixTools_Sim",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -288,7 +288,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simTalonSRX",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimTalonSRX",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -304,7 +304,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simVictorSPX",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimVictorSPX",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -320,7 +320,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simPigeonIMU",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimPigeonIMU",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -336,7 +336,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simCANCoder",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimCANCoder",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -352,7 +352,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProTalonFX",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimProTalonFX",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -368,7 +368,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProTalonFXS",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimProTalonFXS",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -384,7 +384,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProCANcoder",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimProCANcoder",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -400,7 +400,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProPigeon2",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimProPigeon2",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -416,7 +416,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProCANrange",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimProCANrange",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand All @@ -432,7 +432,7 @@
{
"groupId": "com.ctre.phoenix6.sim",
"artifactId": "simProCANdi",
"version": "25.3.1",
"version": "25.3.2",
"libName": "CTRE_SimProCANdi",
"headerClassifier": "headers",
"sharedLibrary": true,
Expand Down