Tutorial: Periodic Execution of RTC (C++)

Overview

If you want to use C++ language, CMake (cross platform make) system must be used to generate Makefile or Visual Studio project.
Then, you can edit your RTC's source code by modifying the callbacks.

Please follow the following steps:

CMake (Cross platform compilation)

You have to alternatives 1.cmake-gui, 2.cmake command-line.

CMake-GUI (Windows, Linux)

Open CMake-gui with Start Button (or cmake-gui command), and "drag & drop" the "CMakeLists.txt" file from your skeleton project folder.

In the "where to build" edit box, add "build" folder, and press "Configure" button.

Allow cmake to create "build" folder.

Select your Build environment. In Windows, Visual Studio 2008 / 2010. In Linux, Unix Makefile is normal selection.

Then, press "Generate" button to generate your project.

Finally, you can get the Visual Studio Solution file / Makefile in "build" folder.

Command Line (Linux)

% cd your-path-to-workspace/MyFirstRTC_cpp
% mkdir build
% cd build
% cmake ../

Editing Code

Let's edit the generated RTC's code.

How to find your skeleton code

The generated file tree is a bit complicated. Please follow this content, if you confuse to find your source code MyFirstRTC.cpp.

Visual C++ 2010 (Windows)

You can find many projects are associated with your solution. Do not mind.

Your RTC can be found in "myfirstrtc" project.

Please open the project tree, and select "MyFirstRTC.cpp" source code.

Unix Makefile (Linux)

You can find your RTC's skeleton code in "path-to-your-workspace/MyFirstRTC_cpp/src" directory.

Open the MyFirstRTC.cpp file with your favorite editor.

Override Callback Functions

In the MyFirstRTC.cpp, you can find lots of function declaration (but commented out).
If you edit the "activity tab" in RTC builder, the selected callback function will be uncommented.

In the previous step, you would have activated the following three functions:
1. onActivated
2. onDeactivated
3. onExecute

Please edit these functions.

onActivated

Example:

RTC::ReturnCode_t MyFirstRTC::onActivated(RTC::UniqueId ec_id)
{

	std::cout 

onDeactivated

Example:

RTC::ReturnCode_t MyFirstRTC::onDeactivated(RTC::UniqueId ec_id)
{
	std::cout 

onExecute

Example:

RTC::ReturnCode_t MyFirstRTC::onExecute(RTC::UniqueId ec_id)
{
	std::cout 

Build

Visual C++ 2010 (Windows)

Just Build your solution.

Then, you can get your RTC-component (DLL) with "myfirstrtc" project, and your executable binary is generated with "myfirstrtccomp" project.
Exe file is generated in "your-path-to-workspace/MyFirstRTC_cpp/build/src/[Debug/Release]/" folder.

Unix Makefile (Linux)

% make

Then, you can get your RT-component in "your-path-to-workspace/MyFirstRTC_cpp/build/src" directory.

Launch RTC

Start Name Service

Please start Name Service first. If you use Windows, "Start">>"Programs">>"OpenRTM-aist 1.1">>"[C++/Python/Java]">>"tools">>"Start Naming Service".

If you use command-line, just enter "rtm-naming".

In Ubuntu linux (and other linuxes that uses major packaging manager), the omniNames process would be running if you install OpenRTM-aist.
The omniNames is a CORBA naming service that OpenRTM also uses to manage launched RTCs.
Please stop omniNames first, then start Naming Service.

Example:

% service omniNames stop

Launch RTC

Please launch RTC.

Visual Studio

In visual studio, executable binary is generated in "myfirstrtccomp" project.
First, please check the "myfirstrtccomp" project as "Start Up Project".

Just right click the project in solution explorer, then select "Start Up Project" in the drop-down menu.

Command Line

Execute RTC in command-line:

% cd path-to-your-workspace/MyFirstRTC_cpp/build/src/
% ./myfirstrtccomp

Your RTC would not output any messages in this step.

Please proceed in the next step and let's activate your RTC.


Prev Up >> Next

Documentation:

Download

latest Releases : 2.0.0-RELESE

2.0.0-RELESE Download page

Number of Projects

Choreonoid

Motion editor/Dynamics simulator

OpenHRP3

Dynamics simulator

OpenRTP

Integrated Development Platform

AIST RTC collection

RT-Components collection by AIST

TORK

Tokyo Opensource Robotics Association

DAQ-Middleware

Middleware for DAQ (Data Aquisition) by KEK