Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
tutorials:intermediate:performing_plans [2016/07/21 14:58] – created gkazhoya | tutorials:intermediate:performing_plans [2022/03/30 21:26] – [Plan goals] schimpf | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Performing | + | ====== Performing |
+ | |||
+ | ===== Basic functionality | ||
This is a short tutorial to showcase how to call plans through performing action designators. | This is a short tutorial to showcase how to call plans through performing action designators. | ||
- | Let's first load the plan library system | + | Let's first load the CRAM plan library system: |
<code lisp> | <code lisp> | ||
- | CL-USER> (ros-load: | + | CL-USER> (ros-load: |
- | ;; or ,r-l-s RET cram_plan_library | + | ;; or ,r-l-s RET cram_executive |
- | CL-USER> (in-package : | + | |
</ | </ | ||
Line 14: | Line 15: | ||
<code lisp> | <code lisp> | ||
- | PLAN-LIB> (cpl: | + | CL-USER> (cpl: |
- | (format t " | + | |
+ | | ||
</ | </ | ||
Line 21: | Line 23: | ||
<code lisp> | <code lisp> | ||
- | PLAN-LIB> (prolog: | + | CL-USER> (prolog: |
- | (prolog:< | + | |
- | (desig: | + | (desig: |
- | (desig: | + | (desig: |
</ | </ | ||
Now let's try to perform the designator we just defined. | Now let's try to perform the designator we just defined. | ||
- | Pay attention that `perform` calls can only be done within a task tree. | + | Pay attention that '' |
<code lisp> | <code lisp> | ||
- | PLAN-LIB> (cpl: | + | CL-USER> (cpl: |
- | (cpl:perform (desig:an action (to eat) (yummy pizza)))) | + | |
+ | hmmm... nomnomnom... PIZZA | ||
+ | NIL | ||
+ | #<A ACTION | ||
+ | (TO EAT) | ||
+ | (YUMMY PIZZA)> | ||
+ | </ | ||
+ | ===== Plan goals ===== | ||
+ | |||
+ | Now, let's assume that our action has an explicit effect we would like to follow: | ||
+ | |||
+ | <code lisp> | ||
+ | CL-USER> (cpl: | ||
+ | | ||
+ | WARNING: | ||
+ | | ||
+ | | ||
hmmm... nomnomnom... PIZZA | hmmm... nomnomnom... PIZZA | ||
+ | WARNING: | ||
+ | | ||
+ | | ||
+ | ; Evaluation aborted on #< | ||
</ | </ | ||
+ | We get an error that the goal of the action was not achieved by the end of performing this action. | ||
+ | |||
+ | Let's add that: | ||
+ | |||
+ | <code lisp> | ||
+ | CL-USER> (defparameter *pizza-eaten-p* nil) | ||
+ | *PIZZA-EATEN-P* | ||
+ | CL-USER> (cpl: | ||
+ | | ||
+ | | ||
+ | (setf *pizza-eaten-p* t)) | ||
+ | ; in: CRAM-LANGUAGE-IMPLEMENTATION: | ||
+ | ; (TYPE (OR STRING NULL) ?YUMMY) | ||
+ | ; | ||
+ | ; caught WARNING: | ||
+ | ; | ||
+ | ; | ||
+ | ; compilation unit finished | ||
+ | ; | ||
+ | ; ? | ||
+ | ; | ||
+ | EAT | ||
+ | CL-USER> (prolog: | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | We defined a new world state '' | ||
+ | |||
+ | Let's now call the perform action again: | ||
+ | |||
+ | <code lisp> | ||
+ | PLAN-LIB> | ||
+ | (exe: | ||
+ | hmmm... nomnomnom... PIZZA | ||
+ | NIL | ||
+ | </ | ||
+ | |||
+ | ===== Restrictions ===== | ||
+ | |||
+ | Please keep in mind that if there are multiple solutions to a particular action designator, i.e. it resolves to different plans, the first one that is defined will be executed. Ordering is not yet implemented and should probably be taken care of explicitly in the plans anyway. | ||
+ | Summary: **make sure an action designator you use for plans can only be resolved to one unique CRAM plan.** |