diff --git a/choreolib/py/choreo/__init__.py b/choreolib/py/choreo/__init__.py index c898914d1..15f4f084b 100644 --- a/choreolib/py/choreo/__init__.py +++ b/choreolib/py/choreo/__init__.py @@ -9,7 +9,7 @@ load_event_marker, ) -SPEC_VERSION = "v2025.0.0" +SPEC_VERSION = 1 def load_differential_trajectory_string( @@ -22,7 +22,7 @@ def load_differential_trajectory_string( """ data = json.loads(trajectory_json_string) name = data["name"] - version = data["version"] + version = int(data["version"]) if version != SPEC_VERSION: raise ValueError( f"{name}.traj: Wrong version {version}. Expected {SPEC_VERSION}" diff --git a/choreolib/py/choreo/test/choreolib_test.py b/choreolib/py/choreo/test/choreolib_test.py index 5ebc67c2b..b70ed6512 100644 --- a/choreolib/py/choreo/test/choreolib_test.py +++ b/choreolib/py/choreo/test/choreolib_test.py @@ -5,7 +5,7 @@ TRAJECTORY = """ { "name":"New Path", - "version":"v2025.0.0", + "version":1, "snapshot":{ "waypoints":[ {"x":0.0, "y":0.0, "heading":0.0, "intervals":9, "split":false, "fixTranslation":true, "fixHeading":true, "overrideIntervals":false}, diff --git a/choreolib/py/choreo/test/resources/swerve_test.traj b/choreolib/py/choreo/test/resources/swerve_test.traj index 128e8cbfc..69688fd8c 100644 --- a/choreolib/py/choreo/test/resources/swerve_test.traj +++ b/choreolib/py/choreo/test/resources/swerve_test.traj @@ -1,6 +1,6 @@ { "name":"test", - "version":"v2025.0.0", + "version":1, "snapshot":{ "waypoints":[ {"x":2.6185336112976074, "y":6.034867286682129, "heading":0.0, "intervals":16, "split":false, "fixTranslation":true, "fixHeading":true, "overrideIntervals":false}, diff --git a/choreolib/src/main/java/choreo/Choreo.java b/choreolib/src/main/java/choreo/Choreo.java index 2d8cedb89..bd61655d8 100644 --- a/choreolib/src/main/java/choreo/Choreo.java +++ b/choreolib/src/main/java/choreo/Choreo.java @@ -46,7 +46,7 @@ public final class Choreo { .registerTypeAdapter(EventMarker.class, new EventMarker.Deserializer()) .create(); private static final String TRAJECTORY_FILE_EXTENSION = ".traj"; - private static final String SPEC_VERSION = "v2025.0.0"; + private static final int SPEC_VERSION = 1; private static File CHOREO_DIR = new File(Filesystem.getDeployDirectory(), "choreo"); @@ -81,8 +81,8 @@ public static ProjectFile getProjectFile() { String str = reader.lines().reduce("", (a, b) -> a + b); reader.close(); JsonObject json = GSON.fromJson(str, JsonObject.class); - String version = json.get("version").getAsString(); - if (!SPEC_VERSION.equals(version)) { + int version = json.get("version").getAsInt(); + if (version != SPEC_VERSION) { throw new RuntimeException( ".chor project file: Wrong version " + version + ". Expected " + SPEC_VERSION); } @@ -159,8 +159,8 @@ static Trajectory> loadTrajectoryString( String trajectoryJsonString, ProjectFile projectFile) { JsonObject wholeTrajectory = GSON.fromJson(trajectoryJsonString, JsonObject.class); String name = wholeTrajectory.get("name").getAsString(); - String version = wholeTrajectory.get("version").getAsString(); - if (!SPEC_VERSION.equals(version)) { + int version = wholeTrajectory.get("version").getAsInt(); + if (version != SPEC_VERSION) { throw new RuntimeException( name + ".traj: Wrong version: " + version + ". Expected " + SPEC_VERSION); } diff --git a/choreolib/src/main/java/choreo/trajectory/ProjectFile.java b/choreolib/src/main/java/choreo/trajectory/ProjectFile.java index 7f4d07d24..739badfc5 100644 --- a/choreolib/src/main/java/choreo/trajectory/ProjectFile.java +++ b/choreolib/src/main/java/choreo/trajectory/ProjectFile.java @@ -120,7 +120,7 @@ public static class Config { public final String name; /** The version of the project. */ - public final String version; + public final int version; /** The sample type for the project */ public final String type; @@ -132,7 +132,7 @@ public static class Config { public final List generationFeatures; ProjectFile( - String name, String version, String type, Config config, List generationFeatures) { + String name, int version, String type, Config config, List generationFeatures) { this.name = name; this.version = version; this.type = type; diff --git a/choreolib/src/main/native/include/choreo/Choreo.h b/choreolib/src/main/native/include/choreo/Choreo.h index c7bada50d..7ca60c653 100644 --- a/choreolib/src/main/native/include/choreo/Choreo.h +++ b/choreolib/src/main/native/include/choreo/Choreo.h @@ -24,7 +24,7 @@ namespace choreo { -inline constexpr std::string_view kSpecVersion = "v2025.0.0"; +inline constexpr uint32_t kSpecVersion = 1; template class AutoFactory; @@ -73,7 +73,7 @@ class Choreo { } wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer()); - std::string version = json["version"]; + uint32_t version = json["version"]; if (kSpecVersion != version) { throw fmt::format(".chor project file: Wrong version {}. Expected {}", version, kSpecVersion); @@ -145,8 +145,8 @@ class Choreo { static std::optional> LoadTrajectoryString( std::string_view trajectoryJsonString, std::string_view trajectoryName) { wpi::json json = wpi::json::parse(trajectoryJsonString); - std::string version = json["version"]; - if (kSpecVersion != version) { + uint32_t version = json["version"]; + if (version != kSpecVersion) { throw fmt::format("{}.traj: Wrong version {}. Expected {}", trajectoryName, version, kSpecVersion); } diff --git a/choreolib/src/main/native/include/choreo/trajectory/ProjectFile.h b/choreolib/src/main/native/include/choreo/trajectory/ProjectFile.h index 3ffd063fd..e2dd90b24 100644 --- a/choreolib/src/main/native/include/choreo/trajectory/ProjectFile.h +++ b/choreolib/src/main/native/include/choreo/trajectory/ProjectFile.h @@ -163,7 +163,7 @@ struct ProjectFile { std::string name; /// The version of the project. - std::string version; + uint32_t version; /// The sample type for the project. std::string type; diff --git a/choreolib/src/test/java/choreo/ChoreoTests.java b/choreolib/src/test/java/choreo/ChoreoTests.java index 836698606..26dc29d55 100644 --- a/choreolib/src/test/java/choreo/ChoreoTests.java +++ b/choreolib/src/test/java/choreo/ChoreoTests.java @@ -18,7 +18,7 @@ public class ChoreoTests { """ { "name":"New Path", - "version":"v2025.0.0", + "version":1, "snapshot":{ "waypoints":[ {"x":0.0, "y":0.0, "heading":0.0, "intervals":9, "split":false, "fixTranslation":true, "fixHeading":true, "overrideIntervals":false}, @@ -59,7 +59,7 @@ public class ChoreoTests { public static final String PROJ = "{" + " \"name\": \"idk\"," - + " \"version\": \"v2025.0.0\"," + + " \"version\": 1," + " \"type\": \"Swerve\"," + " \"variables\": {" + " \"expressions\": {}," diff --git a/choreolib/src/test/native/cpp/ProjectFileTests.cpp b/choreolib/src/test/native/cpp/ProjectFileTests.cpp index ad7d5e921..9c36585b8 100644 --- a/choreolib/src/test/native/cpp/ProjectFileTests.cpp +++ b/choreolib/src/test/native/cpp/ProjectFileTests.cpp @@ -13,7 +13,7 @@ using namespace choreo; constexpr std::string_view projectJsonString = R"({ "name":"test", - "version":"v2025.0.0", + "version":1, "type":"Swerve", "variables":{ "expressions":{ @@ -116,7 +116,7 @@ const wpi::json projectJson = wpi::json::parse(projectJsonString); const ProjectFile correctProjFile{ "test", - "v2025.0.0", + 1, "Swerve", {{"test", Variable{"Number", Expression{"2", 2.0}}}}, {{"test2", Pose{Expression{"2 m", 2.0}, Expression{"3 m", 3.0}, diff --git a/choreolib/src/test/native/cpp/TrajectoryFileTests.cpp b/choreolib/src/test/native/cpp/TrajectoryFileTests.cpp index da484e5d5..8e3932a73 100644 --- a/choreolib/src/test/native/cpp/TrajectoryFileTests.cpp +++ b/choreolib/src/test/native/cpp/TrajectoryFileTests.cpp @@ -14,7 +14,7 @@ using namespace choreo; constexpr std::string_view swerveTrajectoryString = R"({ "name":"New Path", - "version":"v2025.0.0", + "version":1, "snapshot":{ "waypoints":[ {"x":0.0, "y":0.0, "heading":0.0, "intervals":9, "split":false, "fixTranslation":true, "fixHeading":true, "overrideIntervals":false},