diff --git a/build.gradle b/build.gradle index b2c42315..8fb31f29 100644 --- a/build.gradle +++ b/build.gradle @@ -122,7 +122,7 @@ dependencies { def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text) annotationProcessor "org.littletonrobotics.akit:akit-autolog:$akitJson.version" - def coppercoreVersion = "2026.2.21" + def coppercoreVersion = "2026.2.22" implementation "com.google.code.gson:gson:2.11.0" diff --git a/src/main/java/frc/robot/constants/JsonConstants.java b/src/main/java/frc/robot/constants/JsonConstants.java index 5649b670..bc85f342 100644 --- a/src/main/java/frc/robot/constants/JsonConstants.java +++ b/src/main/java/frc/robot/constants/JsonConstants.java @@ -7,6 +7,7 @@ import com.therekrab.autopilot.APTarget; import coppercore.parameter_tools.json.JSONHandler; +import coppercore.parameter_tools.json.JSONSyncConfigBuilder; import coppercore.parameter_tools.json.adapters.measure.JSONMeasure; import coppercore.parameter_tools.json.helpers.JSONConverter; import coppercore.parameter_tools.path_provider.EnvironmentHandler; @@ -28,7 +29,6 @@ import frc.robot.auto.Autos; import frc.robot.constants.drive.DriveConstants; import frc.robot.constants.drive.PhysicalDriveConstants; -import frc.robot.util.json.FixedJSONSyncConfigBuilder; import frc.robot.util.json.JSONAPTarget; import frc.robot.util.json.JSONMotionProfileConfig; import frc.robot.util.json.JSONRotation2d; @@ -70,7 +70,7 @@ public static JSONHandler loadConstants(RobotContainer robotContainer) { EnvironmentHandler.getEnvironmentHandler( Filesystem.getDeployDirectory().toPath().resolve("constants/config.json").toString()); - var jsonSyncSettings = new FixedJSONSyncConfigBuilder(); + var jsonSyncSettings = new JSONSyncConfigBuilder(); Controllers.applyControllerConfigToBuilder(jsonSyncSettings); @@ -122,12 +122,6 @@ public static JSONHandler loadConstants(RobotContainer robotContainer) { jsonHandler.addRoute("/hopper", hopperConstants); jsonHandler.addRoute("/indexer", indexerConstants); jsonHandler.addRoute("/turret", turretConstants); - jsonHandler.registerPostCallback( - "/turret", - (_unused) -> { - turretConstants.initializeDiscontinuityPoint(); - return true; - }); jsonHandler.addRoute("/shooter", shooterConstants); jsonHandler.addRoute("/drive", driveConstants); jsonHandler.addRoute("/hood", hoodConstants); @@ -149,12 +143,6 @@ public static JSONHandler loadConstants(RobotContainer robotContainer) { return true; }); jsonHandler.addRoute("/shotmaps", shotMaps); - jsonHandler.registerPostCallback( - "/shotmaps", - (shotMap) -> { - shotMaps.afterJsonLoad(); - return true; - }); jsonHandler.addRoute("/manualMode", manualModeConstants); } catch (Exception ex) { System.err.println("could not add routes for constant tuning: " + ex); diff --git a/src/main/java/frc/robot/constants/ShotMaps.java b/src/main/java/frc/robot/constants/ShotMaps.java index 1a2797d6..9f6597d8 100644 --- a/src/main/java/frc/robot/constants/ShotMaps.java +++ b/src/main/java/frc/robot/constants/ShotMaps.java @@ -101,7 +101,7 @@ private void initializeFromDataPoints(ShotMapDataPoint[] dataPoints) { /** Initializes the maps and then publishes tuning values for adding values to the map */ @AfterJsonLoad public void afterJsonLoad() { - System.err.println("ShotMaps::afterJsonLoad called"); + System.err.println("ShotMaps::afterJsonLoad: reinitializing maps and publishing tuning values"); initializeMaps(); publishTuningValues(); } diff --git a/src/main/java/frc/robot/util/json/FixedJSONSyncConfigBuilder.java b/src/main/java/frc/robot/util/json/FixedJSONSyncConfigBuilder.java deleted file mode 100644 index 52624c06..00000000 --- a/src/main/java/frc/robot/util/json/FixedJSONSyncConfigBuilder.java +++ /dev/null @@ -1,91 +0,0 @@ -package frc.robot.util.json; - -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonSerializer; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import coppercore.parameter_tools.json.JSONSyncConfig; -import coppercore.parameter_tools.json.JSONSyncConfigBuilder; -import edu.wpi.first.math.Pair; -import java.util.ArrayList; -import java.util.List; - -// I forgot to make a method to add typeAdapterFactories. -// And for some reason I made both typeAdapters and typeAdapterFactories private in JSONSyncConfig, -// which means I can't just extend it and add a method to add factories. - -public class FixedJSONSyncConfigBuilder extends JSONSyncConfigBuilder { - - /** - * List of custom type adapters (JsonSerializer, JsonDeserializer, TypeAdapter) to be registered. - */ - @SuppressWarnings("rawtypes") - public List> typeAdapters = new ArrayList<>(); - - /** List of custom TypeAdapterFactory instances to be registered. */ - public List typeAdapterFactories = new ArrayList<>(); - - /** - * Adds a custom JsonDeserializer for a specific class. - * - * @param The type of the class. - * @param clazz The class to associate with the JsonDeserializer. - * @param adapter The JsonDeserializer to add. - * @return The builder instance. - */ - public JSONSyncConfigBuilder addJsonDeserializer( - Class clazz, JsonDeserializer adapter) { - typeAdapters.add(new Pair<>(clazz, adapter)); - return this; - } - - /** - * Adds a custom JsonSerializer for a specific class. - * - * @param The type of the class. - * @param clazz The class to associate with the JsonSerializer. - * @param adapter The JsonSerializer to add. - * @return The builder instance. - */ - public JSONSyncConfigBuilder addJsonSerializer(Class clazz, JsonSerializer adapter) { - typeAdapters.add(new Pair<>(clazz, adapter)); - return this; - } - - /** - * Adds a custom TypeAdapter for a specific class. - * - * @param The type of the class. - * @param clazz The class to associate with the TypeAdapter. - * @param adapter The TypeAdapter to add. - * @return The builder instance. - */ - public JSONSyncConfigBuilder addJsonTypeAdapter(Class clazz, TypeAdapter adapter) { - typeAdapters.add(new Pair<>(clazz, adapter)); - return this; - } - - public JSONSyncConfigBuilder addJsonTypeAdapterFactory(TypeAdapterFactory factory) { - typeAdapterFactories.add(factory); - return this; - } - - /** - * Builds the configuration object. - * - * @return A JSONSyncConfig instance. - */ - public JSONSyncConfig build() { - return new JSONSyncConfig( - serializeNulls, - prettyPrinting, - excludeFieldsWithoutExposeAnnotation, - namingPolicy, - longSerializationPolicy, - primitiveChecking, - primitiveCheckPrintAlert, - primitiveCheckCrash, - typeAdapters, - typeAdapterFactories); - } -}