Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:beginner:creating_a_cram_package [2013/12/10 10:31] – bbrieber | doc:beginner:creating_a_cram_package [2014/03/11 13:39] (current) – hmess | ||
---|---|---|---|
Line 4: | Line 4: | ||
**Next Tutorial:** [[doc: | **Next Tutorial:** [[doc: | ||
- | ===== Creating the ROS package ===== | ||
- | First we need to create a ROS package. It needs to depend on '' | ||
- | **catkin** | + | This tutorial assumes that you have set up your ROS environment and installed '' |
- | < | + | |
- | catkin_create_pkg cram_tutorial sbcl cram_language | + | |
- | </code> | + | |
- | **rosbuild** | + | |
- | < | + | |
- | roscreate-pkg cram_tutorial sbcl cram_language | + | |
- | </code> | + | |
- | That was easy. Now we need to set up the lisp infrastructure. | + | ===== Creating a ROS package ===== |
- | ===== Setting up the Lisp infrastructure ===== | + | First we need to create a ROS package that depend on '' |
+ | You can do this with either catkin or rosbuild. | ||
- | Setting up the Common Lisp part is a little more work. First we need to create a Lisp ' | + | **For catkin** |
- | **Note:** ROS is still based on asdf 1.x so no asdf 2.0 features should be used. | + | Go to the '' |
+ | <code bash>$ cd MY_CATKIN_WORKSPACE_PATH/ | ||
+ | and execute the following: | ||
+ | <code bash>$ catkin_create_pkg cram_beginner_tutorial cram_language </ | ||
+ | More information | ||
+ | < | ||
+ | or on the [[http:// | ||
- | After we created the system, we need to create a Common Lisp package (i.e. the equivalent to C++ namespaces). | + | **For rosbuild** |
- | ==== Creating an asdf system ==== | + | Please use '' |
+ | In your rosbuild workspace root do: | ||
+ | <code bash>$ roscreate-pkg cram_beginner_tutorial cram_language</ | ||
+ | That was easy. Now we need to set up the Lisp infrastructure. | ||
+ | ===== Setting up the Lisp infrastructure ===== | ||
- | Switch into the root directory of the cram_tutorial package and create | + | Setting up the Common Lisp part is a little bit more work. First we need to create |
+ | After that we will need to create a Common Lisp package (i.e. the equivalent | ||
- | === The code === | + | ==== Creating an ASDF system |
+ | |||
+ | Switch into the root directory of the '' | ||
+ | |||
+ | <code bash> | ||
+ | $ rospack profile | ||
+ | $ roscd cram_beginner_tutorial | ||
+ | </ | ||
+ | |||
+ | and create a file '' | ||
+ | === The code === | ||
- | Put the following content into '' | + | Put the following content into '' |
- | < | + | < |
- | (defsystem cram-tutorial | + | (defsystem cram-beginner-tutorial |
- | :depends-on (roslisp | + | :depends-on (cram-language) |
:components | :components | ||
((:module " | ((:module " | ||
Line 48: | Line 61: | ||
=== The code explained === | === The code explained === | ||
+ | The first line defines the name of the system. It should be named like the file name in which it is defined. Then we specify the dependencies of the system, i.e. other systems that need to be loaded before we load our system. | ||
- | + | Finally, we define the components of the system. A component is a sort of a sub-system of a system and might be either a module (i.e. a sub-directory) or a file. ASDF knows some more component types but they are not relevant for us most of the time. We define that the system knows a sub-directory | |
- | The first line defines the name of the system. It should be named like the file name in which it is defined. Then we define the dependencies of the system, i.e. other systems that need to be loaded before we load our system. | + | |
- | + | ||
- | Finally | + | |
==== Creating the Lisp Package ==== | ==== Creating the Lisp Package ==== | ||
- | + | Lisp packages are the equivalent to C++ namespaces or to Python | |
- | Lisp packages are the equivalent to C++ namespaces or to python | + | |
=== The code === | === The code === | ||
- | |||
Create a sub-directory '' | Create a sub-directory '' | ||
- | < | + | < |
- | (defpackage cram-tutorial | + | (defpackage cram-beginner-tutorial |
(:nicknames :tut) | (:nicknames :tut) | ||
- | (:use #:cpl #:roslisp)) | + | (:use #:cpl)) |
</ | </ | ||
| | ||
=== The code explained === | === The code explained === | ||
+ | We define a package with the name '' | ||
- | We define a package with the name '' | + | ==== Exporting |
- | ==== Exporting | + | To actually load the ASDF system, all files referenced in the system definition must be present and we are missing the file '' |
- | To actually load the asdf system, all files referenced in the system definition must be present. Create the file '' | + | < |
- | + | ||
- | < | + | |
(in-package :tut) | (in-package :tut) | ||
</ | </ | ||
Line 85: | Line 93: | ||
This just selects the namespace of the file by the nickname '': | This just selects the namespace of the file by the nickname '': | ||
+ | Now we are ready to compile and load our new system. Launch Emacs and load the Lisp REPL. If it is already running, reload it by executing | ||
+ | |||
+ | <code lisp> | ||
+ | , | ||
+ | restart-inferior-lisp | ||
+ | </ | ||
- | Now we are ready to compile and load our new system. Launch Emacs and load the Lisp REPL. Enter the following command: | + | in the REPL. Then, enter the following command: |
- | < | + | < |
- | (ros-load: | + | (ros-load: |
</ | </ | ||
- | You need to load the system every time before you use it, experts would build their own shortcuts to this command or use the rosemacs function: | + | You need to load the system every time before you use it, so experts would build their own shortcuts to this command or use the rosemacs function |
- | < | + | < |
- | "," > ros-load-system | + | , |
+ | ros-load-system | ||
+ | cram_beginner_tutorial | ||
+ | cram-beginner-tutorial | ||
</ | </ | ||
- | The first parameter names the ROS package in which to search for the system, the second parameter names the system to be loaded. Executing the above command should load our new asdf system. Now the package '' | + | The first parameter |
- | < | + | < |
(in-package :tut) | (in-package :tut) | ||
</ | </ | ||
- | Now that we have created our first cram package, let's try controlling the ROS turtlesim from it... | + | Now that we have created our first CRAM package, let's try controlling the ROS turtlesim from it... |
[[doc: | [[doc: |