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:simple_plans [2016/01/25 15:05] – [Moving the turtle towards a point] gkazhoya | tutorials:beginner:simple_plans [2019/07/11 13:27] – gkazhoya | ||
---|---|---|---|
Line 4: | Line 4: | ||
**Previous Tutorial:** [[tutorials: | **Previous Tutorial:** [[tutorials: | ||
- | **Next Tutorial:** [[tutorials: | + | **Next Tutorial:** [[tutorials: |
Line 28: | Line 28: | ||
(defun relative-angle-to (goal pose-msg) | (defun relative-angle-to (goal pose-msg) | ||
- | "Given a `pose-msg' | + | "Given a `pose-msg' |
calculate the angle by which the pose has to be turned to point toward the goal." | calculate the angle by which the pose has to be turned to point toward the goal." | ||
(let ((diff-pose (cl-transforms: | (let ((diff-pose (cl-transforms: | ||
Line 38: | Line 38: | ||
(cl-transforms: | (cl-transforms: | ||
- | (defun calculate-angular-cmd (goal & | + | (defun calculate-angular-cmd (goal & |
"Uses the current turtle pose and calculates the angular velocity command | "Uses the current turtle pose and calculates the angular velocity command | ||
to turn towards the goal." | to turn towards the goal." | ||
Line 56: | Line 56: | ||
{{ : | {{ : | ||
- | |||
- | (Note: the coordinates on this picture don't correspond to the real measurements of the TurtleSim window and are " | ||
In order to move the turtle towards a point, we need to continuously recalculate and send the velocity command at a specific rate. The rate must be sufficiently high, since the sent command needs to change while the turtle moves. Let's see if our code does what it should do. Enter in the Lisp REPL: | In order to move the turtle towards a point, we need to continuously recalculate and send the velocity command at a specific rate. The rate must be sufficiently high, since the sent command needs to change while the turtle moves. Let's see if our code does what it should do. Enter in the Lisp REPL: | ||
Line 82: | Line 80: | ||
<code lisp> | <code lisp> | ||
(def-cram-function move-to (goal & | (def-cram-function move-to (goal & | ||
- | (let ((reached-fl (< (fl-funcall #' | + | |
+ | (let ((reached-fl (< (fl-funcall #' | ||
| | ||
#' | #' | ||
Line 101: | Line 100: | ||
</ | </ | ||
| | ||
- | When we want to use CRAM language features such as '' | + | When we want to use CRAM language features such as '' |
The fluent network that we construct looks pretty complicated. We first transform the pose message into a '' | The fluent network that we construct looks pretty complicated. We first transform the pose message into a '' | ||
Line 109: | Line 108: | ||
The '' | The '' | ||
- | To execute CRAM Plan Language code we need to either call it from a function that was defined with '' | + | To execute CRAM Plan Language code (e.g. '' |
<code lisp> | <code lisp> | ||
TUT> (top-level | TUT> (top-level | ||
| | ||
| | ||
- | </ | + | </ |
+ | |||
+ | We pass the '' | ||
The turtle should now move along a rectangle. | The turtle should now move along a rectangle. | ||
Line 122: | Line 123: | ||
- | Moving along predetermined points is all fine and good, but let's have a look at a more flexible way that CRAM provides to specify and reason about parameters ... | + | Moving along predetermined points is all fine and good, but let's have a look at a more flexible way that CRAM provides to specify and reason about parameters. To learn about motion parameter, we, however, first need to understand how the Lisp Prolog works ... |
- | [[tutorials: | + | [[tutorials: |