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. When you source env.sh, orocreate-pkg will be in your PATH.How to use it
The script takes at least one argument: the package name. A second option specifies what to generate in the package, in our case, a component:$ cd ~/orocos $ orocreate-pkg myrobot component 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 Makefile manifest.xml src # Standard build (installs in the same directory as Orocos Toolchain): $ mkdir build ; cd build $ cmake .. -DCMAKE_INSTALL_PREFIX=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. See orocreate-pkg --help for other options which allow you to generate other files.
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
- src/myrobot-component.cpp : template for the Myrobot component. Note that this C++ class is capitalized ('M') while the project name is lower-case ('m').
- src/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 installation directory (or that you used -DCMAKE_INSTALL_PREFIX=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.
- Printer-friendly version
- Login or register to post comments