Skip to content

Commit

Permalink
[choreolib] Fix C++ version checking
Browse files Browse the repository at this point in the history
Resolves SleipnirGroup#973

Signed-off-by: Jade Turner <[email protected]>
  • Loading branch information
spacey-sooty committed Dec 6, 2024
1 parent c7a3ffc commit 46815da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
11 changes: 6 additions & 5 deletions choreolib/src/main/native/include/choreo/Choreo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

namespace choreo {

inline constexpr uint32_t kSpecVersion = 1;
inline constexpr uint32_t kTrajSpecVersion = 1;
inline constexpr uint32_t kChorSpecVersion = 1;

/**
* A class that handles loading choreo and caching choreo trajectories.
Expand Down Expand Up @@ -74,9 +75,9 @@ class Choreo {

wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer());
uint32_t version = json["version"];
if (kSpecVersion != version) {
if (kChorSpecVersion != version) {
throw fmt::format(".chor project file: Wrong version {}. Expected {}",
version, kSpecVersion);
version, kChorSpecVersion);
}
ProjectFile resultProjectFile;
from_json(json, resultProjectFile);
Expand Down Expand Up @@ -152,9 +153,9 @@ class Choreo {

wpi::json json = wpi::json::parse(trajectoryJsonString);
uint32_t version = json["version"];
if (version != kSpecVersion) {
if (version != kTrajSpecVersion) {
throw fmt::format("{}.traj: Wrong version {}. Expected {}",
trajectoryName, version, kSpecVersion);
trajectoryName, version, kTrajSpecVersion);
}
Trajectory<SampleType> trajectory;
from_json(json, trajectory);
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing/schema-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ Each store has a `get serialize()` computed property. This needs to be updated t
#### `deserialize()`
Each store has a `deserialize()` which populates the Mobx store from a data object.

## choreolib
## Choreolib

Update TRAJ_SCHEMA_VERSION and PROJECT_SCHEMA_VERSION in the following:
* Python: `choreolib/py/choreo/__init__.py`
* Java: `choreolib/src/main/java/choreo/Choreo.java`
* C++ currently does not do version validation.
* C++: `choreolib/src/main/native/include/choreo/Choreo.h`

Make any functional changes to the trajectory classes and loading methods in all three languages, according to the schema change being made.
4 changes: 3 additions & 1 deletion src/assets/Angle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const Angle: React.FunctionComponent<SvgIconProps> = (props) => {
y2={cornerY - length * Math.sin(angle)}
></line>
<path
d={`M ${cornerX + r} ${cornerY} A ${r} ${r} 0 0 0 ${cornerX + r * Math.cos(angle)} ${cornerY - r * Math.sin(angle)}`}
d={`M ${cornerX + r} ${cornerY} A ${r} ${r} 0 0 0 ${
cornerX + r * Math.cos(angle)
} ${cornerY - r * Math.sin(angle)}`}
></path>
</SvgIcon>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const PoseVariablePanel = observer(
setName={(name) => props.setName(name)}
validateName={(name) => props.validateName(name)}
></VariableRenamingInput>
{`(${entry[1].x.defaultUnitMagnitude?.toFixed(2)} m, ${entry[1].y.defaultUnitMagnitude?.toFixed(2)} m, ${entry[1].heading.defaultUnitMagnitude?.toFixed(2)} rad)`}
{`(${entry[1].x.defaultUnitMagnitude?.toFixed(2)} m, ${entry[1].y.defaultUnitMagnitude?.toFixed(2)} m, ${entry[1].heading.defaultUnitMagnitude?.toFixed(2)} rad)`}
{props.actionButton()}
{props.open && (
<>
Expand Down

0 comments on commit 46815da

Please sign in to comment.