Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:beginner:simple_plans [2016/01/25 15:07] – [Moving the turtle towards a point] gkazhoya | tutorials:beginner:simple_plans [2022/02/25 23:15] (current) – [Implementing simple plans to move a turtle] schimpf | ||
---|---|---|---|
Line 4: | Line 4: | ||
**Previous Tutorial:** [[tutorials: | **Previous Tutorial:** [[tutorials: | ||
- | **Next 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 need to be executed: | ||
+ | <code lisp> | ||
+ | CL-USER> | ||
+ | ... | ||
+ | CL-USER> | ||
+ | ... | ||
+ | TUT> | ||
+ | ... | ||
+ | TUT> | ||
+ | </ | ||
===== Moving the turtle towards a point ===== | ===== Moving the turtle towards a point ===== | ||
Line 28: | Line 45: | ||
(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 55: | ||
(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 73: | ||
{{ : | {{ : | ||
- | |||
- | (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 97: | ||
<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 117: | ||
</ | </ | ||
| | ||
- | 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 125: | ||
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 140: | ||
- | 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: |