Skip to content

Commit 5e4d7cc

Browse files
committed
fix: Needed constructor for PlannerConfig in JS bindings
1 parent bbb9363 commit 5e4d7cc

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

oxmpl-js/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,16 @@ pub struct JsPlannerConfig {
310310
seed: Option<u64>,
311311
}
312312

313+
#[wasm_bindgen(js_class = PlannerConfig)]
314+
impl JsPlannerConfig {
315+
#[wasm_bindgen(constructor)]
316+
pub fn new(seed: Option<f64>) -> Self {
317+
Self {
318+
seed: seed.map(|s| s as u64),
319+
}
320+
}
321+
}
322+
313323
impl From<&JsPlannerConfig> for PlannerConfig {
314324
fn from(js_planner_config: &JsPlannerConfig) -> Self {
315325
PlannerConfig {

oxmpl-js/tests/test_prm_integration.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ describe('PRM Integration Tests', () => {
7272
// CREATE AND SETUP THE PLANNER
7373
const timeout = 5.0;
7474
const connectionRadius = 0.5;
75-
const planner = new oxmpl.PRM(timeout, connectionRadius);
75+
const planner_config = new oxmpl.PlannerConfig(0);
76+
const planner = new oxmpl.PRM(timeout, connectionRadius, planner_config);
7677

7778
planner.setup(problemDef, validityChecker);
7879
planner.constructRoadmap();

oxmpl-js/tests/test_rrt_connect_integration.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ describe('RRT Connect Integration Tests', () => {
7272
// CREATE AND SETUP THE PLANNER
7373
const maxDistance = 0.5;
7474
const goalBias = 0.05;
75-
const planner = new oxmpl.RRTConnect(maxDistance, goalBias);
75+
const planner_config = new oxmpl.PlannerConfig(0);
76+
const planner = new oxmpl.RRTConnect(maxDistance, goalBias, planner_config);
7677

7778
planner.setup(problemDef, validityChecker);
7879

oxmpl-js/tests/test_rrt_integration.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ describe('RRT Integration Tests', () => {
7272
// CREATE AND SETUP THE PLANNER
7373
const maxDistance = 0.5;
7474
const goalBias = 0.05;
75-
const planner = new oxmpl.RRT(maxDistance, goalBias);
75+
const planner_config = new oxmpl.PlannerConfig(0);
76+
const planner = new oxmpl.RRT(maxDistance, goalBias, planner_config);
7677

7778
planner.setup(problemDef, validityChecker);
7879

oxmpl-js/tests/test_rrt_star_integration.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ describe('RRT* Integration Tests', () => {
7373
const maxDistance = 0.5;
7474
const goalBias = 0.05;
7575
const searchRadius = 0.25;
76-
const planner = new oxmpl.RRTStar(maxDistance, goalBias, searchRadius);
76+
const planner_config = new oxmpl.PlannerConfig(0);
77+
const planner = new oxmpl.RRTStar(maxDistance, goalBias, searchRadius, planner_config);
7778

7879
planner.setup(problemDef, validityChecker);
7980

0 commit comments

Comments
 (0)