Commit 1b90c6c9 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Cosmetic changes.

parent ac370fef
# vim: foldmethod=marker foldlevel=2
from hpp.corbaserver.manipulation.pr2 import Robot
from math import sqrt
# Load robot and object. {{{3
robot = Robot ('pr2', rootJointType = "anchor")
robot.client.manipulation.robot.setRootJointPosition ('pr2', (-3.2, -4, 0, 1, 0, 0, 0))
robot.loadObjectModel ('box', 'freeflyer', 'hpp_tutorial', 'box', '', '')
robot.buildCompositeRobot ('pr2-box', ['pr2', 'box'])
robot.client.manipulation.robot.loadEnvironmentModel ("iai_maps", "kitchen_area", '', '', "")
robot.setJointBounds ("box/base_joint_xyz", [-3,-2,-5,-3,0.7,1])
# 3}}}
from hpp_ros.manipulation import ScenePublisher
r = ScenePublisher (robot)
# Define configurations. {{{3
q_init = robot.getCurrentConfig ()
rank = robot.rankInConfiguration ['pr2/r_gripper_l_finger_joint']
q_init [rank] = 0.5
......@@ -39,6 +43,7 @@ r (q_goal)
del c
q_inter = [-0.8017105239677402, -0.5977125025958312, -0.796440524800078, 0.6047168680102916, -0.4879605145323316, 0.8728657034488995, -0.988715265911429, 0.1498069522875767, -0.012487804646172175, -0.9999220243274567, -0.9479271854727237, -0.31848712853388694, 0.06700549180802896, -0.9977526066453368, 0.15793164217459785, 0.9874500475467277, 0.9804271799015071, -0.19688205837601827, 0.06981400674906149, 0.9975600254930236, 0.8026666074307995, -0.5964279649006498, -0.8558688410761539, -0.5171929300318802, 0.07633365848037467, 2.5514381844999448, 1.1951774265118278, -0.5864281075389233, 0.24807300661555917, 1.0730239901832896, -0.9931474461781542, 0.5380253563010143, -0.8429286541440898, 0.0, -0.9291311234626017, 0.36975039609596555, 0.5, 0.07192830903452277, 0.0516497980242827, 0.5, 0.2978673015357309, 0.011873305063635719, 0.2207828272342602, 0.9968680838221816, -1.1330407965502385, 0.1474961939381539, -0.9059397450606351, -0.9591666722669869, 0.8241613711518598, -0.5663550426199861, -2.094, 0.7924979452316735, 0.6098745828476339, 0.5, 0.35889873246983567, 0.10845342945887403, 0.5, 0.02916333341652683, 0.025597731231524482, 0.16145134862579935, -2.785939904956431, -4.563075760833335, 0.8958690128585236, -0.19634763254425533, -0.7205092487114027, 0.6650461296003519, 0.005260724207565836]
# 3}}}
robot.client.basic.problem.resetRoadmap ()
robot.client.basic.problem.selectPathOptimizer ('None')
......@@ -48,6 +53,7 @@ robot.client.basic.problem.setMaxIterations (40)
from hpp.corbaserver.manipulation import ProblemSolver
p = ProblemSolver (robot)
# Create constraints. {{{3
robot.client.manipulation.problem.createPlacementConstraint (
'box_placement', 'box', 'box/base_joint_SO3', 'box_surface', 'pancake_table_table_top')
......@@ -92,7 +98,9 @@ for n in jointNames['all']:
jointNames['allButPR2LeftArm'].append (n)
robot.client.basic.problem.setPassiveDofs ('l_grasp_passive', jointNames['pr2'])
robot.client.basic.problem.setPassiveDofs ('r_grasp_passive', jointNames['pr2'])
# 3}}}
# Create the graph. {{{2
graph = robot.client.manipulation.graph
id = dict()
id["graph" ] = graph.createGraph ('pr2-box')
......@@ -107,7 +115,7 @@ graph.setNumericalConstraints (id["free"], ['box_placement'])
# This is not need as the object is locked in node free.
#graph.setNumericalConstraintsForPath (id["free"], ['box_placement'])
### Right hand ###
# Right hand {{{4
graph.setNumericalConstraints (id["right"], ['r_grasp'])
graph.setNumericalConstraintsForPath (id["right"], ['r_grasp_passive'])
......@@ -123,8 +131,9 @@ graph.setLockedDofConstraints (id["r_ungrasp_w"], lockbox)
graph.setLockedDofConstraints (id["r_grasp"], lockbox)
graph.setNumericalConstraints (id["r_grasp_w_node"], ['r_pregrasp', 'r_pregrasp/ineq_0', 'r_pregrasp/ineq_0.1'])
graph.setLockedDofConstraints (id["r_grasp_w"], lockbox)
# 4}}}
### Left hand ###
# Left hand {{{4
graph.setNumericalConstraints (id["left"], ['l_grasp'])
graph.setNumericalConstraintsForPath (id["left"], ['l_grasp_passive'])
......@@ -140,8 +149,9 @@ graph.setLockedDofConstraints (id["l_ungrasp_w"], lockbox)
graph.setLockedDofConstraints (id["l_grasp"], lockbox)
graph.setNumericalConstraints (id["l_grasp_w_node"], ['l_pregrasp', 'l_pregrasp/ineq_0', 'l_pregrasp/ineq_0.1'])
graph.setLockedDofConstraints (id["l_grasp_w"], lockbox)
# 4}}}
### Both hands ###
# Both hands {{{4
graph.setNumericalConstraints (id["both"], ['l_grasp', 'r_grasp'])
graph.setNumericalConstraintsForPath (id["both"], ['l_grasp', 'r_grasp'])
......@@ -170,8 +180,9 @@ graph.setLockedDofConstraints (id["b_r_ungrasp_w"], lockbox)
graph.setLockedDofConstraints (id["b_r_grasp"], lockbox)
graph.setNumericalConstraints (id["b_r_grasp_w_node"], ['l_grasp', 'r_pregrasp', 'r_pregrasp/ineq_0', 'r_pregrasp/ineq_0.1'])
graph.setLockedDofConstraints (id["b_r_grasp_w"], lockbox)
# 4}}}
### Loops ###
# Loops {{{4
id["move_free" ] = graph.createEdge (id["free"], id["free"], "move_free" , 1 , False)
id["l_keep_grasp"] = graph.createEdge (id["left"], id["left"], "l_keep_grasp", 5, False)
......@@ -183,8 +194,10 @@ id["r_keep_grasp_ls"] = graph.createLevelSetEdge (id["right"], id["right"], "r_k
graph.setLockedDofConstraints (id["move_free"], lockbox)
graph.setLevelSetConstraints (id["l_keep_grasp_ls"], [], lockbox)
graph.setLevelSetConstraints (id["r_keep_grasp_ls"], [], lockbox)
# 4}}}
graph.setLockedDofConstraints (id["graph"], lockhands)
# 2}}}
p.setInitialConfig (q_init)
p.addGoalConfig (q_goal)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment