Skip to content

Commit

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

Signed-off-by: Jade Turner <[email protected]>
  • Loading branch information
spacey-sooty committed Dec 6, 2024
1 parent c7a3ffc commit e7c4cc0
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 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
4 changes: 3 additions & 1 deletion src/assets/Torque.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ const Torque: React.FunctionComponent<SvgIconProps> = (props) => {
{/* right arrow part */}
<line x1={endX} y1={cornerY - 9} x2={endX - 3} y2={cornerY - 12}></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>

{/* <circle cx={12} cy={12} r={2} fill="currentColor"></circle>
Expand Down
6 changes: 5 additions & 1 deletion src/components/config/variables/PoseVariablesConfigPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ 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
6 changes: 3 additions & 3 deletions src/components/field/svg/OverlayWaypoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ class OverlayWaypoint extends Component<Props, State> {
return (
<g ref={this.rootRef}>
<g
transform={`translate(${waypoint.x.value}, ${waypoint.y.value}) rotate(${
(waypoint.heading.value * 180) / Math.PI
})`}
transform={`translate(${waypoint.x.value}, ${
waypoint.y.value
}) rotate(${(waypoint.heading.value * 180) / Math.PI})`}
id={this.appendIndexID("waypointGroup")}
>
{this.props.waypoint.type === 0 && (
Expand Down
5 changes: 4 additions & 1 deletion src/components/sidebar/SidebarConstraint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ class SidebarConstraint extends Component<Props, State> {
return waypointIDToText(from, points);
else if (from === "first" && to === "last") return "All";
else {
return `${waypointIDToText(from, points)}-${waypointIDToText(to, points)}`;
return `${waypointIDToText(from, points)}-${waypointIDToText(
to,
points
)}`;
}
}
render() {
Expand Down

0 comments on commit e7c4cc0

Please sign in to comment.