Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorials:beginner:motion_designators [2019/02/04 15:47] – [Using motion designators] vanessa | tutorials:beginner:motion_designators [2019/07/29 10:35] – Added turtlesim-srv to the dependencies amar | ||
---|---|---|---|
Line 3: | Line 3: | ||
**Description: | **Description: | ||
- | **Previous Tutorial:** [[tutorials: | + | **Previous Tutorial:** [[tutorials: |
**Next Tutorial:** [[tutorials: | **Next Tutorial:** [[tutorials: | ||
Line 10: | Line 10: | ||
From a user's point of view, a designator is a Common Lisp object that contains a sequence of key-value pairs representing a high-level, symbolic description of some aspect of robot' | From a user's point of view, a designator is a Common Lisp object that contains a sequence of key-value pairs representing a high-level, symbolic description of some aspect of robot' | ||
- | Currently there are five types of designators defined in CRAM: | + | Currently there are the following |
* location designators: | * location designators: | ||
Line 16: | Line 16: | ||
* motion designators: | * motion designators: | ||
* action designators: | * action designators: | ||
- | * human designators: | ||
These types should cover most use cases in robotics, however, if needed, new designator types can be defined as subclasses of the '' | These types should cover most use cases in robotics, however, if needed, new designator types can be defined as subclasses of the '' | ||
Line 23: | Line 22: | ||
<code lisp> | <code lisp> | ||
- | (defparameter spy-location (desig:a location (to see) (object ? | + | (defparameter |
</ | </ | ||
(Do not add this code to your tutorial files, it is meant simply for illustration here.) | (Do not add this code to your tutorial files, it is meant simply for illustration here.) | ||
- | This line of code creates a location designator ('' | + | This line of code creates a location designator ('' |
<code lisp> | <code lisp> | ||
- | (reference spy-location) | + | (reference |
</ | </ | ||
Line 47: | Line 46: | ||
</ | </ | ||
- | In your '' | + | In your '' |
<code lisp> | <code lisp> | ||
- | (defsystem cram-beginner-tutorial | + | (defsystem cram-my-beginner-tutorial |
- | :depends-on (cram-language roslisp turtlesim-msg geometry_msgs-msg cl-transforms | + | :depends-on (cram-language roslisp turtlesim-msg |
+ | geometry_msgs-msg cl-transforms | ||
| | ||
:components | :components | ||
Line 65: | Line 65: | ||
<code lisp> | <code lisp> | ||
- | (defpackage : | + | (defpackage :cram-my-beginner-tutorial |
(:nicknames :tut) | (:nicknames :tut) | ||
(:use :cpl :roslisp : | (:use :cpl :roslisp : | ||
Line 71: | Line 71: | ||
</ | </ | ||
- | Now, reload the tutorial in '' | + | Now, reload the tutorial in '' |
+ | |||
+ | <code lisp> | ||
+ | PROLOG> (ros-load: | ||
+ | PROLOG> (in-package :tut) | ||
+ | </ | ||
==== Creating a motion designator ==== | ==== Creating a motion designator ==== | ||
Line 78: | Line 83: | ||
<code lisp> | <code lisp> | ||
- | TUT> (defparameter my-desig (desig:a motion (type driving) (speed 1.5))) | + | TUT> (defparameter |
- | MY-DESIG | + | *MY-DESIG* |
- | TUT> (desig-prop-value my-desig :speed) | + | TUT> (desig-prop-value |
1.5 | 1.5 | ||
</ | </ | ||
+ | |||
+ | We call the variable '' | ||
We use the '' | We use the '' | ||
Line 89: | Line 96: | ||
<code lisp> | <code lisp> | ||
- | TUT> (reference my-desig) | + | TUT> (reference |
Cannot resolve motion designator #< | Cannot resolve motion designator #< | ||
| | ||
Line 100: | Line 107: | ||
==== Defining inference rules for designators ==== | ==== Defining inference rules for designators ==== | ||
+ | |||
+ | The function '' | ||
+ | CRAM Prolog engine is a Prolog interpreter / compiler implemented as a domain-specific language within Lisp. | ||
+ | To learn more about CRAM Prolog look at the [[cram_prolog|Using Prolog for reasoning]] tutorial. | ||
+ | To '' | ||
Append the following to your '' | Append the following to your '' | ||
Line 137: | Line 149: | ||
Let's see what this code does. The defstruct declares a structure type to hold values resulting from the inference. It's an instantiation of our motion in a space of (possibly) continuous parameters, which we deduce from a symbolic description of the designator via rules given in the def-fact-group. | Let's see what this code does. The defstruct declares a structure type to hold values resulting from the inference. It's an instantiation of our motion in a space of (possibly) continuous parameters, which we deduce from a symbolic description of the designator via rules given in the def-fact-group. | ||
- | As for the inference rules themselves, these are Prolog code embedded in Lisp, for it is Prolog that powers the inference behind designator resolution. To learn more about CRAM Prolog look at the [[cram_prolog|Using Prolog for reasoning]] tutorial. The '' | + | As for the inference rules themselves, these are Prolog code embedded in Lisp, for it is Prolog that powers the inference behind designator resolution. The '' |
<code lisp> | <code lisp> | ||
Line 177: | Line 189: | ||
<code lisp> | <code lisp> | ||
- | TUT> (defparameter my-desig2 (desig:a motion (type driving) (speed 1.5) (angle 2))) | + | TUT> (defparameter |
- | MY-DESIG2 | + | *MY-DESIG2 |
- | TUT> (reference my-desig2) | + | TUT> (reference |
(DRIVE # | (DRIVE # | ||
</ | </ | ||
Line 224: | Line 236: | ||
<code lisp> | <code lisp> | ||
TUT> (desig:a motion (type moving) (goal (1 1 0))) | TUT> (desig:a motion (type moving) (goal (1 1 0))) | ||
- | #<MOTION-DESIGNATOR | + | #<A MOTION |
+ | | ||
+ | | ||
</ | </ | ||
Line 277: | Line 291: | ||
<code lisp> | <code lisp> | ||
- | TUT> (defparameter my-desig3 (desig:a motion (type setting-pen) (r 100) (g 150) (b 0) (width 5))) | + | TUT> (defparameter |
- | MY-DESIG3 | + | *MY-DESIG3* |
- | TUT> (reference my-desig3) | + | TUT> (reference |
(SET-PEN # | (SET-PEN # | ||
</ | </ |