Both sides previous revisionPrevious revisionNext revision | Previous revision |
doc:beginner:controlling_turtlesim [2014/01/17 10:47] – gkazhoya | doc:beginner:controlling_turtlesim [2014/01/19 12:51] (current) – gkazhoya |
---|
**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. |
| |
| |
==== 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> |
==== 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 |
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)) |
(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") |
| |
===== 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) |