Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorials:beginner:failure_handling [2019/07/16 11:33] – cpo | tutorials:beginner:failure_handling [2022/03/15 13:43] (current) – [Implementing failure handling for the TurtleSim] schimpf | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| **Description: | **Description: | ||
| - | **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 should be executed: | ||
| + | <code lisp> | ||
| + | CL-USER> | ||
| + | ... | ||
| + | CL-USER> | ||
| + | ... | ||
| + | TUT> | ||
| + | ... | ||
| + | TUT> (init-ros-turtle " | ||
| + | </ | ||
| ===== Failure Handling in CRAM ===== | ===== Failure Handling in CRAM ===== | ||
| Line 108: | Line 125: | ||
| (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 117: | Line 136: | ||
| (whenever ((fl-funcall #' | (whenever ((fl-funcall #' | ||
| (error ' | (error ' | ||
| - | (exe: | + | (exe: | 
| </ | </ | ||
| Line 192: | 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 198: | 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 213: | Line 234: | ||
| (whenever ((fl-funcall #' | (whenever ((fl-funcall #' | ||
| (error ' | (error ' | ||
| - | (exe: | + | (exe: | 
| (defun recover-from-oob (& | (defun recover-from-oob (& | ||
| Line 248: | 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 260: | 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 280: | 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 295: | Line 324: | ||
| (whenever ((fl-funcall #' | (whenever ((fl-funcall #' | ||
| (error ' | (error ' | ||
| - | (exe: | + | (exe: | 
| (defun recover-from-oob (& | (defun recover-from-oob (& | ||

 
 
 

 
