This is an old revision of the document!


Creating process modules

Description: TODO: this tutorial is not done yet. Refer to

http://wiki.ros.org/cram_pl/InternalTutorials

for more information.

Previous Tutorial: Creating designators for the turtlesim
Next Tutorial:

(defstruct turtle-shape
  "represents an object in continuous space matching a symbolic description"
  radius
  edges)


(cram-reasoning:def-fact-group shape-actions (action-desig)

  ;; for each kind of shape, call make-turtle-shape with the right number of edges

  ;; triangle
  (<- (action-desig ?desig (shape ?act))
    (desig-prop ?desig (type shape))
    (desig-prop ?desig (shape triangle))
    (lisp-fun make-turtle-shape :radius 1 :edges 3  ?act))

  ;; square
  (<- (action-desig ?desig (shape ?act))
    (desig-prop ?desig (type shape))
    (desig-prop ?desig (shape square))
    (lisp-fun make-turtle-shape :radius 1 :edges 4  ?act))

  ;; pentagon
  (<- (action-desig ?desig (shape ?act))
    (desig-prop ?desig (type shape))
    (desig-prop ?desig (shape pentagon))
    (lisp-fun make-turtle-shape :radius 1 :edges 5  ?act))

  ;; hexagon
  (<- (action-desig ?desig (shape ?act))
    (desig-prop ?desig (type shape))
    (desig-prop ?desig (shape hexagon))
    (lisp-fun make-turtle-shape :radius 1 :edges 6  ?act)))

(cram-process-modules:def-process-module turtle-actuators (action-designator)
  (roslisp:ros-info (turtle-process-modules) "Turtle navigation invoked with action designator `~a'." action-designator)
  (destructuring-bind (cmd action-goal) (reference action-designator)
    (ecase cmd
      (shape
         (call-shape-action
          :edges (turtle-shape-edges action-goal)
          :radius (turtle-shape-radius action-goal))))))


(defmacro with-turtle-process-module (&body body)
  `(cpm:with-process-modules-running
       (turtle-actuators)
     ,@body))


         
                   
(def-fact-group turtle-actuators (matching-process-module
                                         available-process-module)

  (<- (matching-process-module ?designator turtle-actuators)
    (or (desig-prop ?designator (type shape))))
(top-level (with-turtle-process-modules (with-designators (( my-desig (action '((type shape) (shape hexagon))))) (perform my-desig))))
Next