Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:beginner:high_level_plans [2019/07/09 20:07]
gkazhoya [Defining the action designators]
tutorials:beginner:high_level_plans [2019/07/29 10:37]
amar renaming navigating -> navigate
Line 8: Line 8:
 ===== Designators:​ Actions vs Motions ===== ===== Designators:​ Actions vs Motions =====
  
-On a pragmatic level there is not a big difference between action and motion designators since both are a set of key-value pairs. But the difference lies in the semantics. As mentioned in an earlier tutorial about motion designators,​ they are meant to represent actual motions of the robot. Like Moving ​an arm or driving around. The action designators on the other hand should be used to describe abstract plans (e.g. tidying up a room).+On a pragmatic level there is not a big difference between action and motion designators since both are a set of key-value pairs. But the difference lies in the semantics. As mentioned in an earlier tutorial about motion designators,​ they are meant to represent actual motions of the robot. Like moving ​an arm or driving around. The action designators on the other hand should be used to describe abstract plans (e.g. tidying up a room).
  
 This difference comes to play when designators are ''​performed''​. The ''​perfom''​ function handles action designators differently than motion designators. Both are first referenced and then motion designators are executed by passing them to a matching process module. Action designators are executed by looking up a function with the same name as the resolved designator. The rest of the designator is passed as arguments to the function. Let's take a designator ''​(desig:​an action (type tidying-up) (what the-room))''​. This could be resolved to something like ''​(tidy-up the-room)''​. So there has to be a function ''​tidy-up''​ which takes one parameter (''​the-room''​),​ for ''​perform''​ to be able to execute the designator. This difference comes to play when designators are ''​performed''​. The ''​perfom''​ function handles action designators differently than motion designators. Both are first referenced and then motion designators are executed by passing them to a matching process module. Action designators are executed by looking up a function with the same name as the resolved designator. The rest of the designator is passed as arguments to the function. Let's take a designator ''​(desig:​an action (type tidying-up) (what the-room))''​. This could be resolved to something like ''​(tidy-up the-room)''​. So there has to be a function ''​tidy-up''​ which takes one parameter (''​the-room''​),​ for ''​perform''​ to be able to execute the designator.
Line 111: Line 111:
     (lisp-fun get-shape-vertices :triangle ?base-width ?height ?vertices))     (lisp-fun get-shape-vertices :triangle ?base-width ?height ?vertices))
   ​   ​
-  (<- (desig:​action-grounding ?desig (move ?target)) +  (<- (desig:​action-grounding ?desig (navigate ​?target)) 
-    (desig-prop ?desig (:type :moving))+    (desig-prop ?desig (:type :navigating))
     (desig-prop ?desig (:target ?target))))     (desig-prop ?desig (:target ?target))))
  
Line 119: Line 119:
 Let's see what this code does. The function ''​get-shape-vertices''​ simply returns a list of vertices for the draw-simple-shape plan to trace. It uses the current position of the turtle to calculate those points. Let's see what this code does. The function ''​get-shape-vertices''​ simply returns a list of vertices for the draw-simple-shape plan to trace. It uses the current position of the turtle to calculate those points.
  
-The inference is simple again: it maps the shape value to the right call to ''​get-shape-vertices''​ to get the right list of vertices. For the ''​move''​ plan it simply extracts the target point from the designator.+The inference is simple again: it maps the shape value to the right call to ''​get-shape-vertices''​ to get the right list of vertices. For the ''​navigate''​ plan it simply extracts the target point from the designator.
  
 Reload the tutorial package in ''​roslisp_repl''​. This will also load the newly defined inference rules. Reload the tutorial package in ''​roslisp_repl''​. This will also load the newly defined inference rules.
Line 152: Line 152:
       (value *turtle-pose*)       (value *turtle-pose*)
     (exe:​perform (an action (type drawing) (shape rectangle) (width 5) (height 4.5)))     (exe:​perform (an action (type drawing) (shape rectangle) (width 5) (height 4.5)))
-    (move-without-pen (list (+ x 3) y 0))+    (navigate-without-pen (list (+ x 3) y 0))
     (exe:​perform (an action (type drawing) (shape rectangle) (width 1) (height 2.5)))     (exe:​perform (an action (type drawing) (shape rectangle) (width 1) (height 2.5)))
-    (move-without-pen (list (+ x 0.5) (+ y 2) 0))+    (navigate-without-pen (list (+ x 0.5) (+ y 2) 0))
     (exe:​perform (an action (type drawing) (shape rectangle) (width 1) (height 1)))     (exe:​perform (an action (type drawing) (shape rectangle) (width 1) (height 1)))
-    (move-without-pen (list x (+ y 4.5) 0))+    (navigate-without-pen (list x (+ y 4.5) 0))
     (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)))))
  
Line 162: Line 162:
   (mapcar   (mapcar
    ​(lambda (?v)    ​(lambda (?v)
-     ​(exe:​perform (an action (type moving) (target ?v))))+     ​(exe:​perform (an action (type navigating) (target ?v))))
    ​vertices))    ​vertices))
  
-(defun ​move-without-pen (?target)+(defun ​navigate-without-pen (?target)
   (exe:​perform (a motion (type setting-pen) (off 1)))   (exe:​perform (a motion (type setting-pen) (off 1)))
-  (exe:​perform (an action (type moving) (target ?target)))+  (exe:​perform (an action (type navigating) (target ?target)))
   (exe:​perform (a motion (type setting-pen) (off 0))))   (exe:​perform (a motion (type setting-pen) (off 0))))
  
-(defun ​move (?v)+(defun ​navigate ​(?v)
   (exe:​perform (a motion (type moving) (goal ?v))))   (exe:​perform (a motion (type moving) (goal ?v))))
 </​code>​ </​code>​
  
-Here we define three plans and two "​helper plans"​. ''​move-without-pen''​ is a helper plan for moving the turtle between the pieces of the house. It calls the ''​move''​ plan to achieve this. In ''​draw-house''​ we use the turtle-pose to move the turtle to the position of the next piece by calling ''​move-without-pen''​. To draw the house we call ''​perform''​ with the action designators we defined above. These get resolved and ''​draw-simple-shape''​ is called. There we use ''​mapcar''​ function to move the turtle by performing a moving ​action for every vertex in vertices. For now the ''​move''​ plan is pretty barebones, but we define it as it's own plan because it will be the one to get the failure handling in the next tutorial. Otherwise we could just perform the moving motion.+Here we define three plans and two "​helper plans"​. ''​navigate-without-pen''​ is a helper plan for moving the turtle between the pieces of the house. It calls the ''​navigate''​ plan to achieve this. In ''​draw-house''​ we use the turtle-pose to move the turtle to the position of the next piece by calling ''​navigate-without-pen''​. To draw the house we call ''​perform''​ with the action designators we defined above. These get resolved and ''​draw-simple-shape''​ is called. There we use the ''​mapcar''​ function to move the turtle by performing a navigating ​action for every vertex in ''​vertices''​. For now the ''​navigate''​ plan is pretty barebones, but we define it as it's own plan because it will be the one to get the failure handling in the next tutorial. Otherwise we could just perform the moving motion.
  
 Now we can test the plan. Now we can test the plan.
Line 181: Line 181:
 TUT> (top-level TUT> (top-level
     (with-process-modules-running (turtlesim-navigation turtlesim-pen-control)     (with-process-modules-running (turtlesim-navigation turtlesim-pen-control)
-      (move-without-pen '(1 1 0))+      (navigate-without-pen '(1 1 0))
       (exe:​perform (an action (type drawing) (shape house)))))       (exe:​perform (an action (type drawing) (shape house)))))
 [(TURTLE-PROCESS-MODULES) INFO] 1503577044.541:​ TurtleSim pen control invoked with motion designator `#<​MOTION-DESIGNATOR ((TYPE [(TURTLE-PROCESS-MODULES) INFO] 1503577044.541:​ TurtleSim pen control invoked with motion designator `#<​MOTION-DESIGNATOR ((TYPE