Skip to content

Commit

Permalink
Add PointAt constraint (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruingineer authored Apr 3, 2024
1 parent 34d7fde commit 478751a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
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

0 comments on commit 478751a

Please sign in to comment.