Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorials:beginner:location_designators [2016/01/25 21:23] – gkazhoya | tutorials:beginner:location_designators [2016/03/04 14:25] (current) – old revision restored (2016/01/26 10:38) gkazhoya | ||
|---|---|---|---|
| Line 56: | Line 56: | ||
| </ | </ | ||
| - | Now we'll want some code to generate a location based on a symbolic description found in a designator. There are two interfaces for resolving location designators: | + | Now we'll want some code to generate a location based on a symbolic description found in a designator. There are two interfaces for resolving location designators: |
| We would like to specify locations for the turtle to go using spatial relations, e.g.: | We would like to specify locations for the turtle to go using spatial relations, e.g.: | ||
| Line 209: | Line 209: | ||
| </ | </ | ||
| + | This will resolve any action designator with properties '' | ||
| - | '' | + | Now for the process module, let's add a new process module called '' |
| <code lisp> | <code lisp> | ||
| + | (in-package :tut) | ||
| + | |||
| + | (def-process-module actionlib-navigation (action-designator) | ||
| + | (roslisp: | ||
| + | " | ||
| + | action-designator) | ||
| + | (destructuring-bind (command action-goal) (reference action-designator) | ||
| + | (ecase command | ||
| + | (draw-shape | ||
| + | | ||
| + | :edges (turtle-shape-edges action-goal) | ||
| + | :radius (turtle-shape-radius action-goal)))))) | ||
| + | |||
| (def-process-module simple-navigation (action-designator) | (def-process-module simple-navigation (action-designator) | ||
| (roslisp: | (roslisp: | ||
| - | " | + | " |
| - | | + | |
| - | (let ((target-pose (reference | + | |
| - | | + | (ecase command |
| - | | + | (go-to |
| + | (when (typep action-goal ' | ||
| + | (let ((target-point (reference | ||
| + | | ||
| + | " | ||
| + | | ||
| - | (defun goto-location | + | (defmacro with-turtle-process-modules |
| + | `(with-process-modules-running | ||
| + | | ||
| + | simple-navigation) | ||
| + | , | ||
| + | |||
| + | (defun draw-hexagon (radius) | ||
| (let ((turtle-name " | (let ((turtle-name " | ||
| (start-ros-node turtle-name) | (start-ros-node turtle-name) | ||
| (init-ros-turtle turtle-name) | (init-ros-turtle turtle-name) | ||
| (top-level | (top-level | ||
| - | (cpm:with-process-modules-running | + | (with-turtle-process-modules |
| - | (cpm: | + | |
| - | (cpm:pm-execute : | + | (with-designators |
| + | ((trajectory | ||
| + | (pm-execute :navigation trajectory)))))) | ||
| + | |||
| + | (defun goto-location (horizontal-position vertical-position) | ||
| + | (let ((turtle-name " | ||
| + | (start-ros-node turtle-name) | ||
| + | (init-ros-turtle turtle-name) | ||
| + | (top-level | ||
| + | (with-turtle-process-modules | ||
| + | (process-module-alias :navigation 'simple-navigation) | ||
| + | (with-designators | ||
| + | ((area :location `((: | ||
| + | | ||
| + | (goal :action `((:type :goal) (:goal ,area)))) | ||
| + | (pm-execute : | ||
| </ | </ | ||
| - | And let's give it a go. Reload the tutorial | + | And let's give it a go. Reload the tutorial |
| <code lisp> | <code lisp> | ||
| - | TUT> (defparameter turtle-target (make-designator ' | + | TUT> (goto-location :center |
| - | TURTLE-TARGET | + | [(ROSLISP TOP) INFO] 1453758117.881: Node name is /turtle1 |
| - | TUT> (goto-location | + | [(ROSLISP TOP) INFO] 1453758117.881: Namespace is / |
| - | WARNING: | + | [(ROSLISP TOP) INFO] 1453758117.885: Params are NIL |
| - | | + | [(ROSLISP TOP) INFO] 1453758117.885: Remappings are: |
| - | [(ROSLISP EVENT-LOOP) INFO] 1414081756.703: | + | [(ROSLISP TOP) INFO] 1453758117.885: master URI is 127.0.0.1: |
| - | [(ROSLISP TOP) INFO] 1414081757.022: | + | [(ROSLISP TOP) INFO] 1453758119.036: Node startup complete |
| - | [(ROSLISP TOP) INFO] 1414081757.028: Node name is /turtle1 | + | [(TURTLE-PROCESS-MODULES) INFO] 1453758119.377: Turtle |
| - | [(ROSLISP TOP) INFO] 1414081757.028: Namespace is / | + | `#<ACTION-DESIGNATOR ((TYPE GOAL) |
| - | [(ROSLISP TOP) INFO] 1414081757.028: Params are NIL | + | (GOAL #< |
| - | [(ROSLISP TOP) INFO] 1414081757.028: Remappings are: | + | |
| - | [(ROSLISP TOP) INFO] 1414081757.028: master URI is 127.0.0.1: | + | [(TURTLE-PROCESS-MODULES) INFO] 1453758119.386: |
| - | [(ROSLISP TOP) INFO] 1414081758.033: Node startup complete | + | |
| - | [(TURTLE-PROCESS-MODULES) INFO] 1414081758.183: Turtle navigation invoked with location | + | |
| - | CENTER) | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | #<CL-TRANSFORMS: | + | |
| T | T | ||
| </ | </ | ||
| - | The turtle should also have moved to somewhere in the vecinity | + | The turtle should also have moved to somewhere in the vicinity |
| == Next == | == Next == | ||

