diff --git a/NEWS b/NEWS index 32d72b40482a47608dd881f2a9283e5a2f966594..cc9e10defc7fb8c1d3cc6ce0b6c17f9c46b2ead8 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,7 @@ -*- outline -*- +New In v4.10.1 +* Improve tutorial_3.py. +New in v4.10.0 * Install tutorial_3.py and refer to it in instructions. New in v4.6.1 * Update tutorial instructions to run gepetto-gui after hppcorbaserver. diff --git a/include/hpp_tutorial/tutorial_3.hh b/include/hpp_tutorial/tutorial_3.hh index 4bc646e538e9c5e2df08a6703eba3a44c26c0b15..395cddadf419e6be2a2a9b3860c63ac65d5f0695 100644 --- a/include/hpp_tutorial/tutorial_3.hh +++ b/include/hpp_tutorial/tutorial_3.hh @@ -58,6 +58,9 @@ /// \code /// >>> v = vf.createViewer () /// \endcode +/// The robot and environment should appear in the viewer. If the viewer +/// window is black, select the window and hit space. +/// /// To solve the problem, type /// \code /// >>> ps.solve () @@ -68,3 +71,15 @@ /// >>> pp = PathPlayer (v) /// >>> pp (0) /// \endcode +/// +/// \section hpp_tutorial_3_optimization Optimizing the solution path +/// +/// To optimize the solution path, select a path optimizer: +/// \code +/// >>> ps.addPathOptimizer('Graph-RandomShortcut') +/// >>> ps.optimizePath(0) +/// \endcode +/// To display the solution: +/// \code +/// >>> pp(1) +/// \endcode diff --git a/script/tutorial_3.py b/script/tutorial_3.py index 577459b330aa9dc5fefc88ab86e8cd39769abdb6..aaa6421d1d71ff84f78597c2f12a79cd8ccf6a37 100644 --- a/script/tutorial_3.py +++ b/script/tutorial_3.py @@ -1,6 +1,7 @@ # Import libraries and load robots. {{{1 # Import. {{{2 +from math import sqrt from hpp.gepetto import PathPlayer from hpp.corbaserver.manipulation.pr2 import Robot from hpp.corbaserver.manipulation import ProblemSolver, ConstraintGraph, Rule, \ @@ -62,12 +63,15 @@ q_init [0:2] = [-3.2, -4] rank = robot.rankInConfiguration ['pr2/torso_lift_joint'] q_init [rank] = 0.2 rank = robot.rankInConfiguration ['box/root_joint'] -q_init [rank:rank+3] = [-2.5, -4, 0.8] +q_init [rank:rank+3] = [-2.5, -4, 0.746] + +# Put box in right orientation +q_init[rank+3:rank+7] = [0, -sqrt(2)/2, 0, sqrt(2)/2] q_goal = q_init [::] q_goal [0:2] = [-3.2, -4] rank = robot.rankInConfiguration ['box/root_joint'] -q_goal [rank:rank+3] = [-3.5, -4, 0.8] +q_goal [rank:rank+3] = [-2.5, -4.5, 0.746] # 2}}} # Create the constraints. {{{2 @@ -99,17 +103,13 @@ factory.setObjects (objects, handlesPerObject, contactSurfacesPerObject) factory.setRules (rules) factory.generate () cg.addConstraints (graph = True, constraints = Constraints \ - (lockedJoints = locklhand)) + (numConstraints = locklhand)) cg.initialize () # 2}}} -res, q_init_proj, err = cg.applyNodeConstraints("free", q_init) -res, q_goal_proj, err = cg.applyNodeConstraints("free", q_goal) - -ps.setInitialConfig (q_init_proj) - -ps.addGoalConfig (q_goal_proj) +ps.setInitialConfig (q_init) +ps.addGoalConfig (q_goal) # print ps.solve()