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
Next revisionBoth sides next revision
tutorials:beginner:process_modules [2016/01/25 11:30] gkazhoyatutorials:beginner:process_modules [2016/01/25 17:13] – [Process modules: an overview] gkazhoya
Line 10: Line 10:
 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. You can read some more about process modules in the [[http://cram-system.org/doc/package/cram_process_modules|documentation of the package]]. 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. You can read some more about process modules in the [[http://cram-system.org/doc/package/cram_process_modules|documentation of the package]].
  
-For better organization, process modules can also be referenced by aliases that describe what kind of function they can perform. Currently, in the ''cram_pr2'' stack for the PR2 mobile manipulation platform the following aliases are defined:+For better organization, process modules can also be referenced by aliases that describe what kind of function they can perform. For examplecurrently in the ''cram_pr2'' stack for the PR2 mobile manipulation platform the following aliases are defined:
  
   * :navigation   * :navigation
Line 170: Line 170:
  
 <code lisp> <code lisp>
-(defun draw-hexagon (r)+(defun draw-hexagon (radius)
   (let ((turtle-name "turtle1"))   (let ((turtle-name "turtle1"))
     (start-ros-node turtle-name)     (start-ros-node turtle-name)
Line 176: Line 176:
     (top-level     (top-level
       (with-turtle-process-modules       (with-turtle-process-modules
-        (cpm:process-module-alias :manipulation 'turtle-actuators) +        (process-module-alias :navigation 'turtle-actuators) 
-          (cram-language-designator-support:with-designators +        (with-designators 
-            ((trajectory (action `((type shape) (shape hexagon) (radius ,r))))) +            ((trajectory :action `((:type :shape) (:shape :hexagon) (:radius ,radius)))) 
-            (cpm:pm-execute :manipulation trajectory))))))+          (pm-execute :navigation trajectory))))))
 </code> </code>
  
-What the function does is simply start a ROS node for our turtle and sets up the action client, then activates the turtle process modules (in our case, the sole existing one), creates a designator to describe how the turtle should move, and calls the cpm:pm-execute macro to have the process module follow the trajectory specified by the designator. +What the function does is simply start a ROS node for our turtle and sets up the action client, then activates the turtle process modules (in our case, the sole existing one), creates a designator to describe how the turtle should move, and calls the ''cram-process-modules:pm-execute'' macro to have the process module follow the trajectory specified by the designator. 
  
-Two other things to observe here are the use of the top-level macro, which sets up a CRAM running context and is needed for with-turtle-process-modules. Also, we declare that :manipulation is the alias for our turtle-actuators process module. That way, our plan can invoke a generic name like :manipulation, rather than a robot-specific one like turtle-actuators.+Two other things to observe here are the use of the ''top-level'' macro, which sets up a CRAM running context and is needed for ''with-turtle-process-modules''. Also, we declare that '':navigation'' is the alias for our turtle-actuators process module. That way, our plan can invoke a generic name like '':navigation'', rather than a robot-specific one like turtle-actuators.
  
 Reload the tutorial in REPL, and let's try to start the tutorial Reload the tutorial in REPL, and let's try to start the tutorial
  
 <code lisp> <code lisp>
-TUT> (draw-hexagon 3+TUT> (draw-hexagon 2
-[(ROSLISP TOP) INFO] 1413894471.489: Node name is /turtle1 +[(ROSLISP TOP) INFO] 1453721727.445: Node name is /turtle1 
-[(ROSLISP TOP) INFO] 1413894471.489: Namespace is / +[(ROSLISP TOP) INFO] 1453721727.446: Namespace is / 
-[(ROSLISP TOP) INFO] 1413894471.489: Params are NIL +[(ROSLISP TOP) INFO] 1453721727.446: Params are NIL 
-[(ROSLISP TOP) INFO] 1413894471.489: Remappings are: +[(ROSLISP TOP) INFO] 1453721727.446: Remappings are: 
-[(ROSLISP TOP) INFO] 1413894471.489: master URI is 127.0.0.1:11311 +[(ROSLISP TOP) INFO] 1453721727.446: master URI is 127.0.0.1:11311 
-[(ROSLISP TOP) INFO] 1413894472.493: Node startup complete +[(ROSLISP TOP) INFO] 1453721728.452: Node startup complete 
-[(TURTLE-PROCESS-MODULES) INFO] 1413894472.501: Turtle navigation invoked with action designator `#<ACTION-DESIGNATOR ((TYPE+[(TURTLE-PROCESS-MODULES) INFO] 1453721728.467: Turtle navigation invoked with action designator `#<ACTION-DESIGNATOR ((TYPE
                                                                         SHAPE)                                                                         SHAPE)
                                                                        (SHAPE                                                                        (SHAPE
                                                                         HEXAGON)                                                                         HEXAGON)
                                                                        (RADIUS                                                                        (RADIUS
-                                                                        3)) {10084BC463}>'.+                                                                        2)) {10056DB513}>'.
 An error occured! An error occured!
 Client lost connection to server. Client lost connection to server.
 Reinitializing... Reinitializing...
  
-[(TURTLE-SHAPE-ACTION-CLIENT) INFO] 1413894480.479: Waiting for turtle shape action server... +[(TURTLE-SHAPE-ACTION-CLIENT) INFO] 1453721736.385: Waiting for turtle shape action server... 
-[(TURTLE-SHAPE-ACTION-CLIENT) INFO] 1413894482.480: Turtle shape action client created. +[(TURTLE-SHAPE-ACTION-CLIENT) INFO] 1453721738.386: Turtle shape action client created. 
-[(TURTLE-SHAPE-ACTION-CLIENT) INFO] 1413894505.711: Nav action finished.+[(TURTLE-SHAPE-ACTION-CLIENT) INFO] 1453721761.206: Nav action finished.
 [TURTLE_ACTIONLIB-MSG:SHAPERESULT [TURTLE_ACTIONLIB-MSG:SHAPERESULT
    INTERIOR_ANGLE:    INTERIOR_ANGLE:
      2.094395160675049d0      2.094395160675049d0
    APOTHEM:    APOTHEM:
-     2.598076105117798d0]+     1.7320507764816284d0]
 :SUCCEEDED :SUCCEEDED
 </code> </code>