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
Last revisionBoth sides next revision
tutorials:beginner:location_designators_2 [2017/09/07 12:49] – Added rule for matching process module of going-to designator. cpotutorials:beginner:location_designators_2 [2019/07/09 19:21] – [Using a location designator] gkazhoya
Line 3: Line 3:
 **Description:** in this tutorial you will learn about location designators, how to create and resolve them. You will expand a process module to make use of the location designator. **Description:** in this tutorial you will learn about location designators, how to create and resolve them. You will expand a process module to make use of the location designator.
  
-**Previous Tutorial:** [[tutorials:beginner:assigning_actions|Automatically choosing a process module for an action]]+**Previous Tutorial:** [[tutorials:beginner:assigning_actions_2|Automatically choosing a process module for an action]]\\ 
 +**Next Tutorial:** [[tutorials:beginner:high_level_plans|Writing plans for the TurtleSim]]
  
 ===== Location designators: an overview ===== ===== Location designators: an overview =====
Line 31: Line 32:
 ===== Location designator generators ===== ===== Location designator generators =====
  
-Let's create a new file called ''location-designators.lisp'' in our tutorial's ''src'' directory and add it to the ''*.asd'' file with ''process-modules'' depending on it. The resulting ''cram-beginner-tutorial.asd'' should now look like this:+Let's create a new file called ''location-designators.lisp'' in our tutorial's ''src'' directory and add it to the ''*.asd'' file. The resulting ''cram-my-beginner-tutorial.asd'' should now look like this:
  
 <code lisp> <code lisp>
-(defsystem cram-beginner-tutorial+(defsystem cram-my-beginner-tutorial
   :depends-on (roslisp cram-language turtlesim-msg turtlesim-srv cl-transforms geometry_msgs-msg cram-designators cram-prolog   :depends-on (roslisp cram-language turtlesim-msg turtlesim-srv cl-transforms geometry_msgs-msg cram-designators cram-prolog
                        cram-process-modules cram-language-designator-support cram-executive)                        cram-process-modules cram-language-designator-support cram-executive)
Line 61: Line 62:
        (make-designator :location '((:vertical-position :bottom) (:horizontal-position :left))))        (make-designator :location '((:vertical-position :bottom) (:horizontal-position :left))))
 TUT> goal-desig TUT> goal-desig
-#<LOCATION-DESIGNATOR ((:VERTICAL-POSITION :BOTTOM) +#<LOCATION 
-                       (:HORIZONTAL-POSITION :LEFT)) {1008548CD3}>+​    (VERTICAL-POSITION BOTTOM) 
 +    (HORIZONTAL-POSITION LEFT)>
 </code> </code>
  
Line 193: Line 195:
 </code> </code>
  
-Depending on the random number generator we will get some or none of the solutions rejected and, therefore, ''<='' number of valid solutions for our designator ''another-goal''.+Depending on the random number generator we will get some or none of the solutions rejected and, therefore, ''<='' number of valid solutions for our designator ''another-goal''That means, you might get a different number of solutions than what we got: we got 3 but you might be 4 or 5 or something else. 
  
  
Line 201: Line 204:
  
 <code lisp> <code lisp>
-(def-fact-group goal-motions (motion-desig+(def-fact-group goal-motions (motion-grounding
-  (<- (motion-desig ?desig (go-to ?point))+  (<- (motion-grounding ?desig (go-to ?point))
     (desig-prop ?desig (:type :going-to))     (desig-prop ?desig (:type :going-to))
     (desig-prop ?desig (:goal ?point))))     (desig-prop ?desig (:goal ?point))))
Line 230: Line 233:
          (let ((target-point (reference motion)))          (let ((target-point (reference motion)))
            (roslisp:ros-info (turtle-process-modules)            (roslisp:ros-info (turtle-process-modules)
-                             "Goint to point ~a." target-point)+                             "Going to point ~a." target-point)
            (move-to target-point)))))))            (move-to target-point)))))))
  
Line 268: Line 271:
                                (horizontal-position ?horizontal-position)                                (horizontal-position ?horizontal-position)
                                (vertical-position ?vertical-position)))                                (vertical-position ?vertical-position)))
-               (goal (desig:a motion (type :going-to) (:goal ?area))))+               (goal (desig:a motion (type going-to) (goal ?area))))
           (cram-executive:perform goal))))))           (cram-executive:perform goal))))))
 </code> </code>
  
-In ''goto-location'' we use ''perform'', which means we have to make sure the right process module for our ''going-to'' designator can be found. For that we add a rule to the fact-group ''available-turtle-process-modules'':+In ''goto-location'' we use ''perform'', which means we have to make sure the right process module for our ''going-to'' designator can be found. For that we add a rule to the fact-group ''available-turtle-process-modules'' from the ''selecting-process-modules.lisp'' file. The file should now look like this:
  
 <code lisp> <code lisp>
Line 297: Line 300:
 </code> </code>
  
-It's the same as the other ones. If the type of ''?desig'' is ''going-to'', the rule applies and ''turtlesim-navigation'' gets selected-+It's the same as the other ones. If the type of ''?desig'' is ''going-to'', the rule applies and ''turtlesim-navigation'' gets selected.
  
 Now let's give it a go. Reload the tutorial in ''roslisp_repl'' then in the command line of the REPL type: Now let's give it a go. Reload the tutorial in ''roslisp_repl'' then in the command line of the REPL type:
Line 309: Line 312:
 [(ROSLISP TOP) INFO] 1501153969.641: master URI is 127.0.0.1:11311 [(ROSLISP TOP) INFO] 1501153969.641: master URI is 127.0.0.1:11311
 [(ROSLISP TOP) INFO] 1501153970.649: Node startup complete [(ROSLISP TOP) INFO] 1501153970.649: Node startup complete
-[(TURTLE-PROCESS-MODULES) INFO] 1501153970.689: TurtleSim navigation invoked with motion designator `#<MOTION-DESIGNATOR ((TYPE +[(TURTLE-PROCESS-MODULES) INFO] 1562698457.619: TurtleSim navigation invoked with motion designator `#<MOTION 
-                                                                           GOING-TO) +    (TYPE GOING-TO) 
-                                                                          (GOAL +    (GOAL #<LOCATION 
-                                                                           #<LOCATION-DESIGNATOR +    (HORIZONTAL-POSITION RIGHT) 
-                                                                             ((HORIZONTAL-POSITION +    (VERTICAL-POSITION TOP)>)>'
-                                                                               RIGHT) +[(TURTLE-PROCESS-MODULES) INFO] 1501153970.691: Going to point #<3D-VECTOR (10.131428718566895d0 8.874866485595703d0 0.0d0)>.
-                                                                              (VERTICAL-POSITION +
-                                                                               TOP)+
-                                                                             {1005139363}>)) {1005139703}>'+
-[(TURTLE-PROCESS-MODULES) INFO] 1501153970.691: Goint to point #<3D-VECTOR (10.131428718566895d0 8.874866485595703d0 0.0d0)>.+
 T T
 +</code>
 +
 +If you already had a running node in the REPL, you might get the error shown below but that is absolutely normal: ROS simply notifies you that it is going to shut down the previous node and start a new one.
 +<code lisp>
 +WARNING:
 +   Before starting node, node-status equalled RUNNING instead of :shutdown.  Shutting the previous node invocation down now.
 </code> </code>