Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pddl_planner/demos/2013_fridge_demo] fix bug #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 53 additions & 46 deletions pddl/pddl_planner/demos/2013_fridge_demo/solve-bring-can.l
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,16 @@
(AT PREGRASP))
:effect '((ONHAND ?OBJ)))

(instance pddl-action :init
:name "grasp_f"
:parameters '((?OBJ object))
:precondition '((NOT (ONHAND ?OBJ))
(NOT (CLOSED))
(AT PREGRASP))
:effect '())

(instance pddl-action :init
:name "move-to"
:parameters '((?FROM ?TO spot))
:precondition '((AT ?FROM)
(NOT (= ?FROM SOMEWHERE))
(NOT (= ?FROM ?TO)))
:effect '((AT ?TO)
(NOT (AT ?FROM))))
(instance pddl-action :init
:name "move-to_f"
:parameters '((?FROM ?TO spot))
:precondition '((AT ?FROM)
(NOT (= ?TO SOMEWHERE))
(NOT (= ?FROM ?TO)))
:effect '((AT SOMEWHERE)
:effect '((AT ?TO)
(NOT (AT ?FROM))))

(instance pddl-action :init
:name "move-recoverly"
:parameters '()
Expand All @@ -87,13 +73,6 @@
:effect '((AT FRONTFRIDGE)
(NOT (AT SOMEWHERE))))

(instance pddl-action :init
:name "move_rec_f"
:parameters '()
:precondition '((AT SOMEWHERE)
(CLOSED))
:effect '())

(instance pddl-action :init
:name "open-door"
:parameters '()
Expand All @@ -102,42 +81,20 @@
(CLOSED))
:effect '((NOT (CLOSED))))

(instance pddl-action :init
:name "open_f"
:parameters '()
:precondition '((AT FRONTFRIDGE)
(NOT (ONHAND CAN))
(CLOSED))
:effect '())

(instance pddl-action :init
:name "close-door"
:parameters '()
:precondition '((NOT (CLOSED))
(AT PRECLOSE))
:effect '((CLOSED)))

(instance pddl-action :init
:name "close_f"
:parameters '()
:precondition '((NOT (CLOSED))
(AT PRECLOSE))
:effect '())

(instance pddl-action :init
:name "try-close"
:parameters '()
:precondition '((NOT (CLOSED))
(AT SOMEWHERE))
:effect '((CLOSED)))

(instance pddl-action :init
:name "close_try_f"
:parameters '()
:precondition '((NOT (CLOSED))
(AT SOMEWHERE))
:effect '())

))
;;add action to domain
(dolist (act *action-list*)
Expand All @@ -146,7 +103,57 @@
;;
;; solve planning
;;
(setq *failed-nodes* (list 'move-to))
(setq *failed-nodes*
(list
(list 'move-to
(instance pddl-action :init
:name "move-to_f"
:parameters '((?FROM ?TO spot))
:precondition '((AT ?FROM)
(NOT (= ?FROM SOMEWHERE))
(NOT (= ?TO SOMEWHERE))
(NOT (= ?FROM ?TO)))
:effect '((AT SOMEWHERE)
(NOT (AT ?FROM)))))
(list 'grasp-object
(instance pddl-action :init
:name "grasp_f"
:parameters '((?OBJ object))
:precondition '((NOT (ONHAND ?OBJ))
(NOT (CLOSED))
(AT PREGRASP))
:effect '()))
(list 'move-recoverly
(instance pddl-action :init
:name "move_rec_f"
:parameters '()
:precondition '((AT SOMEWHERE)
(CLOSED))
:effect '()))
(list 'open-door
(instance pddl-action :init
:name "open_f"
:parameters '()
:precondition '((AT FRONTFRIDGE)
(NOT (ONHAND CAN))
(CLOSED))
:effect '()))

(list 'close-door
(instance pddl-action :init
:name "close_f"
:parameters '()
:precondition '((NOT (CLOSED))
(AT PRECLOSE))
:effect '()))
(list 'try-close
(instance pddl-action :init
:name "close_try_f"
:parameters '()
:precondition '((NOT (CLOSED))
(AT SOMEWHERE))
:effect '()))
))
(setq *graph*
(pddl-plan-to-graph nil :domain *domain* :problem *problem* :failed-nodes *failed-nodes* :debug t))
(pprint *result*)
Expand Down
36 changes: 22 additions & 14 deletions pddl/pddl_planner/src/eus-pddl.l
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,17 @@
))

(:check-condition (st act)
(let ((action (find-if #'(lambda (x)
(equal
(or
(and (send self :use-durative-action)
(caaddr act))
(car act))
(intern (string-upcase (send x :name))))) (send domain :action)))
(let ((action (if (and (not (atom (car act)))
(not (send self :use-durative-action))
(derivedp (caar act) pddl-action))
(caar act)
(find-if #'(lambda (x)
(equal
(or
(and (send self :use-durative-action)
(caaddr act))
(car act))
(intern (string-upcase (send x :name))))) (send domain :action))))
param pcond)
(unless action
(return-from :check-condition nil))
Expand Down Expand Up @@ -707,13 +711,17 @@
))
(:apply-action (st act)
(if (send self :check-condition st act)
(let ((action (find-if #'(lambda (x)
(equal
(or
(and (send self :use-durative-action)
(caaddr act))
(car act))
(intern (string-upcase (send x :name))))) (send domain :action)))
(let ((action (if (and (not (atom (car act)))
(not (send self :use-durative-action))
(derivedp (caar act) pddl-action))
(caar act)
(find-if #'(lambda (x)
(equal
(or
(and (send self :use-durative-action)
(caaddr act))
(car act))
(intern (string-upcase (send x :name))))) (send domain :action))))
param effect (tmp-st st))
(unless action
(return-from :apply-action nil))
Expand Down
Loading