From bdef8fe6e9081d56a73bb147d87c035bc99e777f Mon Sep 17 00:00:00 2001 From: Paul Sardin Date: Fri, 19 Sep 2025 08:47:44 +0200 Subject: [PATCH 1/4] Add hpp python tutorial --- script/hpp_python_tutorial_1.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/script/hpp_python_tutorial_1.py b/script/hpp_python_tutorial_1.py index 74f8fb4..2ece7e0 100644 --- a/script/hpp_python_tutorial_1.py +++ b/script/hpp_python_tutorial_1.py @@ -2,17 +2,16 @@ from pinocchio import SE3 from pyhpp.core import DiffusingPlanner, Problem from pyhpp.gepetto import Viewer -from pyhpp.pinocchio import Device +from pyhpp.pinocchio import Device, urdf urdfFilename = "package://example-robot-data/robots/pr2_description/urdf/pr2.urdf" srdfFilename = "package://example-robot-data/robots/pr2_description/srdf/pr2.srdf" rootJointType = "planar" # Initialize robot and viewer robot = Device.create("ur2") -viewer = Viewer("tutorial_1", robot) -viewer.addURDFToScene( - 0, "r0", rootJointType, urdfFilename, srdfFilename, SE3.Identity() +urdf.loadModel( + robot, 0, "r0", rootJointType, urdfFilename, srdfFilename, SE3.Identity() ) # Define initial and goal configurations @@ -25,7 +24,7 @@ upperLimit = model.upperPositionLimit # Set root_joint bounds specifically -root_joint_bounds = [-4, -3, -5, -3] # [x_lower, x_upper, y_lower, y_upper] +root_joint_bounds = [-4, -3, -5, -3] ij = model.getJointId("r0/root_joint") iq = model.idx_qs[ij] @@ -58,18 +57,18 @@ rank = rankInConfiguration["r_elbow_flex_joint"] q_goal[rank] = -0.5 -viewer.addURDFObstacleToScene( - "package://hpp_tutorial/urdf/kitchen_area_obstacle.urdf", "kitchen" +urdf.loadModel( + robot, 0, "kitchen_area", "anchor", "package://hpp_tutorial/urdf/kitchen_area_obstacle.urdf", "", SE3.Identity() ) -viewer.applyConfiguration(q_goal) +viewer = Viewer(robot) -# Setup problem and RRT components problem = Problem(robot) problem.initConfig(q_init) problem.addGoalConfig(q_goal) +viewer.display(q_init) diffusingPlanner = DiffusingPlanner(problem) path = diffusingPlanner.solve() -viewer.displayPath(path) +viewer.playPath(path) From eb0f3db1d6d2c251561ad5a9ff2b4e3325ac5a20 Mon Sep 17 00:00:00 2001 From: Paul Sardin Date: Wed, 15 Oct 2025 11:22:15 +0200 Subject: [PATCH 2/4] fix call to display --- script/hpp_python_tutorial_1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/hpp_python_tutorial_1.py b/script/hpp_python_tutorial_1.py index 2ece7e0..9172f3e 100644 --- a/script/hpp_python_tutorial_1.py +++ b/script/hpp_python_tutorial_1.py @@ -66,7 +66,7 @@ problem = Problem(robot) problem.initConfig(q_init) problem.addGoalConfig(q_goal) -viewer.display(q_init) +viewer(q_init) diffusingPlanner = DiffusingPlanner(problem) From f54c2530caf6a08d4e22213960d0f865c3a2c9bd Mon Sep 17 00:00:00 2001 From: Paul Sardin Date: Wed, 18 Feb 2026 08:45:25 +0100 Subject: [PATCH 3/4] Switch to viser viewer --- script/hpp_python_tutorial_1.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/script/hpp_python_tutorial_1.py b/script/hpp_python_tutorial_1.py index 9172f3e..9d68504 100644 --- a/script/hpp_python_tutorial_1.py +++ b/script/hpp_python_tutorial_1.py @@ -1,14 +1,14 @@ import numpy as np from pinocchio import SE3 -from pyhpp.core import DiffusingPlanner, Problem -from pyhpp.gepetto import Viewer +from pyhpp.core import DiffusingPlanner, Problem, RandomShortcut +from pyhpp.viser import Viewer from pyhpp.pinocchio import Device, urdf urdfFilename = "package://example-robot-data/robots/pr2_description/urdf/pr2.urdf" srdfFilename = "package://example-robot-data/robots/pr2_description/srdf/pr2.srdf" rootJointType = "planar" # Initialize robot and viewer -robot = Device.create("ur2") +robot = Device("ur2") urdf.loadModel( robot, 0, "r0", rootJointType, urdfFilename, srdfFilename, SE3.Identity() @@ -61,14 +61,19 @@ robot, 0, "kitchen_area", "anchor", "package://hpp_tutorial/urdf/kitchen_area_obstacle.urdf", "", SE3.Identity() ) -viewer = Viewer(robot) - problem = Problem(robot) problem.initConfig(q_init) problem.addGoalConfig(q_goal) -viewer(q_init) diffusingPlanner = DiffusingPlanner(problem) +path_optimizer = RandomShortcut(problem) path = diffusingPlanner.solve() -viewer.playPath(path) +opt_path = path_optimizer.optimize(path) + +#launch in interactive mode to use viewer +viewer = Viewer(robot) +viewer.initViewer(open=True, loadModel=True) +viewer(np.array(q_init)) +viewer.loadPath(path, "path") +viewer.loadPath(opt_path, "opt_path") \ No newline at end of file From e52f4482670de987c6bd508e113e3c637226abc3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 07:49:06 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- script/hpp_python_tutorial_1.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/script/hpp_python_tutorial_1.py b/script/hpp_python_tutorial_1.py index 9d68504..b46ea92 100644 --- a/script/hpp_python_tutorial_1.py +++ b/script/hpp_python_tutorial_1.py @@ -1,8 +1,8 @@ import numpy as np from pinocchio import SE3 from pyhpp.core import DiffusingPlanner, Problem, RandomShortcut -from pyhpp.viser import Viewer from pyhpp.pinocchio import Device, urdf +from pyhpp.viser import Viewer urdfFilename = "package://example-robot-data/robots/pr2_description/urdf/pr2.urdf" srdfFilename = "package://example-robot-data/robots/pr2_description/srdf/pr2.srdf" @@ -58,7 +58,13 @@ q_goal[rank] = -0.5 urdf.loadModel( - robot, 0, "kitchen_area", "anchor", "package://hpp_tutorial/urdf/kitchen_area_obstacle.urdf", "", SE3.Identity() + robot, + 0, + "kitchen_area", + "anchor", + "package://hpp_tutorial/urdf/kitchen_area_obstacle.urdf", + "", + SE3.Identity(), ) problem = Problem(robot) @@ -71,9 +77,9 @@ path = diffusingPlanner.solve() opt_path = path_optimizer.optimize(path) -#launch in interactive mode to use viewer +# launch in interactive mode to use viewer viewer = Viewer(robot) viewer.initViewer(open=True, loadModel=True) viewer(np.array(q_init)) viewer.loadPath(path, "path") -viewer.loadPath(opt_path, "opt_path") \ No newline at end of file +viewer.loadPath(opt_path, "opt_path")