Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
doc:beginner:package_for_turtlesim [2014/03/12 14:23] – created hmessdoc:beginner:package_for_turtlesim [2015/04/28 15:36] – [Exporting the ASDF system to ROS] gkazhoya
Line 1: Line 1:
 ====== Creating a CRAM package ====== ====== Creating a CRAM package ======
  
-**Description:** In this tutorial you will set up a ROS package to use the CRAM plan language within the repl.+**Description:** In this tutorial you will set up a ROS package to use the CRAM plan language within the lisp repl.
  
-**Next Tutorial:** [[doc:beginner:controlling_turtlesim_2|Controlling turtlesim from Lisp_2]]+**Next Tutorial:** [[doc:beginner:controlling_turtlesim_2|Controlling turtlesim from CRAM]]
  
 ===== Creating a ROS package ===== ===== Creating a ROS package =====
Line 33: Line 33:
             :components             :components
             ((:file "package")             ((:file "package")
-             (:file "tutorial" :depends-on ("package"))))))+             (:file "control-turtlesim" :depends-on ("package"))))))
 </code> </code>
                            
Line 39: Line 39:
 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. 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 ''src''. Further, we define that this module contains two components, one file for the package definition ''package.lisp'' and one with the actual tutorial code ''tutorial.lisp'' that has exactly one dependency - the component ''package''. We will create these two source files next. Dependencies inside the system can be any component that is known in the current scope. That means that a component can only depend on those components that are defined in the same parent component. Please note that the file extension must be left out when defining files.+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 ''src''. Further, we define that this module contains two components, one file for the package definition ''package.lisp'' and one with the actual tutorial code ''control-turtlesim.lisp'' that has exactly one dependency - the component ''package''. We will create these two source files next. Dependencies inside the system can be any component that is known in the current scope. That means that a component can only depend on those components that are defined in the same parent component. Please note that the file extension must be left out when defining files.
  
 ==== Creating the Lisp Package ==== ==== Creating the Lisp Package ====
  
-Lisp packages are the equivalent to C++ namespaces or to Python modules. Lisp packages cannot be hierarchicWe 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.+Lisp packages are the equivalent to C++ namespaces or Python modules. Lisp packages cannot be hierarchicalThrough 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 ''src'' in your package. Then create the file ''package.lisp'' and put the following code into it: Create a sub-directory ''src'' in your package. Then create the file ''package.lisp'' and put the following code into it:
Line 53: Line 53:
 </code>   </code>  
      
-We define a package with the name ''cram-beginner-tutorial''. Packages in Common Lisp can have an arbitrary number of nicknames. In our case we nickname ''cram-beginner-tutorial'' as ''tut''. Finally, we define that the package uses another package ''cpl'' which is a nickname of the package  ''CRAM Plan Language''.  +We define a package with the name ''cram-beginner-tutorial''. Packages in Common Lisp can have an arbitrary number of nicknames. In our case we nickname ''cram-beginner-tutorial'' as ''tut''. Finally, we define that the package uses another package ''cpl'' which is a nickname of the package  ''cram-language'' from the metapackage ''cram_core''
-<!--Please note that most Common Lisp packages actually use the package ''common-lisp'' which exports all symbols of the Common Lisp standard. The packages ''cpl'' and ''common-lisp'' cannot be used together because the CRAM Language re-defines some of the symbols of the ''common-lisp'' package and thus ''cpl'' and ''common-lisp'' would conflict.+
  
- 
- We have to deside how much lisp content we want to have in here. 
---> 
 ==== Exporting the ASDF system to ROS ==== ==== 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 ''tutorial.lisp'' in ''src'', so create it with the following content:+To actually load the ASDF system, all files referenced in the system definition must be present and we are missing the file ''control-turtlesim.lisp'' in ''src'', so create it with the following content:
  
 <code lisp> <code lisp>
Line 67: Line 63:
 </code> </code>
  
-This just selects the namespace of the file by the nickname '':tut'' we defined in ''package.lisp''. We will fill it with more content in later tutorials.+This just selects the namespace of the file by the nickname '':tut'' we defined in ''package.lisp''. We will fill it with more content in the next tutorial.
  
-Now we are ready to compile and load our new system. Launch the Lisp REPL. If it is already running, reload it by executing: +Now we are ready to compile and load our new system. Launch the Lisp REPL (''$ roslisp_repl'').  
- +Then load your newly created system by typing:
-<code lisp> +
-+
-restart-inferior-lisp +
-</code> +
- +
-in the REPL. Then load your newly created system by typing:+
  
 <code lisp> <code lisp>
Line 82: Line 72:
 </code> </code>
  
-<!--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 unstead:+This loads the ''cram-beginner-tutorial'' of the package ''cram_beginner_tutorial''
 +Test it by evaluating
  
 <code lisp> <code lisp>
-+(in-package :tut)
-ros-load-system +
-cram_beginner_tutorial +
-cram-beginner-tutorial+
 </code> </code>
  
-The first parameter to ''ros-load-system'' 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. --> +== Next ==
-Now the package ''cram-beginner-tutorial'' should be defined. Test it by evaluating+
  
-<code lisp> 
-(in-package :tut) 
-</code> 
  
 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:beginner:controlling_turtlesim_2|Controlling turtlesim from Lisp_2]]+[[doc:beginner:controlling_turtlesim_2|Controlling turtlesim from CRAM]]