Verifying and Executing
(defun verify-and-execute-command (command)
(case (command-action command)
(when (verify-lift (command-object command))
(world-execute-command :LIFT)))
(when (verify-drop (command-object command))
(world-execute-command :DROP)))
(let ((positions (verify-move (command-destination command))))
(world-execute-command :MOVE (first positions)))))
(OTHERWISE (error "Unrecognized command ~a" (command-action command)))))
;;;****************************************************
(defun verify-lift (object)
(let* ((gripper-position (world-sense-gripper-position))
(gripper-contents (world-sense-gripper-contents))
(top-block (first (world-sense-position gripper-position))))
((not (null gripper-contents))
(format t "~%Execution error on LIFT: gripper not empty.~%")
(format t "~%Execution error on LIFT: no object to lift.~%")
((not (objects-agree object top-block gripper-position))
(format t "~%Execution error on LIFT: invalid object description~%")