From 25dca8cef4a8ec06a0acaf7b18463c772661bed0 Mon Sep 17 00:00:00 2001 From: thenetworkgrinch Date: Wed, 8 Jan 2025 13:21:27 -0600 Subject: [PATCH 1/3] Added example schema. Signed-off-by: thenetworkgrinch --- docs/schemas/swervedrive_schema.json | 42 +++++++++++++++++++ .../deploy/swerve/falcon/swervedrive.json | 1 + 2 files changed, 43 insertions(+) create mode 100644 docs/schemas/swervedrive_schema.json diff --git a/docs/schemas/swervedrive_schema.json b/docs/schemas/swervedrive_schema.json new file mode 100644 index 000000000..7d64152fb --- /dev/null +++ b/docs/schemas/swervedrive_schema.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "description": "", + "type": "object", + "properties": { + "imu": { + "type": "object", + "properties": { + "type": { + "type": "string", + "minLength": 1 + }, + "id": { + "type": "number" + }, + "canbus": { + "type": "string" + } + }, + "required": [ + "type", + "id", + "canbus" + ] + }, + "invertedIMU": { + "type": "boolean" + }, + "modules": { + "type": "array", + "items": { + "required": [], + "properties": {} + } + } + }, + "required": [ + "imu", + "invertedIMU", + "modules" + ] +} \ No newline at end of file diff --git a/src/main/deploy/swerve/falcon/swervedrive.json b/src/main/deploy/swerve/falcon/swervedrive.json index 961281262..f4631eb8e 100644 --- a/src/main/deploy/swerve/falcon/swervedrive.json +++ b/src/main/deploy/swerve/falcon/swervedrive.json @@ -1,4 +1,5 @@ { + "$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/swervedrive_schema.json", "imu": { "type": "navx", "id": 13, From 3599c915ad409a0fd4c5afa8b51e6652b7a53410 Mon Sep 17 00:00:00 2001 From: thenetworkgrinch Date: Wed, 8 Jan 2025 13:28:33 -0600 Subject: [PATCH 2/3] Added ignore on unknown properties. Signed-off-by: thenetworkgrinch --- src/main/deploy/swerve/neo/swervedrive.json | 1 + src/main/java/swervelib/parser/SwerveParser.java | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/deploy/swerve/neo/swervedrive.json b/src/main/deploy/swerve/neo/swervedrive.json index fb2b0b85f..89ae3b1bd 100644 --- a/src/main/deploy/swerve/neo/swervedrive.json +++ b/src/main/deploy/swerve/neo/swervedrive.json @@ -1,4 +1,5 @@ { + "$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/swervedrive_schema.json", "imu": { "type": "pigeon2", "id": 13, diff --git a/src/main/java/swervelib/parser/SwerveParser.java b/src/main/java/swervelib/parser/SwerveParser.java index afa535441..47ea5e214 100644 --- a/src/main/java/swervelib/parser/SwerveParser.java +++ b/src/main/java/swervelib/parser/SwerveParser.java @@ -1,5 +1,6 @@ package swervelib.parser; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import edu.wpi.first.math.geometry.Pose2d; @@ -57,17 +58,21 @@ public SwerveParser(File directory) throws IOException checkDirectory(directory); swerveDriveJson = new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .readValue(new File(directory, "swervedrive.json"), SwerveDriveJson.class); controllerPropertiesJson = new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .readValue( new File(directory, "controllerproperties.json"), ControllerPropertiesJson.class); pidfPropertiesJson = new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .readValue( new File(directory, "modules/pidfproperties.json"), PIDFPropertiesJson.class); physicalPropertiesJson = new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) .readValue( new File(directory, "modules/physicalproperties.json"), PhysicalPropertiesJson.class); @@ -77,7 +82,9 @@ public SwerveParser(File directory) throws IOException moduleConfigs.put(swerveDriveJson.modules[i], i); File moduleFile = new File(directory, "modules/" + swerveDriveJson.modules[i]); assert moduleFile.exists(); - moduleJsons[i] = new ObjectMapper().readValue(moduleFile, ModuleJson.class); + moduleJsons[i] = new ObjectMapper() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .readValue(moduleFile, ModuleJson.class); } } From 196e630f7f6dcac922a6b2f337a0450b92bdb79c Mon Sep 17 00:00:00 2001 From: thenetworkgrinch Date: Wed, 8 Jan 2025 13:34:33 -0600 Subject: [PATCH 3/3] Added basic schema's Signed-off-by: thenetworkgrinch --- docs/schemas/controllerproperties_schema.json | 33 +++++ docs/schemas/module_schema.json | 114 ++++++++++++++++++ docs/schemas/physicalproperties_schema.json | 93 ++++++++++++++ docs/schemas/pidfproperties_schema.json | 65 ++++++++++ docs/schemas/swervedrive_schema.json | 2 +- 5 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 docs/schemas/controllerproperties_schema.json create mode 100644 docs/schemas/module_schema.json create mode 100644 docs/schemas/physicalproperties_schema.json create mode 100644 docs/schemas/pidfproperties_schema.json diff --git a/docs/schemas/controllerproperties_schema.json b/docs/schemas/controllerproperties_schema.json new file mode 100644 index 000000000..bbb7ccc94 --- /dev/null +++ b/docs/schemas/controllerproperties_schema.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/controllerproperties_schema.json", + "description": "", + "type": "object", + "properties": { + "angleJoystickRadiusDeadband": { + "type": "number" + }, + "heading": { + "type": "object", + "properties": { + "p": { + "type": "number" + }, + "i": { + "type": "number" + }, + "d": { + "type": "number" + } + }, + "required": [ + "p", + "i", + "d" + ] + } + }, + "required": [ + "angleJoystickRadiusDeadband", + "heading" + ] +} \ No newline at end of file diff --git a/docs/schemas/module_schema.json b/docs/schemas/module_schema.json new file mode 100644 index 000000000..e8c79310d --- /dev/null +++ b/docs/schemas/module_schema.json @@ -0,0 +1,114 @@ +{ + "$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/module_schema.json", + "description": "", + "type": "object", + "properties": { + "drive": { + "type": "object", + "properties": { + "type": { + "type": "string", + "minLength": 1 + }, + "id": { + "type": "number" + }, + "canbus": { + "type": "object", + "properties": {}, + "required": [] + } + }, + "required": [ + "type", + "id", + "canbus" + ] + }, + "angle": { + "type": "object", + "properties": { + "type": { + "type": "string", + "minLength": 1 + }, + "id": { + "type": "number" + }, + "canbus": { + "type": "object", + "properties": {}, + "required": [] + } + }, + "required": [ + "type", + "id", + "canbus" + ] + }, + "encoder": { + "type": "object", + "properties": { + "type": { + "type": "string", + "minLength": 1 + }, + "id": { + "type": "number" + }, + "canbus": { + "type": "object", + "properties": {}, + "required": [] + } + }, + "required": [ + "type", + "id", + "canbus" + ] + }, + "inverted": { + "type": "object", + "properties": { + "drive": { + "type": "boolean" + }, + "angle": { + "type": "boolean" + } + }, + "required": [ + "drive", + "angle" + ] + }, + "absoluteEncoderOffset": { + "type": "number" + }, + "location": { + "type": "object", + "properties": { + "front": { + "type": "number" + }, + "left": { + "type": "number" + } + }, + "required": [ + "front", + "left" + ] + } + }, + "required": [ + "drive", + "angle", + "encoder", + "inverted", + "absoluteEncoderOffset", + "location" + ] +} \ No newline at end of file diff --git a/docs/schemas/physicalproperties_schema.json b/docs/schemas/physicalproperties_schema.json new file mode 100644 index 000000000..ef302ae23 --- /dev/null +++ b/docs/schemas/physicalproperties_schema.json @@ -0,0 +1,93 @@ +{ + "$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/physicalproperties_schema.json", + "description": "", + "type": "object", + "properties": { + "conversionFactors": { + "type": "object", + "properties": { + "angle": { + "type": "object", + "properties": { + "gearRatio": { + "type": "number" + }, + "factor": { + "type": "number" + } + }, + "required": [ + "gearRatio", + "factor" + ] + }, + "drive": { + "type": "object", + "properties": { + "gearRatio": { + "type": "number" + }, + "diameter": { + "type": "number" + }, + "factor": { + "type": "number" + } + }, + "required": [ + "gearRatio", + "diameter", + "factor" + ] + } + }, + "required": [ + "angle", + "drive" + ] + }, + "currentLimit": { + "type": "object", + "properties": { + "drive": { + "type": "number" + }, + "angle": { + "type": "number" + } + }, + "required": [ + "drive", + "angle" + ] + }, + "rampRate": { + "type": "object", + "properties": { + "drive": { + "type": "number" + }, + "angle": { + "type": "number" + } + }, + "required": [ + "drive", + "angle" + ] + }, + "wheelGripCoefficientOfFriction": { + "type": "number" + }, + "optimalVoltage": { + "type": "number" + } + }, + "required": [ + "conversionFactors", + "currentLimit", + "rampRate", + "wheelGripCoefficientOfFriction", + "optimalVoltage" + ] +} \ No newline at end of file diff --git a/docs/schemas/pidfproperties_schema.json b/docs/schemas/pidfproperties_schema.json new file mode 100644 index 000000000..c71462609 --- /dev/null +++ b/docs/schemas/pidfproperties_schema.json @@ -0,0 +1,65 @@ +{ + "$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/pidfproperties_schema.json", + "description": "", + "type": "object", + "properties": { + "drive": { + "type": "object", + "properties": { + "p": { + "type": "number" + }, + "i": { + "type": "number" + }, + "d": { + "type": "number" + }, + "f": { + "type": "number" + }, + "iz": { + "type": "number" + } + }, + "required": [ + "p", + "i", + "d", + "f", + "iz" + ] + }, + "angle": { + "type": "object", + "properties": { + "p": { + "type": "number" + }, + "i": { + "type": "number" + }, + "d": { + "type": "number" + }, + "f": { + "type": "number" + }, + "iz": { + "type": "number" + } + }, + "required": [ + "p", + "i", + "d", + "f", + "iz" + ] + } + }, + "required": [ + "drive", + "angle" + ] +} \ No newline at end of file diff --git a/docs/schemas/swervedrive_schema.json b/docs/schemas/swervedrive_schema.json index 7d64152fb..1ba223660 100644 --- a/docs/schemas/swervedrive_schema.json +++ b/docs/schemas/swervedrive_schema.json @@ -1,5 +1,5 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", + "$schema": "https://broncbotz3481.github.io/YAGSL-Example/schemas/swervedrive_schema.json", "description": "", "type": "object", "properties": {