Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:beginner:high_level_plans [2017/08/17 13:50] – [Writings plans for the TurtleSim] cpo | tutorials:beginner:high_level_plans [2022/03/15 13:29] (current) – [Writing the plans] schimpf | ||
---|---|---|---|
Line 3: | Line 3: | ||
**Description: | **Description: | ||
- | **Previous Tutorial:** [[tutorials: | + | **Previous Tutorial:** [[tutorials: |
+ | **Next Tutorial:** [[tutorials: | ||
+ | To run the code in the tutuorial the roscore and the turtlesim need to be started over the terminal. Each in their own tab. | ||
+ | <code bash> | ||
+ | $ roscore | ||
+ | </ | ||
+ | <code bash> | ||
+ | $ rosrun turtlesim turtlesim_node | ||
+ | </ | ||
+ | |||
+ | And in the REPL the following commands should be executed: | ||
+ | <code lisp> | ||
+ | CL-USER> | ||
+ | ... | ||
+ | CL-USER> | ||
+ | ... | ||
+ | TUT> | ||
+ | </ | ||
===== Designators: | ===== Designators: | ||
- | On a pragmatic level there is not a big difference between action and motion designators since both are a set of key-value pairs. But the difference lies in the semantics. As mentioned in an earlier tutorial about motion designators, | + | On a pragmatic level there is not a big difference between action and motion designators since both are a set of key-value pairs. But the difference lies in the semantics. As mentioned in an earlier tutorial about motion designators, |
This difference comes to play when designators are '' | This difference comes to play when designators are '' | ||
Line 20: | Line 37: | ||
==== Defining the action designators ==== | ==== Defining the action designators ==== | ||
- | Let's create new source files for the code in this tutorial (under the '' | + | Let's create new source files for the code in this tutorial (under the '' |
<code lisp> | <code lisp> | ||
- | (defsystem cram-beginner-tutorial | + | (defsystem cram-my-beginner-tutorial |
:depends-on (roslisp cram-language turtlesim-msg turtlesim-srv cl-transforms geometry_msgs-msg cram-designators cram-prolog | :depends-on (roslisp cram-language turtlesim-msg turtlesim-srv cl-transforms geometry_msgs-msg cram-designators cram-prolog | ||
| | ||
Line 56: | Line 73: | ||
TUT> (desig:an action (type drawing) (shape rectangle) (width 5) (height 4)) | TUT> (desig:an action (type drawing) (shape rectangle) (width 5) (height 4)) | ||
- | #<ACTION-DESIGNATOR ((:TYPE :DRAWING) (:SHAPE :RECTANGLE) (:WIDTH 5) | + | #<A ACTION |
- | | + | |
+ | | ||
+ | | ||
+ | (HEIGHT 4)> | ||
</ | </ | ||
Line 76: | Line 96: | ||
| | ||
(list | (list | ||
- | (list x y 0) | ||
(list (+ x base-width) y 0) | (list (+ x base-width) y 0) | ||
- | (list (/ (float | + | (list (+ x (/ (float base-width) 2)) (+ y height) |
+ | (list x y 0)))) | ||
(:rectangle | (:rectangle | ||
(let ((width (first parameters)) | (let ((width (first parameters)) | ||
| | ||
(list | (list | ||
- | (list x y 0) | ||
(list (+ x width) y 0) | (list (+ x width) y 0) | ||
(list (+ x width) (+ y height) 0) | (list (+ x width) (+ y height) 0) | ||
- | (list x (+ y height) 0))))))) | + | (list x (+ y height) |
+ | (list x y 0))))))) | ||
- | (def-fact-group turtle-action-designators (action-desig) | + | (def-fact-group turtle-action-designators (action-grounding) |
- | (<- (desig: | + | |
- | (desig-prop ?desig (:type : | + | |
- | (desig-prop ?desig (:shape :house))) | + | |
- | (<- (desig: | + | (<- (desig: |
- | (desig-prop ?desig (:type : | + | (desig-prop ?action-designator (:type : |
- | (desig-prop ?desig (:shape : | + | (desig-prop ? |
- | (desig-prop ?desig (:width ?width)) | + | |
- | (desig-prop ?desig (:height ?height)) | + | (<- (desig: |
- | (lisp-fun get-shape-vertices :rectangle | + | (desig-prop ? |
+ | (desig-prop ? | ||
+ | |||
+ | (<- (desig: | ||
+ | (desig-prop ?action-designator | ||
+ | (desig-prop ?action-designator (:shape : | ||
+ | (desig-prop ? | ||
+ | (desig-prop ? | ||
+ | (lisp-fun get-shape-vertices | ||
+ | (desig: | ||
+ | (:vertices ? | ||
+ | ? | ||
+ | |||
+ | (<- (desig: | ||
+ | (desig-prop ?action-designator (:type : | ||
+ | (desig-prop ? | ||
+ | (desig-prop ? | ||
+ | (desig-prop ?action-designator | ||
+ | (lisp-fun get-shape-vertices :triangle | ||
+ | (desig: | ||
+ | (:vertices ? | ||
+ | ? | ||
- | (<- (desig: | ||
- | (desig-prop ?desig (:type :drawing)) | ||
- | (desig-prop ?desig (:shape :triangle)) | ||
- | (desig-prop ?desig (: | ||
- | (desig-prop ?desig (:height ?height)) | ||
- | (lisp-fun get-shape-vertices :triangle ?base-width ?height ? | ||
</ | </ | ||
- | Let's see what this code does. The function '' | + | Let's see what this code does. The function '' |
- | The inference is simple again: it maps the shape value to the right call to '' | + | The inference is simple again: it maps the shape value to the right call to '' |
Reload the tutorial package in '' | Reload the tutorial package in '' | ||
Line 121: | Line 153: | ||
TUT> (reference (desig:an action (type drawing) (shape rectangle) (width 5) (height 4))) | TUT> (reference (desig:an action (type drawing) (shape rectangle) (width 5) (height 4))) | ||
(DRAW-SIMPLE-SHAPE | (DRAW-SIMPLE-SHAPE | ||
- | ((3.077953338623047d0 11.088889122009277d0 | + | #<A ACTION |
- | (8.077953338623047d0 11.088889122009277d0 | + | (TYPE DRAWING) |
- | (8.077953338623047d0 15.088889122009277d0 | + | (VERTICES |
- | (3.077953338623047d0 15.088889122009277d0 | + | |
+ | | ||
+ | | ||
TUT> (reference (desig:an action (type drawing) (shape house))) | TUT> (reference (desig:an action (type drawing) (shape house))) | ||
- | (DRAW-HOUSE) | + | (DRAW-HOUSE |
+ | #< | ||
+ | (TYPE DRAWING) | ||
+ | (SHAPE HOUSE)>) | ||
</ | </ | ||
==== Writing the plans ==== | ==== Writing the plans ==== | ||
+ | |||
+ | > Disclaimer: In this tutorial we omit the package ('' | ||
Append the following to your '' | Append the following to your '' | ||
Line 137: | Line 176: | ||
(in-package :tut) | (in-package :tut) | ||
- | (defun | + | (defun |
- | | + | & |
- | (exe:perform (a motion (type moving) (goal ?goal))) | + | (declare |
- | (exe:perform (a motion | + | |
- | + | ||
- | (defun draw-house () | + | |
(with-fields (x y) | (with-fields (x y) | ||
(value *turtle-pose*) | (value *turtle-pose*) | ||
(exe: | (exe: | ||
- | (move-without-pen (list (+ x 3) y 0)) | + | (navigate-without-pen (list (+ x 3) y 0)) |
(exe: | (exe: | ||
- | (move-without-pen (list (+ x 0.5) (+ y 2) 0)) | + | (navigate-without-pen (list (+ x 0.5) (+ y 2) 0)) |
(exe: | (exe: | ||
- | (move-without-pen (list x (+ y 4) 0)) | + | (navigate-without-pen (list x (+ y 4.5) 0)) |
(exe: | (exe: | ||
- | (defun draw-simple-shape (vertices) | + | (defun draw-simple-shape (&key |
- | (roslisp:ros-info (turtlesim) " | + | ((:vertices ?vertices)) |
- | (dolist | + | & |
- | (exe: | + | (declare (type (or list null) ?vertices)) |
+ | (mapcar | ||
+ | | ||
+ | (exe:perform (an action (type navigating) (target ?v)))) | ||
+ | ? | ||
+ | |||
+ | |||
+ | (defun navigate-without-pen | ||
+ | | ||
+ | (exe: | ||
+ | | ||
+ | |||
+ | (defun navigate (&key ((:target ?target)) | ||
+ | & | ||
+ | (declare (type (or list null) ?target)) | ||
+ | | ||
</ | </ | ||
- | Here we define three plans. '' | + | Here we define three plans and two " |
Now we can test the plan. | Now we can test the plan. | ||
Line 166: | Line 217: | ||
TUT> (top-level | TUT> (top-level | ||
(with-process-modules-running (turtlesim-navigation turtlesim-pen-control) | (with-process-modules-running (turtlesim-navigation turtlesim-pen-control) | ||
- | (move-without-pen '(1 1 0)) | + | (navigate-without-pen '(1 1 0)) |
(exe: | (exe: | ||
- | [(TURTLE-PROCESS-MODULES) INFO] 1502976852.289: TurtleSim pen control invoked with motion designator `#< | + | [(TURTLE-PROCESS-MODULES) INFO] 1503577044.541: TurtleSim pen control invoked with motion designator `#< |
SETTING-PEN) | SETTING-PEN) | ||
(OFF | (OFF | ||
- | 1)) {100B1F2D13}>' | + | 1)) {1008B23133}>' |
- | [(TURTLE-PROCESS-MODULES) INFO] 1502976852.307: TurtleSim navigation invoked with motion designator `#< | + | [(TURTLE-PROCESS-MODULES) INFO] 1503577044.559: TurtleSim navigation invoked with motion designator `#< |
| | ||
(GOAL | (GOAL | ||
(1 1 | (1 1 | ||
- | 0))) {100CFF8DC3}>' | + | 0))) {1009A325A3}>' |
- | [(TURTLE-PROCESS-MODULES) INFO] 1502976852.598: TurtleSim pen control invoked with motion designator `#< | + | [(TURTLE-PROCESS-MODULES) INFO] 1503577047.556: TurtleSim pen control invoked with motion designator `#< |
SETTING-PEN) | SETTING-PEN) | ||
(OFF | (OFF | ||
- | 0)) {100D2AFED3}>'. | + | 0)) {10088E73D3}>' |
- | [(TURTLESIM) INFO] 1502976852.610: | + | [(TURTLE-PROCESS-MODULES) INFO] 1503577047.573: TurtleSim navigation invoked with motion designator `#< |
- | (6.0125720500946045d0 1.082411289215088d0 0) | + | |
- | (6.0125720500946045d0 5.582411289215088d0 0) | + | |
- | (1.0125720500946045d0 5.582411289215088d0 0))). | + | |
- | [(TURTLE-PROCESS-MODULES) INFO] 1502976852.614: TurtleSim navigation invoked with motion designator `#< | + | |
| | ||
(GOAL | (GOAL | ||
- | (1.0125720500946045d0 | + | (6.001096606254578d0 |
- | 1.082411289215088d0 | + | 1.0863173007965088d0 |
- | 0))) {100D8036B3}>' | + | 0))) {1008E02D63}>' |
| | ||
- | [ ... ] | + | [ ... ] |
| | ||
- | [(TURTLESIM) INFO] 1502976879.586: | + | [(TURTLE-PROCESS-MODULES) INFO] 1503577079.916: TurtleSim navigation invoked with motion designator `#< |
- | (6.059867262840271d0 5.014044284820557d0 0) | + | |
- | (3.0299336314201355d0 9.014044284820557d0 0))). | + | |
- | [(TURTLE-PROCESS-MODULES) INFO] 1502976879.590: | + | |
- | | + | |
- | (GOAL | + | |
- | | + | |
- | 5.014044284820557d0 | + | |
- | 0))) {100A8326D3}>' | + | |
- | + | ||
- | [ ... ] | + | |
- | + | ||
- | [(TURTLE-PROCESS-MODULES) INFO] 1502976886.567: TurtleSim navigation invoked with motion designator `#< | + | |
| | ||
(GOAL | (GOAL | ||
- | (1.059867262840271d0 | + | (1.0146702527999878d0 |
- | 5.014044284820557d0 | + | 5.501473426818848d0 |
- | 0))) {100B6259E3}>' | + | 0))) {1003C1D383}>' |
- | NIL | + | (T T T) |
+ | TUT> | ||
</ | </ | ||