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 11:26] – Added "Writing a process module for the turtlesim" 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. | ||
- | |||
- | ===== Writing a process module for the turtlesim ===== | ||
- | |||
- | Once again, some new dependencies must be declared in the tutorial files you've been working on. | ||
- | |||
- | In your package.xml file you need to add build and runtime dependencies on actionlib_lisp, | ||
- | |||
- | < | ||
- | < | ||
- | < | ||
- | < | ||
- | |||
- | < | ||
- | < | ||
- | < | ||
- | </ | ||
- | |||
- | Similarly, in your .asd file you should add actionlib, actionlib_tutorials-msg, | ||
- | |||
- | <code lisp> | ||
- | (defsystem cram-beginner-tutorial-workthrough | ||
- | :depends-on (roslisp cram-language turtlesim-msg cl-transforms geometry_msgs-msg designators cram-reasoning | ||
- | | ||
- | :components | ||
- | ((:module " | ||
- | :components | ||
- | ((:file " | ||
- | | ||
- | </ | ||
- | |||
- | ==== A process module for the turtlesim ==== | ||
- | |||
- | We first need to connect to the turtlesim as a client for an action that will have the turtle draw a shape. To do this, append the following to your tutorial.lisp file | ||
- | |||
- | <code lisp> | ||
- | (defvar *navp-client* nil) | ||
- | |||
- | (defun init-action-client () | ||
- | (setf *navp-client* (actionlib: | ||
- | " | ||
- | " | ||
- | (roslisp: | ||
- | " | ||
- | ;; workaround for race condition in actionlib wait-for server | ||
- | (loop until | ||
- | (actionlib: | ||
- | (roslisp: | ||
- | " | ||
- | |||
- | (defun get-action-client () | ||
- | (when (null *navp-client*) | ||
- | (init-action-client)) | ||
- | *navp-client*) | ||
- | </ | ||
- | |||
- | The above code simply declares a variable *navp-client* which we can then initialize with a pointer to our ros action client and retrieve this pointer later with the init-action-client and get-action-client functions, respectively. | ||
- | |||
- | <code lisp> | ||
- | (defun make-shape-action-goal (in-edges in-radius) | ||
- | (actionlib: | ||
- | edges in-edges | ||
- | radius in-radius)) | ||
- | |||
- | (defun call-shape-action (&key edges radius) | ||
- | (multiple-value-bind (result status) | ||
- | (with-failure-handling | ||
- | ((simple-error (e) | ||
- | | ||
- | (setf *navp-client* nil) | ||
- | | ||
- | (let ((actionlib: | ||
- | (actionlib: | ||
- | | ||
- | | ||
- | (roslisp: | ||
- | (values result status))) | ||
- | </ | ||
- | |||
- | < | ||
- | (top-level (with-turtle-process-modules (with-designators (( my-desig (action ' | ||
- | </ | ||
- | |||
- | |||
- | == Next == | ||
- | |||
- | |||