Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tutorials:beginner:failure_handling [2019/07/16 11:34] cpotutorials:beginner:failure_handling [2022/03/15 13:38] – [Recovering from the failure] schimpf
Line 107: Line 107:
 (defparameter *max-bound* 10.5) (defparameter *max-bound* 10.5)
  
-(defun navigate (?v)+(defun navigate (&key ((:target ?target)) 
 +                 &allow-other-keys) 
 +  (declare (type (or list null) ?target))
   (flet ((out-of-bounds (pose)   (flet ((out-of-bounds (pose)
            (with-fields (x y)            (with-fields (x y)
Line 116: Line 118:
       (whenever ((fl-funcall #'out-of-bounds *turtle-pose*))       (whenever ((fl-funcall #'out-of-bounds *turtle-pose*))
         (error 'out-of-bounds-error))         (error 'out-of-bounds-error))
-      (exe:perform (a motion (type moving) (goal ?v))))))+      (exe:perform (a motion (type moving) (goal ?target))))))
 </code> </code>
  
Line 191: Line 193:
 (defparameter *max-bound* 10.5) (defparameter *max-bound* 10.5)
  
-(defun navigate (?v)+(defun navigate (&key ((:target ?target)) 
 +                 &allow-other-keys) 
 +  (declare (type (or list null) ?target))
   (flet ((out-of-bounds (pose)   (flet ((out-of-bounds (pose)
            (with-fields (x y)            (with-fields (x y)
Line 197: Line 201:
              (not (and (< *min-bound* x *max-bound*)              (not (and (< *min-bound* x *max-bound*)
                        (< *min-bound* y *max-bound*))))))                        (< *min-bound* y *max-bound*))))))
-    (with-failure-handling+        (with-failure-handling
         ((out-of-bounds-error (e)         ((out-of-bounds-error (e)
            (ros-warn (draw-simple-simple) "Moving went-wrong: ~a" e)            (ros-warn (draw-simple-simple) "Moving went-wrong: ~a" e)
            (exe:perform (a motion (type setting-pen) (r 204) (g 0) (b 0) (width 2)))            (exe:perform (a motion (type setting-pen) (r 204) (g 0) (b 0) (width 2)))
            (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)))
              (recover-from-oob ?corr-v)              (recover-from-oob ?corr-v)
Line 212: Line 216:
         (whenever ((fl-funcall #'out-of-bounds *turtle-pose*))         (whenever ((fl-funcall #'out-of-bounds *turtle-pose*))
           (error 'out-of-bounds-error))           (error 'out-of-bounds-error))
-        (exe:perform (a motion (type moving) (goal ?v)))))))+        (exe:perform (a motion (type moving) (goal ?target)))))))
  
 (defun recover-from-oob (&optional goal) (defun recover-from-oob (&optional goal)