Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:beginner:package_for_turtlesim [2015/04/28 15:34] – [Creating the Lisp Package] gkazhoya | doc:beginner:package_for_turtlesim [2015/05/11 16:55] (current) – removed gkazhoya | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Creating a CRAM package ====== | ||
- | **Description: | ||
- | |||
- | **Next Tutorial:** [[doc: | ||
- | |||
- | ===== Creating a ROS package ===== | ||
- | |||
- | First we need to create a ROS package that depends on '' | ||
- | You can do this with either catkin or rosbuild. On the Ros website there are two tutorials about creating a package: [[http:// | ||
- | In the '' | ||
- | <code bash>$ catkin_create_pkg cram_beginner_tutorial cram_language </ | ||
- | |||
- | If you have good reasons you can also follow the rosbuild instructions to create a package. | ||
- | |||
- | ===== Setting up the Lisp infrastructure ===== | ||
- | |||
- | Setting up the Common Lisp part is a little bit more work. First we need to create a Lisp ' | ||
- | After that we will need to create a Common Lisp package (i.e. the equivalent to C++ namespaces). You can learn roslisp in more detail at the [[http:// | ||
- | |||
- | ==== Creating an ASDF system ==== | ||
- | |||
- | Switch into the root directory of the '' | ||
- | and create a file '' | ||
- | |||
- | Put the following content into '' | ||
- | |||
- | <code lisp> | ||
- | (defsystem cram-beginner-tutorial | ||
- | :depends-on (cram-language) | ||
- | :components | ||
- | ((:module " | ||
- | :components | ||
- | ((:file " | ||
- | | ||
- | </ | ||
- | |||
- | |||
- | The first line defines the name of the system. 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 sub-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 '' | ||
- | |||
- | ==== Creating the Lisp Package ==== | ||
- | |||
- | Lisp packages are the equivalent to C++ namespaces or Python modules. Lisp packages cannot be hierarchical. Through Lisp packages we can define which other packages should be used, i.e. which symbols should be accessible without a package prefix. Further, we can define which symbols should be exported from the package. | ||
- | |||
- | Create a sub-directory '' | ||
- | |||
- | <code lisp> | ||
- | (defpackage cram-beginner-tutorial | ||
- | (:nicknames :tut) | ||
- | (:use #:cpl)) | ||
- | </ | ||
- | | ||
- | We define a package with the name '' | ||
- | |||
- | ==== Exporting the ASDF system to ROS ==== | ||
- | |||
- | To actually load the ASDF system, all files referenced in the system definition must be present and we are missing the file '' | ||
- | |||
- | <code lisp> | ||
- | (in-package :tut) | ||
- | </ | ||
- | |||
- | This just selects the namespace of the file by the nickname '': | ||
- | |||
- | Now we are ready to compile and load our new system. Launch the Lisp REPL. | ||
- | Then load your newly created system by typing: | ||
- | |||
- | <code lisp> | ||
- | (ros-load: | ||
- | </ | ||
- | |||
- | This loads the '' | ||
- | Test it by evaluating | ||
- | |||
- | <code lisp> | ||
- | (in-package :tut) | ||
- | </ | ||
- | |||
- | == Next == | ||
- | |||
- | |||
- | Now that we have created our first CRAM package, let's try controlling the ROS turtlesim from it... | ||
- | |||
- | [[doc: |