Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:beginner:process_modules [2014/10/21 10:43] – Added "Process module overview" section. mpomarlan | doc:beginner:process_modules [2015/05/11 17:01] (current) – removed gkazhoya | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Creating process modules ====== | ||
- | |||
- | **Description: | ||
- | |||
- | **Previous Tutorial:** [[doc: | ||
- | **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, | ||
- | |||
- | For better organization, | ||
- | |||
- | * :navigation | ||
- | * :ptu | ||
- | * : | ||
- | * :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 ' | ||
- | (pm-execute :navigation my-designator)) | ||
- | </ | ||
- | |||
- | 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. | ||
- | |||
- | < | ||
- | (defstruct turtle-shape | ||
- | " | ||
- | radius | ||
- | edges) | ||
- | |||
- | |||
- | (cram-reasoning: | ||
- | |||
- | ;; 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: | ||
- | (roslisp: | ||
- | (destructuring-bind (cmd action-goal) (reference action-designator) | ||
- | (ecase cmd | ||
- | (shape | ||
- | | ||
- | :edges (turtle-shape-edges action-goal) | ||
- | :radius (turtle-shape-radius action-goal)))))) | ||
- | |||
- | |||
- | (defmacro with-turtle-process-module (&body body) | ||
- | `(cpm: | ||
- | | ||
- | , | ||
- | |||
- | |||
- | |||
- | |||
- | (def-fact-group turtle-actuators (matching-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 ' | ||
- | </ | ||
- | |||
- | |||
- | == Next == | ||
- | |||
- | |||