tmkit
0.0.1-alpha1
A Task-Motion Planning Framework
|
This tutorial will show you how to use TMSMT for task-motion planning, by starting by using the Baxter robot to solve the Sussman Anomaly, a classic example planning problem involving rearranging several blocks. Then, you will modify the the problem, first by changing the goal positions of the blocks, next by changing the initial scene, and finally by addition additional task operators.
In this tutorial, you will first see how to run the planner on the demo scene, then modify the scene with different goals and objects.
Obtain the baxter URDF, which describes the kinematics and geometry (meshes) of the robot.
baxter_description
ROS package, for example on ROS Indigo: sudo apt-get install ros-indigo-baxter-description export ROS_PACKAGE_PATH=/opt/ros/indigo/share
git clone https://github.com/RethinkRobotics/baxter_common export ROS_PACKAGE_PATH=`pwd`/baxter_common
Now, check that you can load the Baxter model. The following command will visualize the Baxter in the Amino viewer. Click and drag the mouse and to rotate the view, and zoom with the scroll wheel. Close the window the exit.
aarxc --gui package://baxter_description/urdf/baxter.urdf
mkdir baxter-blocks cp tmkit/demo/baxter-sussman/*.robray \ tmkit/demo/baxter-sussman/q0.tmp \ tmkit/demo/domains/blocksworld/tm-blocks.* \ baxter-blocks
cd baxter-blocks aarxc --gui package://baxter_description/urdf/baxter.urdf sussman-0.robray
Run the planner command on the example problem.
tmsmt package://baxter_description/urdf/baxter.urdf \ sussman-0.robray \ allowed-collision.robray \ tm-blocks.pddl \ tm-blocks.py \ -q q0.tmp \ -g sussman-1.robray \ -o baxter-sussman.tmp
This commands takes a number of inputs and options:
package://baxter_description/urdf/baxter.urdf
: A scene description (for the robot) for the start scene in URDF formatsussman-0.robray
: a scene description for the start scene in scene file formatallowed-collision.robray
: an additional scene description contained the allowable collisionstm-blocks.pddl
: The task operators filetm-blocks.py
: The domain somantics file-q q0.tmp
: The initial configuration-g sussman-1.robray
: The goal scene-o baxter-sussman.tmp
: The output file plan fileLoad and view the computed plan:
tmsmt package://baxter_description/urdf/baxter.urdf \ sussman-0.robray \ allowed-collision.robray \ baxter-sussman.tmp \ --gui
This command takes as parameters the initial scene (*.urdf
and *.robray
files) along with the previously computed plan file baxter-sussman.tmp
. The --gui
option will display the plan in a 3D visualization.
Next, we will change the goal for the task-motion planning problem. The goal is specified as an Amino Scene File.
cp sussman-1.robray sussman-reversed.robray vi sussman-reversed.robray
/* include common definitions for blocks */ include "class.robray" /* the kinematic frame for block "C" */ frame block_c { parent block_b; // the parent from of block_c is block_b geometry { isa block; // geometry class for blocks } } /* the kinematic frame for block "B" */ frame block_b { parent block_a; // the parent frame of block_b is block_a geometry { isa block; // geometry class for blocks } }
tmsmt package://baxter_description/urdf/baxter.urdf \ sussman-0.robray \ allowed-collision.robray \ tm-blocks.pddl \ tm-blocks.py \ -q q0.tmp \ -g sussman-reversed.robray \ -o baxter-sussman-reversed.tmp \ --gui
Next, we will change both the start and goal scenes, also specified with as Amino Scene Files.
cp sussman-0.robray 4-blocks-start.robray vi 4-blocks-start.robray
/* the kinematic frame for block "D" */ frame block_d { parent block_b; // block_d is initially on block_b /* set the height of block_d above block_b */ translation [0, 0, block_stack]; geometry { isa block; color [0,1,1]; // block_d is cyan } }
aarxc --gui package://baxter_description/urdf/baxter.urdf 4-blocks-start.robray
cp sussman-1.tmp 4-blocks-goal.robray vi 4-blocks-goal.robray
frame block_d { parent block_a; // block "D" is stacked on block "A" /* set the relative height of block "D" */ translation [0, 0, block_stack]; geometry { isa block; } }
tmsmt package://baxter_description/urdf/baxter.urdf \ 4-blocks-start.robray \ allowed-collision.robray \ tm-blocks.pddl \ tm-blocks.py \ -q q0.tmp \ -g 4-blocks-goal.robray \ -o 4-blocks.tmp \ --gui
This tutorial demonstrates adding pure task operators. You will add operators to enable and disable a safety light. Then, you will modify the other preconditions to ensure that the robot only moves with the safety light on.
cp tm-blocks.pddl tm-blocks-light.pddl vi tm-blocks-light.pddl
(safety-light)
(:action enable-motion :parameters () :effect (and (safety-light)))
(:action disable-motion :parameters () :effect (and (not (safety-light))))
(safety-light)
predicate to the precondition of each motion action (pick-up
, stack
, etc.).vi light-goal.pddl
(define (problem sussman-anomaly) (:domain blocks) (:goal (not (safety-light))))
tmsmt package://baxter_description/urdf/baxter.urdf \ sussman-0.robray \ allowed-collision.robray \ tm-blocks-light.pddl \ light-goal.pddl \ tm-blocks.py \ -q q0.tmp \ -g baxter-sussman/sussman-1.robray \ -o baxter-sussman-light.tmp \ --gui \
This tutorial demonstrates adding new task-motion operators. You will add an operator to push a button when the robot finishes its task. In addition to creating the PDDL operator defintion as in the previous tutorial, you will also define the semantics of the operator: how to compute a motion plan for the operator. These domain semantics are defined as Python functions.
Create the additional frames and geometry for the button that the robot will push.
cp sussman-0.robray sussman-extend.robray vi sussman-extend.robray
sussman-extend.robray
: def button_height .05; frame button_base { parent front_table; translation [-.3, -.3, button_height/2]; geometry { shape box; dimension [.1, .1, button_height]; color [.5, .5, .5]; } } frame button { parent button_base; translation [0, 0, button_height/2]; geometry { shape cylinder; radius .025; height .03; color [1, 0, 0 ]; } }
Modify the operators file with an additional operator to push the button and a predicate indicating button state.
cp tm-blocks.pddl tm-blocks-extend.pddl vi tm-blocks-extend.pddl
(running)
.(running)
to the set of preconditions.(:action push-button :parameters () :precondition (and (handempty) (running)) :effect (and (not (running))))
Add additional start state and goal conditions for the button.
vi extended-facts.pddl
(define (problem itmp) (:domain blocks) ;; Start: running is true (:init (running)) ;; Goal: running is false (:goal (not (running))))
Create the refinement function for the push-button
action.
cp tm-blocks.py tm-blocks-extend.py vi tm-blocks-extend.py
def op_push_button(scene, config, op): # wrap start scene and configuration nop = tm.op_nop(scene,config) # compute the workspace goal, i.e., the button'spose ws_goal = tm.op_tf_abs(nop,"button") # compute a motion plan to push the button return motion_plan(nop, FRAME, tm.op_tf_abs(nop,"button"))
# Bind the refinement function for the PUSH-Button operator tm.bind_refine_operator(op_push_button, "PUSH-BUTTON")
tmsmt package://baxter_description/urdf/baxter.urdf \ sussman-extend-0.robray \ allowed-collision.robray \ tm-blocks-extend.pddl \ extended-facts.pddl \ tm-blocks-extend.py \ -q q0.tmp \ -g sussman-1.robray \ -o baxter-sussman-extend.tmp \ --gui