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
tutorials:beginner:high_level_plans [2019/07/16 11:32] – Rename plan ''move'' to ''navigate''. cpotutorials:beginner:high_level_plans [2022/03/15 13:29] (current) – [Writing the plans] schimpf
Line 6: Line 6:
 **Next Tutorial:** [[tutorials:beginner:failure_handling|Implementing failure handling for the TurtleSim]] **Next Tutorial:** [[tutorials:beginner:failure_handling|Implementing failure handling for the TurtleSim]]
  
 +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>
 +<code bash>
 +$ rosrun turtlesim turtlesim_node
 +</code>
 +
 +And in the REPL the following commands should be executed:
 +<code lisp>
 +CL-USER>(ros-load:load-system "cram_my_beginner_tutorial" :cram-my-beginner-tutorial)
 +...
 +CL-USER>(in-package :tut)
 +...
 +TUT>(start-ros-node "turtle1")
 +</code>
 ===== Designators: Actions vs Motions ===== ===== Designators: Actions vs Motions =====
  
Line 93: Line 109:
  
 (def-fact-group turtle-action-designators (action-grounding) (def-fact-group turtle-action-designators (action-grounding)
-  (<- (desig:action-grounding ?desig (draw-house)) 
-    (desig-prop ?desig (:type :drawing)) 
-    (desig-prop ?desig (:shape :house))) 
  
-  (<- (desig:action-grounding ?desig (draw-simple-shape ?vertices)) +  (<- (desig:action-grounding ?action-designator (navigate ?action-designator)) 
-    (desig-prop ?desig (:type :drawing)) +     (desig-prop ?action-designator (:type :navigating)) 
-    (desig-prop ?desig (:shape :rectangle)) +     (desig-prop ?action-designator (:target ?target))) 
-    (desig-prop ?desig (:width ?width)) +  
-    (desig-prop ?desig (:height ?height)) +  (<(desig:action-grounding ?action-designator (draw-house ?action-designator)) 
-    (lisp-fun get-shape-vertices :rectangle ?width ?height ?vertices))+    (desig-prop ?action-designator (:type :drawing)) 
 +    (desig-prop ?action-designator (:shape :house)))
  
-  (<- (desig:action-grounding ?desig (draw-simple-shape ?vertices)) +  (<- (desig:action-grounding ?action-designator (draw-simple-shape ?resolved-action-designator)) 
-    (desig-prop ?desig (:type :drawing)) +    (desig-prop ?action-designator (:type :drawing)) 
-    (desig-prop ?desig (:shape :triangle)) +    (desig-prop ?action-designator (:shape :rectangle)) 
-    (desig-prop ?desig (:base-width ?base-width)) +    (desig-prop ?action-designator (:width ?width)) 
-    (desig-prop ?desig (:height ?height)) +    (desig-prop ?action-designator (:height ?height)) 
-    (lisp-fun get-shape-vertices :triangle ?base-width ?height ?vertices)) +    (lisp-fun get-shape-vertices :rectangle ?width ?height ?vertices)    
-   +    (desig:designator :action ((:type :drawing) 
-  (<- (desig:action-grounding ?desig (navigate ?target)) +                              (:vertices ?vertices)) 
-    (desig-prop ?desig (:type :navigating)) +                      ?resolved-action-designator)) 
-    (desig-prop ?desig (:target ?target))))+ 
 +  (<- (desig:action-grounding ?action-designator (draw-simple-shape ?resolved-action-designator)) 
 +    (desig-prop ?action-designator (:type :drawing)) 
 +    (desig-prop ?action-designator (:shape :triangle)) 
 +    (desig-prop ?action-designator (:base-width ?base-width)
 +    (desig-prop ?action-designator (:height ?height))     
 +    (lisp-fun get-shape-vertices :triangle ?base-width ?height ?vertices) 
 +    (desig:designator :action ((:type :drawing) 
 +                              (:vertices ?vertices)) 
 +                      ?resolved-action-designator)))
  
 </code> </code>
Line 130: Line 153:
 TUT> (reference (desig:an action (type drawing) (shape rectangle) (width 5) (height 4))) TUT> (reference (desig:an action (type drawing) (shape rectangle) (width 5) (height 4)))
 (DRAW-SIMPLE-SHAPE (DRAW-SIMPLE-SHAPE
- ((3.077953338623047d0 11.088889122009277d0 0) + #<A ACTION 
-  (8.077953338623047d0 11.088889122009277d0 0) +    (TYPE DRAWING) 
-  (8.077953338623047d0 15.088889122009277d0 0) +    (VERTICES ((9.255966663360596d0 10.373946189880371d0 0) 
-  (3.077953338623047d0 15.088889122009277d0 0)))+               (9.255966663360596d0 14.373946189880371d0 0) 
 +               (4.255966663360596d0 14.373946189880371d0 0) 
 +               (4.255966663360596d0 10.373946189880371d0 0)))>)
 TUT> (reference (desig:an action (type drawing) (shape house))) TUT> (reference (desig:an action (type drawing) (shape house)))
-(DRAW-HOUSE)+(DRAW-HOUSE 
 + #<A ACTION 
 +    (TYPE DRAWING) 
 +    (SHAPE HOUSE)>)
 </code> </code>
  
Line 148: Line 176:
 (in-package :tut) (in-package :tut)
  
-(defun draw-house ()+(defun draw-house (&key ((:shape ?shape)) 
 +                   &allow-other-keys) 
 +  (declare (type (or keyword) ?shape))
   (with-fields (x y)   (with-fields (x y)
       (value *turtle-pose*)       (value *turtle-pose*)
Line 159: Line 189:
     (exe:perform (an action (type drawing) (shape triangle) (base-width 5) (height 4)))))     (exe:perform (an action (type drawing) (shape triangle) (base-width 5) (height 4)))))
  
-(defun draw-simple-shape (vertices)+(defun draw-simple-shape (&key 
 +                            ((:vertices ?vertices)) 
 +                          &allow-other-keys) 
 +  (declare (type (or list null) ?vertices)
   (mapcar   (mapcar
    (lambda (?v)    (lambda (?v)
      (exe:perform (an action (type navigating) (target ?v))))      (exe:perform (an action (type navigating) (target ?v))))
-   vertices))+   ?vertices)) 
  
 (defun navigate-without-pen (?target) (defun navigate-without-pen (?target)
Line 170: Line 204:
   (exe:perform (a motion (type setting-pen) (off 0))))   (exe:perform (a motion (type setting-pen) (off 0))))
  
-(defun navigating (?v+(defun navigate (&key ((:target ?target)) 
-  (exe:perform (a motion (type moving) (goal ?v))))+                 &allow-other-keys) 
 +  (declare (type (or list null) ?target)
 +  (exe:perform (a motion (type moving) (goal ?target))))
 </code> </code>