Skip to content

Commit

Permalink
Update to 2024.5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thenetworkgrinch committed Jul 29, 2024
1 parent c2890ab commit df003b1
Show file tree
Hide file tree
Showing 74 changed files with 253 additions and 41 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ repositories {
mavenCentral()
}
//if (project.hasProperty('releaseMode')) {
wpilibRepositories.addAllReleaseRepositories(project)
wpilibRepositories.addAllReleaseRepositories(project)
//} else {
//wpilibRepositories.addAllDevelopmentRepositories(project)
//wpilibRepositories.addAllDevelopmentRepositories(project)
//}

// Apply C++ configuration
Expand Down
2 changes: 1 addition & 1 deletion publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'maven-publish'

ext.licenseFile = files("$rootDir/LICENSE.txt")

def pubVersion = '2024.4.8.13'
def pubVersion = '2024.5.0.0'

def outputsFolder = file("$buildDir/outputs")

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/swervelib/SwerveDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,19 @@ public void restoreInternalOffset() {
}
}

/**
* Enable auto-centering module wheels. This has a side effect of causing some jitter to the robot
* when a PID is not tuned perfectly. This function is a wrapper for {@link
* SwerveModule#setAntiJitter(boolean)} to perform auto-centering.
*
* @param enabled Enable auto-centering (disable antiJitter)
*/
public void setAutoCenteringModules(boolean enabled) {
for (SwerveModule module : swerveModules) {
module.setAntiJitter(!enabled);
}
}

/**
* Enable or disable the {@link swervelib.parser.SwerveModuleConfiguration#useCosineCompensator}
* for all {@link SwerveModule}'s in the swerve drive. The cosine compensator will slow down or
Expand Down
30 changes: 8 additions & 22 deletions src/main/java/swervelib/math/SwerveMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,33 +336,19 @@ public static SwerveModuleConfiguration getSwerveModule(
* 756 degrees, assumes the full scope is (720-1080), and places an angle of 22 degrees into it,
* returning 742 deg.
*
* <p>A more formal definition: returns the closest angle {@code n} to {@code scopeReference} such
* that {@code n} is congruent to {@code newAngle}.
*
* @param scopeReference Current Angle (deg)
* @param newAngle Target Angle (deg)
* @return Closest angle within scope (deg)
*/
public static double placeInAppropriate0To360Scope(double scopeReference, double newAngle) {
double lowerBound;
double upperBound;
double lowerOffset = scopeReference % 360;
if (lowerOffset >= 0) {
lowerBound = scopeReference - lowerOffset;
upperBound = scopeReference + (360 - lowerOffset);
} else {
upperBound = scopeReference - lowerOffset;
lowerBound = scopeReference - (360 + lowerOffset);
}
while (newAngle < lowerBound) {
newAngle += 360;
}
while (newAngle > upperBound) {
newAngle -= 360;
}
if (newAngle - scopeReference > 180) {
newAngle -= 360;
} else if (newAngle - scopeReference < -180) {
newAngle += 360;
}
return newAngle;
// Figure out how many revolutions from the angle to the reference
double diffRevs = Math.round((scopeReference - newAngle) / 360) * 360;

// Add that many revolutions
return diffRevs + newAngle;
}

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/swervelib/parser/json/ModuleJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import swervelib.parser.SwerveModuleConfiguration;
import swervelib.parser.SwerveModulePhysicalCharacteristics;
import swervelib.parser.json.modules.BoolMotorJson;
import swervelib.parser.json.modules.ConversionFactorsJson;
import swervelib.parser.json.modules.LocationJson;

/** {@link swervelib.SwerveModule} JSON parsed class. Used to access the JSON data. */
Expand All @@ -27,6 +28,8 @@ public class ModuleJson {
* drive motors.
*/
public MotorConfigDouble conversionFactor = new MotorConfigDouble(0, 0);
/** Conversion Factors composition. Auto-calculates the conversion factors. */
public ConversionFactorsJson conversionFactors = new ConversionFactorsJson();
/** Absolute encoder device configuration. */
public DeviceJson encoder;
/** Defines which motors are inverted. */
Expand Down Expand Up @@ -64,6 +67,27 @@ public SwerveModuleConfiguration createModuleConfiguration(
}
}

// Setup deprecation notice.
// if (this.conversionFactor.drive != 0 && this.conversionFactor.angle != 0)
// {
// new Alert("Configuration",
// "\n'conversionFactor': {'drive': " + conversionFactor.drive + ", 'angle': " +
// conversionFactor.angle +
// "} \nis deprecated, please use\n" +
// "'conversionFactors': {'drive': {'factor': " + conversionFactor.drive + "},
// 'angle': {'factor': " +
// conversionFactor.angle + "} }",
// AlertType.WARNING).set(true);
// }

// Override with composite conversion factor.
if (!conversionFactors.isAngleEmpty()) {
conversionFactor.angle = conversionFactors.angle.calculate();
}
if (!conversionFactors.isDriveEmpty()) {
conversionFactor.drive = conversionFactors.drive.calculate();
}

// Set the conversion factors to null if they are both 0.
if (this.conversionFactor != null) {
if (this.conversionFactor.angle == 0 && this.conversionFactor.drive == 0) {
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/swervelib/parser/json/PhysicalPropertiesJson.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package swervelib.parser.json;

import swervelib.parser.SwerveModulePhysicalCharacteristics;
import swervelib.parser.json.modules.ConversionFactorsJson;

/**
* {@link swervelib.parser.SwerveModulePhysicalCharacteristics} parsed data. Used to configure the
Expand All @@ -15,6 +16,8 @@ public class PhysicalPropertiesJson {
* drive motors.
*/
public MotorConfigDouble conversionFactor = new MotorConfigDouble(0, 0);
/** Conversion Factors composition. Auto-calculates the conversion factors. */
public ConversionFactorsJson conversionFactors = new ConversionFactorsJson();
/** The current limit in AMPs to apply to the motors. */
public MotorConfigInt currentLimit = new MotorConfigInt(40, 20);
/** The minimum number of seconds to take for the motor to go from 0 to full throttle. */
Expand All @@ -33,6 +36,29 @@ public class PhysicalPropertiesJson {
* @return {@link SwerveModulePhysicalCharacteristics} based on parsed data.
*/
public SwerveModulePhysicalCharacteristics createPhysicalProperties() {
// Setup deprecation notice.
// if (conversionFactor.drive != 0 && conversionFactor.angle != 0 &&
// conversionFactors.isDriveEmpty() &&
// conversionFactors.isAngleEmpty())
// {
// new Alert("Configuration",
// "\n'conversionFactor': {'drive': " + conversionFactor.drive + ", 'angle': " +
// conversionFactor.angle +
// "} \nis deprecated, please use\n" +
// "'conversionFactors': {'drive': {'factor': " + conversionFactor.drive + "},
// 'angle': {'factor': " +
// conversionFactor.angle + "} }",
// AlertType.ERROR_TRACE).set(true);
// }

if (!conversionFactors.isAngleEmpty()) {
conversionFactor.angle = conversionFactors.angle.calculate();
}

if (!conversionFactors.isDriveEmpty()) {
conversionFactor.drive = conversionFactors.drive.calculate();
}

return new SwerveModulePhysicalCharacteristics(
conversionFactor,
wheelGripCoefficientOfFriction,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package swervelib.parser.json.modules;

import swervelib.math.SwerveMath;
import swervelib.telemetry.Alert;
import swervelib.telemetry.Alert.AlertType;

/** Angle motor conversion factors composite JSON parse class. */
public class AngleConversionFactorsJson {

/**
* Gear ratio for the angle/steering/azimuth motor on the Swerve Module. Motor rotations to 1
* wheel rotation.
*/
public double gearRatio = 0;
/** Calculated or given conversion factor. */
public double factor = 0;

/**
* Calculate the drive conversion factor.
*
* @return Drive conversion factor, if factor isn't set.
*/
public double calculate() {
if (factor != 0 && gearRatio != 0) {
new Alert(
"Configuration",
"The given angle conversion factor takes precedence over the composite conversion factor, please remove 'factor' if you want to use the composite factor instead.",
AlertType.WARNING)
.set(true);
}
if (factor == 0) {
factor = SwerveMath.calculateDegreesPerSteeringRotation(gearRatio);
}
return factor;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package swervelib.parser.json.modules;

/** Conversion Factors parsed JSON class */
public class ConversionFactorsJson {

/** Drive motor conversion factors composition. */
public DriveConversionFactorsJson drive = new DriveConversionFactorsJson();
/** Angle motor conversion factors composition. */
public AngleConversionFactorsJson angle = new AngleConversionFactorsJson();

/**
* Check if the conversion factors are set for the drive motor.
*
* @return Empty
*/
public boolean isDriveEmpty() {
return drive.factor == 0 && drive.diameter == 0 && drive.gearRatio == 0;
}

/**
* Check if the conversion factors are set for the angle motor.
*
* @return Empty
*/
public boolean isAngleEmpty() {
return angle.factor == 0 && angle.gearRatio == 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package swervelib.parser.json.modules;

import edu.wpi.first.math.util.Units;
import swervelib.math.SwerveMath;
import swervelib.telemetry.Alert;
import swervelib.telemetry.Alert.AlertType;

/** Drive motor composite JSON parse class. */
public class DriveConversionFactorsJson {

/** Gear ratio for the drive motor rotations to turn the wheel 1 complete rotation. */
public double gearRatio = 0;
/** Diameter of the wheel in inches. */
public double diameter = 0;
/** Calculated conversion factor. */
public double factor = 0;

/**
* Calculate the drive conversion factor.
*
* @return Drive conversion factor, if factor isn't set.
*/
public double calculate() {
if (factor != 0 && (diameter != 0 || gearRatio != 0)) {
new Alert(
"Configuration",
"The given drive conversion factor takes precedence over the composite conversion factor, please remove 'factor' if you want to use the composite factor instead.",
AlertType.WARNING)
.set(true);
}
if (factor == 0) {
factor =
SwerveMath.calculateMetersPerRotation(
Units.inchesToMeters(this.diameter), this.gearRatio);
}
return factor;
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08caa4af8eaae4675661179f851ffb27
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de3b1976111495ed71be02dc1e444364198ecaf0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fb99f57bbdc7c3b30b185c9643609f16d4e60d7e3b1e69dfe1f112924fb168ec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
418b466a46440387ed256fa4937014c875ff04f0e454b13af2caf3d9a44734720e2f1c79df8224a7e9dead59a1d018b0635cae03daa77908c949395df953bb96
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08caa4af8eaae4675661179f851ffb27
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de3b1976111495ed71be02dc1e444364198ecaf0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fb99f57bbdc7c3b30b185c9643609f16d4e60d7e3b1e69dfe1f112924fb168ec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
418b466a46440387ed256fa4937014c875ff04f0e454b13af2caf3d9a44734720e2f1c79df8224a7e9dead59a1d018b0635cae03daa77908c949395df953bb96
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08caa4af8eaae4675661179f851ffb27
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de3b1976111495ed71be02dc1e444364198ecaf0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fb99f57bbdc7c3b30b185c9643609f16d4e60d7e3b1e69dfe1f112924fb168ec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
418b466a46440387ed256fa4937014c875ff04f0e454b13af2caf3d9a44734720e2f1c79df8224a7e9dead59a1d018b0635cae03daa77908c949395df953bb96
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08caa4af8eaae4675661179f851ffb27
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de3b1976111495ed71be02dc1e444364198ecaf0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fb99f57bbdc7c3b30b185c9643609f16d4e60d7e3b1e69dfe1f112924fb168ec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
418b466a46440387ed256fa4937014c875ff04f0e454b13af2caf3d9a44734720e2f1c79df8224a7e9dead59a1d018b0635cae03daa77908c949395df953bb96
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08caa4af8eaae4675661179f851ffb27
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de3b1976111495ed71be02dc1e444364198ecaf0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fb99f57bbdc7c3b30b185c9643609f16d4e60d7e3b1e69dfe1f112924fb168ec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
418b466a46440387ed256fa4937014c875ff04f0e454b13af2caf3d9a44734720e2f1c79df8224a7e9dead59a1d018b0635cae03daa77908c949395df953bb96
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
08caa4af8eaae4675661179f851ffb27
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de3b1976111495ed71be02dc1e444364198ecaf0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fb99f57bbdc7c3b30b185c9643609f16d4e60d7e3b1e69dfe1f112924fb168ec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
418b466a46440387ed256fa4937014c875ff04f0e454b13af2caf3d9a44734720e2f1c79df8224a7e9dead59a1d018b0635cae03daa77908c949395df953bb96
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>swervelib</groupId>
<artifactId>YAGSL-cpp</artifactId>
<version>2024.5.0.0</version>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a3038c661716887feccbeafef54bbdc4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dc13dd3540bd2dbf16e09a1390c03c1990c72914
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
aebd7d7a4d9291d555f9cb6ea9f7a44ae002a98a3f986fe9ed7fbd53390c01a0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a80324cc5dd0f75187fcf617c6f02c979518cbe86488a3007a1e5822fb81b29e6852213cbd498b8fc773472172b48dd83d06d673aab6d5b992f2ac64b96131c0
8 changes: 4 additions & 4 deletions yagsl/repos/swervelib/YAGSL-cpp/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<groupId>swervelib</groupId>
<artifactId>YAGSL-cpp</artifactId>
<versioning>
<latest>2024.4.8.13</latest>
<release>2024.4.8.13</release>
<latest>2024.5.0.0</latest>
<release>2024.5.0.0</release>
<versions>
<version>2024.4.8.13</version>
<version>2024.5.0.0</version>
</versions>
<lastUpdated>20240614175758</lastUpdated>
<lastUpdated>20240729201423</lastUpdated>
</versioning>
</metadata>
2 changes: 1 addition & 1 deletion yagsl/repos/swervelib/YAGSL-cpp/maven-metadata.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0b744260daf3ff4216785c137fd91428
ab2c6cf21107b5fd040c01c4cc97d17f
2 changes: 1 addition & 1 deletion yagsl/repos/swervelib/YAGSL-cpp/maven-metadata.xml.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a181f606fcac0e3f77c0561214d4a952c7ce1222
20945ad53253382c08c5da37c76bb98b7ee1b8da
Loading

0 comments on commit df003b1

Please sign in to comment.