Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:beginner:process_modules [2014/10/21 10:43] – Added "Process module overview" section. mpomarlandoc:beginner:process_modules [2015/05/11 17:01] (current) – removed gkazhoya
Line 1: Line 1:
-====== Creating process modules ====== 
- 
-**Description:** in this tutorial you will learn about CRAM process modules and write a simple one to move the turtlesim. 
- 
-**Previous Tutorial:** [[doc:beginner:designators|Creating designators for the turtlesim]]\\ 
-**Next Tutorial:**  
- 
-===== Process modules: an overview ===== 
- 
-A process module is a program that controls a robot actuator. Different robots will have different kinds of actuators, requiring different kinds of controllers, and we would like to abstract away such specifics at the high level of task specification. When we ask a robot to clean a kitchen, we don't care that it has two arms or one; rather, as long as it has some capacity to manipulate objects, and some ability to move around, we can issue the cleaning task to it. Process modules allow us this flexibility by providing a well-defined, robot-independent interface to high level planning which works as an abstraction layer over the robot controllers. 
- 
-For better organization, process modules can also be referenced by aliases that describe what kind of function they can perform. Currently, in the cram_highlevel stack for manipulation platforms the following aliases are defined: 
- 
-  * :navigation 
-  * :ptu 
-  * :manipulation 
-  * :perception 
- 
-A plan will typically refer to a process module by the alias. The process module would be defined for the particular robot in use and associated with the proper alias when the system is initialized. 
- 
-Here's an example of invoking a process module: 
- 
-<code lisp> 
-(with-designators ((my-designator (location '((close-to 'fridge))))) 
-  (pm-execute :navigation my-designator)) 
-</code> 
- 
-This will run a process module associated to :navigation and use my-designator to pass parameters to it. In this case, the designator is a semantic description of a target location and it's up to the process module to ask that this designator be resolved (by some appropriate other module in the system) so as to get an actual location and then control the robot to reach the target. The specifics of the controller may vary enormously; the robot might be differential drive, or legged. But these details are not important for this high level plan. All we want is for the robot to approach the fridge, in whatever way it can carry itself there. 
- 
-<code> 
-(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)))) 
- 
-</code> 
-<code> 
-(top-level (with-turtle-process-modules (with-designators (( my-desig (action '((type shape) (shape hexagon))))) (perform my-desig)))) 
-</code> 
- 
- 
-== Next == 
- 
-