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 [2019/07/09 18:42] – [Using a location designator] gkazhoyatutorials:beginner:location_designators_2 [2019/07/09 19:21] – [Using a location designator] gkazhoya
Line 32: Line 32:
 ===== Location designator generators ===== ===== Location designator generators =====
  
-Let's create two new files called ''location-designators.lisp'' and ''selecting-process-modules.lisp'' in our tutorial's ''src'' directory and add them to the ''*.asd'' file. The ''selecting-process-modules.lisp'' file should thereby depend on ''motion-designators.lisp'' and ''process-modules.lisp''. The resulting ''cram-my-beginner-tutorial.asd'' should now look like this:+Let's create 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>
Line 45: Line 45:
              (:file "simple-plans" :depends-on ("package" "control-turtlesim"))              (:file "simple-plans" :depends-on ("package" "control-turtlesim"))
              (:file "motion-designators" :depends-on ("package"))              (:file "motion-designators" :depends-on ("package"))
 +             (:file "location-designators" :depends-on ("package"))
              (:file "process-modules" :depends-on ("package"              (:file "process-modules" :depends-on ("package"
                                                    "control-turtlesim"                                                    "control-turtlesim"
Line 51: Line 52:
              (:file "selecting-process-modules" :depends-on ("package"              (:file "selecting-process-modules" :depends-on ("package"
                                                              "motion-designators"                                                              "motion-designators"
-                                                             "process-modules")) +                                                             "process-modules"))))))
-             (:file "location-designators" :depends-on ("package"))))))+
 </code> </code>
  
Line 63: Line 63:
 TUT> goal-desig TUT> goal-desig
 #<A LOCATION #<A LOCATION
-    (VERTICAL-POSITION BOTTOM)+​    (VERTICAL-POSITION BOTTOM)
     (HORIZONTAL-POSITION LEFT)>     (HORIZONTAL-POSITION LEFT)>
 </code> </code>
Line 195: 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''. That means, you might get a different number of solutions than what we got, i.e. 3.+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 but you might be 4 or 5 or something else. 
  
  
Line 232: 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 270: 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 implement the ''available-process-module'' Prolog rule. Put the following code into your ''selecting-process-modules.lisp'' file that we created at the beginning of this tutorial:+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 299: Line 300:
 </code> </code>
  
-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 311: 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>