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:controlling_turtlesim_2 [2019/07/03 11:51] – [ASDF dependencies] tlippstutorials:beginner:controlling_turtlesim_2 [2022/02/21 10:08] (current) – [Fluents] schimpf
Line 10: Line 10:
 ==== ROS dependencies ==== ==== ROS dependencies ====
  
-In this tutorial we will re-use the package ''cram_my_beginner_tutorial'' that you have created in the previous tutorial. For controlling the turtle, we need to depend on the ''turtlesim'' package, since it contains the message definitions we will use. Further, we will want to use the communication functionality of ROS to talk to the ''turtlesim'' from inside Lisp, so we depend on ''roslisp''. Finally, we will have to deal with poses. For that, we want to use the package ''cl_transforms'' and ''geometry_msgs''. Add these dependencies to the ''package.xml'' as described in [[http://wiki.ros.org/catkin/Tutorials/CreatingPackage|Package creation]]. You can find the resulting code in the corresponding [[https://github.com/cram-code/cram_tutorials/tree/master/cram_beginner_tutorial|Github repo]].+In this tutorial we will re-use the package ''cram_my_beginner_tutorial'' that you have created in the previous tutorial. For controlling the turtle, we need to depend on the ''turtlesim'' package, since it contains the message definitions we will use. Further, we will want to use the communication functionality of ROS to talk to the ''turtlesim'' from inside Lisp, so we depend on ''roslisp''. Finally, we will have to deal with poses. For that, we want to use the package ''cl_transforms'' and ''geometry_msgs''. Add these dependencies to the ''package.xml'' as described in [[http://wiki.ros.org/catkin/Tutorials/CreatingPackage|Package creation]]. You can find the resulting code in the corresponding [[https://github.com/cram2/cram/tree/master/cram_tutorials/cram_beginner_tutorial|Github repo]].
  
 ==== ASDF dependencies ==== ==== ASDF dependencies ====
Line 30: Line 30:
 We also want to add ''roslisp'' and ''cl-transforms'' to our namespace in the file ''package.lisp'' so that we don't have to specify the namespace each time we use a function from that package in our code. We also want to add ''roslisp'' and ''cl-transforms'' to our namespace in the file ''package.lisp'' so that we don't have to specify the namespace each time we use a function from that package in our code.
 <code lisp> <code lisp>
-(defpackage :cram-beginner-tutorial+(defpackage :cram-my-beginner-tutorial
   (:nicknames :tut)   (:nicknames :tut)
   (:use :cpl :roslisp :cl-transforms))   (:use :cpl :roslisp :cl-transforms))
Line 94: Line 94:
                 :b b                 :b b
                 :width width                 :width width
-                :off off))                         +                :off off))
 </code>                            </code>                           
                                                                                
Line 107: Line 107:
 ===== Experimenting in the REPL ===== ===== Experimenting in the REPL =====
  
-Now let's try it out. Open your Lisp REPL and make sure that you loaded the system ''cram-beginner-tutorial'' and switched to the package ''tut'', hint:+Now let's try it out. Open your Lisp REPL and make sure that you loaded the system ''cram-my-beginner-tutorial'' and switched to the package ''tut'', hint:
  
 <code lisp> <code lisp>
-CL-USER> (ros-load:load-system "cram_beginner_tutorial" :cram-beginner-tutorial)+CL-USER> (ros-load:load-system "cram_my_beginner_tutorial" :cram-my-beginner-tutorial)
 ... ...
 CL-USER> (in-package :tut) CL-USER> (in-package :tut)
Line 231: Line 231:
 Let's see if we can also move the turtle from Lisp. Try the following: Let's see if we can also move the turtle from Lisp. Try the following:
 <code lisp> <code lisp>
-TUT> (dotimes (i 10) (send-vel-cmd 1 1) (sleep 1))+TUT> (dotimes (i 10) (send-vel-cmd 1 1) (wait-duration 1))
 </code> </code>
 We use the ''send-vel-cmd'' function that we defined in ''control-turtlesim.lisp''. We send the same command 10 times, once every second. The turtle should now move along a circle. We use the ''send-vel-cmd'' function that we defined in ''control-turtlesim.lisp''. We send the same command 10 times, once every second. The turtle should now move along a circle.