Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify logic when receiving a successful generation in UI #1065

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions src/document/DocumentModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export const DocumentStore = types

console.log(pathStore.serialize);
const config = self.robotConfig.serialize;
const inputDriveType = self.type;
pathStore.params.constraints
.filter((constraint) => constraint.enabled)
.forEach((constraint) => {
Expand Down Expand Up @@ -254,30 +253,7 @@ export const DocumentStore = types
const result: Trajectory = rust_trajectory as Trajectory;
console.log(result);
if (result.trajectory.samples.length == 0) throw "No trajectory";
self.history.startGroup(() => {
const newTrajectory = result.trajectory.samples;
if (inputDriveType === "Differential") {
pathStore.trajectory.setDifferentialSamples(
newTrajectory as DifferentialSample[]
);
} else {
pathStore.trajectory.setSwerveSamples(
newTrajectory as SwerveSample[]
);
}
pathStore.trajectory.setSplits(result.trajectory.splits);
pathStore.trajectory.setWaypoints(result.trajectory.waypoints);
pathStore.markers.forEach((m) => {
const index = m.from.trajectoryTargetIndex;
if (index === undefined) {
m.from.setTargetTimestamp(undefined);
} else {
m.from.setTargetTimestamp(result.trajectory.waypoints[index]);
}
});
pathStore.setSnapshot(result.snapshot);
self.history.stopGroup();
});
pathStore.processGenerationResult(result);
},
(e) => {
tracing.error("generatePathPost:", e);
Expand Down
13 changes: 13 additions & 0 deletions src/document/path/HolonomicPathStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,24 @@ export const HolonomicPathStore = types
})
.actions((self) => {
return {
processGenerationResult(ser: Trajectory) {
self.trajectory.deserialize(ser.trajectory);
self.markers.forEach((m) => {
const index = m.from.trajectoryTargetIndex;
if (index === undefined) {
m.from.setTargetTimestamp(undefined);
} else {
m.from.setTargetTimestamp(ser.trajectory.waypoints[index]);
}
});
self.setSnapshot(ser.snapshot);
},
deserialize(ser: Trajectory) {
self.name = ser.name;
self.snapshot = ser.snapshot;
self.params.deserialize(ser.params);
self.trajectory.deserialize(ser.trajectory);
self.markers.clear();
ser.events.forEach((m) => {
self.addEventMarker(m);
});
Expand Down
Loading