Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorials:beginner:failure_handling [2022/03/15 13:36] – [Defining and signaling a failure condition] schimpf | tutorials:beginner:failure_handling [2022/03/15 13:43] (current) – [Implementing failure handling for the TurtleSim] schimpf | ||
---|---|---|---|
Line 6: | Line 6: | ||
**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 should be executed: | ||
+ | <code lisp> | ||
+ | CL-USER> | ||
+ | ... | ||
+ | CL-USER> | ||
+ | ... | ||
+ | TUT> | ||
+ | ... | ||
+ | TUT> (init-ros-turtle " | ||
+ | </ | ||
===== Failure Handling in CRAM ===== | ===== Failure Handling in CRAM ===== | ||
Line 193: | Line 211: | ||
(defparameter *max-bound* 10.5) | (defparameter *max-bound* 10.5) | ||
- | (defun navigate (?v) | + | (defun navigate (&key ((: |
+ | & | ||
+ | (declare (type (or list null) ?target)) | ||
(flet ((out-of-bounds (pose) | (flet ((out-of-bounds (pose) | ||
| | ||
Line 199: | Line 219: | ||
(not (and (< *min-bound* x *max-bound*) | (not (and (< *min-bound* x *max-bound*) | ||
(< *min-bound* y *max-bound*)))))) | (< *min-bound* y *max-bound*)))))) | ||
- | | + | |
((out-of-bounds-error (e) | ((out-of-bounds-error (e) | ||
| | ||
| | ||
(let ((?corr-v (list | (let ((?corr-v (list | ||
- | (max 0.6 (min 10.4 (car ?v))) | + | (max 0.6 (min 10.4 (car ?target))) |
- | (max 0.6 (min 10.4 (cadr ?v))) | + | (max 0.6 (min 10.4 (cadr ?target))) |
0))) | 0))) | ||
| | ||
Line 214: | Line 234: | ||
(whenever ((fl-funcall #' | (whenever ((fl-funcall #' | ||
(error ' | (error ' | ||
- | (exe: | + | (exe: |
(defun recover-from-oob (& | (defun recover-from-oob (& | ||
Line 249: | Line 269: | ||
<code lisp> | <code lisp> | ||
(in-package :tut) | (in-package :tut) | ||
- | + | ||
- | (defun draw-house () | + | (defun draw-house (&key ((:shape ?shape)) |
+ | & | ||
+ | (declare (type (or keyword) ?shape)) | ||
(with-fields (x y) | (with-fields (x y) | ||
(value *turtle-pose*) | (value *turtle-pose*) | ||
Line 261: | Line 283: | ||
(exe: | (exe: | ||
- | (defun draw-simple-shape (vertices) | + | (defun draw-simple-shape (&key |
+ | ((:vertices | ||
+ | & | ||
+ | (declare (type (or list null) ?vertices)) | ||
(mapcar | (mapcar | ||
| | ||
| | ||
- | | + | ?vertices)) |
+ | |||
(defun navigate-without-pen (?target) | (defun navigate-without-pen (?target) | ||
(exe: | (exe: | ||
(exe: | (exe: | ||
(exe: | (exe: | ||
+ | |||
(defparameter *min-bound* 0.5) | (defparameter *min-bound* 0.5) | ||
(defparameter *max-bound* 10.5) | (defparameter *max-bound* 10.5) | ||
- | + | ||
- | (defun navigate (?v) | + | (defun navigate (&key ((:target ?target)) |
+ | & | ||
+ | (declare (type (or list null) ?target)) | ||
(flet ((out-of-bounds (pose) | (flet ((out-of-bounds (pose) | ||
| | ||
Line 281: | Line 309: | ||
(not (and (< *min-bound* x *max-bound*) | (not (and (< *min-bound* x *max-bound*) | ||
(< *min-bound* y *max-bound*)))))) | (< *min-bound* y *max-bound*)))))) | ||
- | | + | |
((out-of-bounds-error (e) | ((out-of-bounds-error (e) | ||
| | ||
| | ||
(let ((?corr-v (list | (let ((?corr-v (list | ||
- | (max 0.6 (min 10.4 (car ?v))) | + | (max 0.6 (min 10.4 (car ?target))) |
- | (max 0.6 (min 10.4 (cadr ?v))) | + | (max 0.6 (min 10.4 (cadr ?target))) |
0))) | 0))) | ||
| | ||
Line 296: | Line 324: | ||
(whenever ((fl-funcall #' | (whenever ((fl-funcall #' | ||
(error ' | (error ' | ||
- | (exe: | + | (exe: |
(defun recover-from-oob (& | (defun recover-from-oob (& |