Using orocreate-pkg

Where to find it

The orocreate-pkg script is installed in your bin directory where the deployer and other OCL tools are installed, or you can find it in orocos-toolchain/ocl/scripts/pkg/orocreate-pkg.

How to use it

The script only takes one argument: the package name. For example:
$ cd myproject
$ orocreate-pkg myrobot
Using templates at /home/kaltan/src/git/orocos-toolchain/ocl/scripts/pkg/templates...
Package myrobot created in directory /home/kaltan/src/git/orocos-toolchain/myproject/myrobot
$ cd myrobot
$ ls
CMakeLists.txt  manifest.xml  myrobot-component.cpp  myrobot-component.hpp  myrobot-plugin.cpp  
myrobot-service.cpp  myrobot-types.hpp  orocos-myrobot.pc.in  support.cpp Makefile
# Standard build:
  $ mkdir build ; cd build
  $ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/orocos
  $ make install
# OR: ROS build:
  $ make

You can modify the .cpp/.hpp files and the CMakeLists.txt file to adapt them to your needs. It's possible that you don't need all of them, in that case, you can remove them from the CMakeLists.txt file.

What gets generated

All files that are generated may be modified by you, except for all files in the typekit directory. That directory is generated during a build and under the control of the Orocos typegen tool, from the orogen package.

  • Makefile : default makefile to start the CMake configuration process. In case you use ROS, this file is rosmake compatible.
  • CMakeLists.txt : specify what gets build (documented in the file itself) See also our RTT Cheat Sheet
  • myrobot-component.cpp : template for the Myrobot component. Note that this C++ class is capitalized ('M') while the project name is lower-case ('m').
  • myrobot-types.hpp : put the structs/classes of communicated data in here. Restrictions apply on how such a class/struct may look like. See Typegen manual and the Orocos typekits manual.
  • typekit/ : This directory is generated by the cmake process and is under control of typegen. It contains generated code for all data found in the myrobot-types.hpp file or any other header listed in the CMakeLists.txt file.
  • Other files are examples for services and plugins and not for novice users.

Loading the component

After the 'make install' step, make sure that your RTT_COMPONENT_PATH includes the /opt/orocos/lib/orocos directory (or that the toolchain was installed in /opt/orocos) and then start the deployer for your platform:

$ deployer-gnulinux
   Switched to : Deployer
 
  This console reader allows you to browse and manipulate TaskContexts.
  You can type in an operation, expression, create or change variables.
  (type 'help' for instructions and 'ls' for context info)
 
    TAB completion and HISTORY is available ('bash' like)
 
Deployer [S]> import("myrobot")
 = true
 
Deployer [S]> displayComponentTypes
I can create the following component types:
   Myrobot
   OCL::ConsoleReporting
   OCL::FileReporting
   OCL::HMIConsoleOutput
   OCL::HelloWorld
   OCL::TcpReporting
   OCL::TimerComponent
 = (void)
 
Deployer [S]> loadComponent("TheRobot","Myrobot")
Myrobot constructed !
 = true
 
Deployer [S]> cd TheRobot
   Switched to : TheRobot
TheRobot [S]> ls
 
 Listing TaskContext TheRobot[S] :
 
 Configuration Properties: (none)
 
 Provided Interface:
  Attributes   : (none)
  Operations      : activate cleanup configure error getPeriod inFatalError inRunTimeError 
isActive isConfigured isRunning setPeriod start stop trigger update 
 
 Data Flow Ports: (none)
 
 Services: 
(none)
 
 Requires Operations :  (none)
 Requests Services   :  (none)
 
 Peers        : (none)

Extending the component or its plugins

You now need to consult the Component Builder's Manual for instructions on how to use and extend your Orocos component. All relevant documentation is available on the Toolchain Reference Manuals page.

ROS package compatibility

The generated package contains a manifest.xml file and the CMakeLists.txt file will call ros_buildinit() if ROS_ROOT has been set and also sets the LIBRARY_OUTPUT_PATH to packagename/lib/orocos such that the ROS tools can find the libraries and the package itself. The ROS integration is mediated in the UseOrocos-RTT.cmake file, which gets included on top of the generated CMakeLists.txt file and is installed as part of the RTT. The Makefile file is rosmake compatible.

The OCL deployer knows about ROS packages and can import Orocos components (and their dependencies) from them once your ROS_PACKAGE_PATH has been correctly set.