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
doc:beginner:controlling_turtlesim [2013/12/17 13:44] gkazhoyadoc:beginner:controlling_turtlesim [2014/01/19 12:51] (current) gkazhoya
Line 5: Line 5:
 **Next Tutorial:** [[doc:beginner:simple_plans|Implementing simple plans to move a turtle]] **Next Tutorial:** [[doc:beginner:simple_plans|Implementing simple plans to move a turtle]]
  
-In this tutorial we will re-use the package ''cram_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'', the latter one is only needed if you're working with Hydro or a newer ROS version. +In this tutorial we will re-use the package ''cram_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'', the latter one is only needed if you're working with Hydro or a newer ROS version. 
  
  
Line 14: Line 14:
 ==== catkin ==== ==== catkin ====
  
-Open ''package.xml'' from the root directory of your ''cram_tutorial'' package and add the lines+Open ''package.xml'' from the root directory of your ''cram_beginner_tutorial'' package and add the lines
 <code xml> <code xml>
   <build_depend>roslisp</build_depend>   <build_depend>roslisp</build_depend>
Line 42: Line 42:
 ==== Updating cram dependecies ==== ==== Updating cram dependecies ====
  
-Now open ''cram-tutorial.asd'' and update the system dependencies to include the system  ''roslisp'', ''turtlesim-msg'', ''geometry_msgs-msg'' and ''cl-transforms''. The systems that correspond to the messages of a package are always named like the package name with a ''-msg'' suffix. Your system should now look like this:+Now open ''cram-beginner-tutorial.asd'' and update the system dependencies to include the system  ''roslisp'', ''turtlesim-msg'', ''geometry_msgs-msg'' and ''cl-transforms''. The systems that correspond to the messages of a package are always named like the package name with a ''-msg'' suffix. Your system should now look like this:
  
 <code lisp> <code lisp>
-(defsystem cram-tutorial+(defsystem cram-beginner-tutorial
   :depends-on (roslisp cram-language turtlesim-msg cl-transforms geometry_msgs-msg)   :depends-on (roslisp cram-language turtlesim-msg cl-transforms geometry_msgs-msg)
   :components   :components
Line 54: Line 54:
 </code> </code>
  
-===== Updating the the Lisp Package =====+===== Updating the Lisp Package =====
  
 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-tutorial+(defpackage cram-beginner-tutorial
   (:nicknames :tut)   (:nicknames :tut)
   (:use #:cpl #:roslisp #:cl-transforms))   (:use #:cpl #:roslisp #:cl-transforms))
Line 65: Line 65:
 ===== Writing the communication glue code ===== ===== Writing the communication glue code =====
  
-Now it's time to use roslisp to connect to turtlesim. Turtlesim creates one ROS topic namespace per turtle. For each turtle name (turtle1, turtle2, etc.) it publishes the pose of the turtle on a ''~/pose topic'', publishes the color value under the turtle (the background color) on a ''~/color_sensor'' topic. For each turtle turtlesim subscribes to a ''~/cmd_vel'' topic (or ''~/command_velocity'' before hydro) waiting for commands to move the turtle. This is the topic through which we will be controlling our turtles from Lisp.+Now it's time to use roslisp to connect to turtlesim. Turtlesim creates one ROS topic namespace per turtle. For each turtle name (turtle1, turtle2, etc.) it publishes the pose of the turtle on a ''~/pose'' topic, publishes the color value under the turtle (the background color) on a ''~/color_sensor'' topic. For each turtle turtlesim subscribes to a ''~/cmd_vel'' topic (or ''~/command_velocity'' before hydro) waiting for commands to move the turtle. This is the topic through which we will be controlling our turtles from Lisp.
  
 ==== The code ==== ==== The code ====
Line 76: Line 76:
 (in-package :tut) (in-package :tut)
  
-(defvar *color-value* (make-fluent :name :color-value) "current color of turtle")+(defvar *color-value* (make-fluent :name :color-value) "current color under the turtle")
 (defvar *turtle-pose* (make-fluent :name :turtle-pose) "current pose of turtle") (defvar *turtle-pose* (make-fluent :name :turtle-pose) "current pose of turtle")
  
Line 159: Line 159:
 ===== 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-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-beginner-tutorial'' and switched to the package ''tut'', hint:
  
 <code lisp> <code lisp>
-CL-USER> (ros-load:load-system "cram_tutorial" :cram-tutorial)+CL-USER> (ros-load:load-system "cram_beginner_tutorial" :cram-beginner-tutorial)
 ... ...
 CL-USER> (in-package :tut) CL-USER> (in-package :tut)
Line 290: Line 290:
  
  
-Now that we have functions and fluents to connect to the turtlesim, let'implementing some simple plans.+Now that we have functions and fluents to connect to the turtlesim, let'implement some simple plans.
  
 [[doc:beginner:simple_plans|Implementing simple plans to move a turtle]] [[doc:beginner:simple_plans|Implementing simple plans to move a turtle]]