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

Add PointAt constraint #427

Merged
merged 16 commits into from
Apr 3, 2024
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tauri-build = { version = "1.5.1", features = [] }
tauri = { version = "1.6.0", features = [ "window-close", "window-set-title", "path-all", "dialog", "dialog-confirm", "dialog-save", "dialog-open", "dialog-ask", "fs-all", "shell-open", "devtools"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
trajoptlib = { git = "https://github.com/SleipnirGroup/TrajoptLib.git", rev = "4b238aa71a1d92a8e4e9913dfc25a6ee81d57cb8", features = ["sleipnir"] }
trajoptlib = { git = "https://github.com/SleipnirGroup/TrajoptLib.git", rev = "c1a764608604837a1601034cddca44e068099dbd", features = ["sleipnir"] }
open = "3"

[features]
Expand Down
25 changes: 24 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ enum Constraints {
StraightLine {
scope: ChoreoConstraintScope,
},
PointAt {
scope: ChoreoConstraintScope,
x: f64,
y: f64,
tolerance: f64,
},
}

#[derive(Debug, serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -372,7 +378,24 @@ async fn generate_trajectory(
)
}
}
} // add more cases here to impl each constraint.
}
Constraints::PointAt {
scope,
x,
y,
tolerance,
} => match scope {
ChoreoConstraintScope::Waypoint(idx) => {
path_builder.wpt_point_at(fix_scope(idx[0], &rm), *x, *y, *tolerance)
}
ChoreoConstraintScope::Segment(idx) => path_builder.sgmt_point_at(
fix_scope(idx[0], &rm),
fix_scope(idx[1], &rm),
*x,
*y,
*tolerance,
),
}, // add more cases here to impl each constraint.
}
}
let half_wheel_base = config.wheelbase / 2.0;
Expand Down
27 changes: 27 additions & 0 deletions src/document/ConstraintStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Dangerous,
Explore,
KeyboardDoubleArrowRight,
NearMe,
PriorityHigh,
StopCircleOutlined,
SyncDisabledOutlined,
Expand Down Expand Up @@ -129,6 +130,32 @@ export const constraints = {
properties: {},
wptScope: false,
sgmtScope: true
},
PointAt: {
name: "Point At",
shortName: "Point At",
description: "Face a specified point",
icon: <NearMe />,
properties: {
x: {
name: "X",
description: "The x coordinate of the point the robot should face",
units: "m"
},
y: {
name: "Y",
description: "The y coordinate of the point the robot should face",
units: "m"
},
tolerance: {
name: "Heading Tolerance",
description:
"The allowable heading range relative to the direction to the point. Keep less than Pi.",
units: "rad"
}
},
wptScope: true,
sgmtScope: true
}
};
const WaypointUUIDScope = types.model("WaypointScope", {
Expand Down
Loading