User Tools

Site Tools


software:cram:development_experiences:new_goals

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
software:cram:development_experiences:new_goals [2013/04/26 11:22] – created bartelsgsoftware:cram:development_experiences:new_goals [2016/05/19 09:19] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ===== How to register and achieve a new goal ===== ===== How to register and achieve a new goal =====
 +
 +==== A plan for a new goal ====
 +
 +Let's assume we wanna write a plan to achieve a new goal, e.g. to flip a pancake. Best practice is to put this plan into one of the source-files of a plan library, e.g. cram_plan_library:
 +
 +
 +<code lisp>
 +(def-goal (achieve (flip-pancake ...))
 +  (with-designators ((action-desig 
 +                       (action `((to flip))))
 +                     ...)
 +    ...
 +    (perform action)))
 +</code>
 +
 +If you want other packages to also use this plan, export the goal-symbol in the package.lisp of the your plan library. Make sure to also export all designator properties used in your plan:
 +
 +<code lisp>
 +(desig-props:def-desig-package cram-plan-library
 + ...
 + (:export #:...
 +          #:flip-pancake
 +          ...)
 + (:desig-properties #:to #:flip ...))
 +</code>
 +
 +Catch #1: If you one of your manipulation process modules, e.g. the pr2_manipulation_process_module, uses the same designator properties it also has to export the same properties. I (Georg) do not understand why but Jan says this necessary for them to talk about the same symbol.
 +
 +Catch #2: You also need to export the goal-symbol, i.e. flip-pancake, from the package cram_plan_knowledge! The reason for this was not clear at the time of writing... Thus, yuo also need to add #:flip-pancake to package.lisp of cram_plan_library. Otherwise you will get a warning like this when trying to achieve flip-pancake:
 +
 +<code>
 +WARNING:
 +   Trying to prove goal (FLIP-PANCAKE
 +                         #<OBJECT-DESIGNATOR ((TYPE PANCAKE))
 +                           {100926AF61}>) with undefined functor CRAM-PLAN-LIBRARY:FLIP-PANCAKE.
 +</code>
 +==== How to use/achieve the new plan ====
 +
 +You can now try to achieve your new goal like this:
 +
 +<code lisp>
 +(top-level
 +  (cpm:with-process-modules-running
 +      (pr2-manipulation-process-module)
 +    (achieve `(flip-pancake))))
 +</code>
 +
 +You need to make sure that cram_environment_representation is loaded (either in your package that uses cram_plan_library or in your REPL). Otherwise (holds ...) will not be known.
software/cram/development_experiences/new_goals.1366975359.txt.gz · Last modified: 2016/05/19 09:18 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki