Modifying GripperManipulation Plugin to be an RT component

Attach a “receptacle” for the RT component to the plugin referred to as Choreonoid/extPlugin/graspPlugin/GripperManipulation.

Details on the original GripperManipulation

This is a graspPlugin plugin for the grasping plan intended for twin arm robots, with the following file configurations:
CMakeLists.txt: cmake definition file
GripperManipulationMain.cpp: Choreonoid plugin ManipPlugin class source
ManipBar.cpp: Choreonoid tool bar ManipBar class source
ManipBar.h: Choreonoid tool bar ManipBar class header
ManipController.cpp: grasping plan controller ManipController class source
ManipController.h: grasping plan controller ManipController class header
PRM: grasping plan data file directory

In order to make the structure of the program easier to see, GripperManipulationMain.cpp is renamed ManipPlugin. In addition, CMakeLists.txt is also modified and verified to ensure that it can be compiled.

Preparing the RT components skeleton with RTC Builder

In the preliminary preparation, the rtc directory is prepared under GripperManipulation, while GraspController.idl is also placed there.
Run Eclipse and set a new Eclipse project (a dummy project) in this rtc directory. Select “C++ Project” in the Wizard selection and set the respective items in the following manner.
Project name: GraspControllerRTC
Location (user’s working directory): /Choreonoid/extplugin/graspPlugin/GripperManipulation/rtc
Project type: Executable - Empty Project

Press the “Finish” button and a dialog box with the prompt, "Open C++ Perspective?" will be displayed. This can be closed.
The preliminary preparations are now complete. Open the RTC Builder Perspective with Eclipse. Click on the RT icon to open the RtcBuilder View and set the necessary information for each tab.

“Basic” tab

Module name: GripperManipulation
Module summary: Gripper Manipulation
Vendor name: AIST
Module category: TestInterface
Output Project GripperManipulationRTC (select the project that was prepared earlier).

Other items can be left with the default settings.

"Language and environment" tab

Select C++.

“Service port” tab

Press the Add Port button. A port called “sv_name” is created. Click on it with the mouse and display the Profile Setting screen on the right side. Set the port name to PlanStartPort and then press the Add Interface button to set the following information to the newly created interface.
Interface name: PlanStart
Direction: Required
IDL file: /home/asahi/workspace/Choreonoid/extplugin/graspPlugin/GripperManipulation/rtc/GraspController.idl
Interface type: GraspPlanStart (selectable item)
IDL path: /home/asahi/workspace/Choreonoid/extplugin/graspPlugin/GripperManipulation/rtc/
In the same way, create the port, ResultPort, and the interface, Result.
Interface name: Result
Direction: Provided
IDL file: /home/asahi/workspace/Choreonoid/extplugin/graspPlugin/GripperManipulation/rtc/GraspController.idl
Interface type: GraspPlanResult
IDL path: /home/asahi/workspace/Choreonoid/extplugin/graspPlugin/GripperManipulation/rtc/

Generate codes

The settings for the RTC Builder are now complete. Open the Basic tab again and press the Generate Code button to create the following files in Choreonoid/extPlugin/graspPlugin/GripperManipulation/rtc:
  • GraspControllerSVC_impl.cpp
  • GraspControllerSVC_impl.h
  • GripperManipulation.conf
  • GripperManipulation.cpp
  • GripperManipulation.h
  • GripperManipulationComp.cpp
  • GripperManipulationComp_vc8.vcproj
  • GripperManipulationComp_vc9.vcproj
  • GripperManipulation_vc8.sln
  • GripperManipulation_vc8.vcproj
  • GripperManipulation_vc9.sln
  • GripperManipulation_vc9.vcproj
  • Makefile.GripperManipulation
  • RTC.xml
  • copyprops.bat
  • user_config.vsprops
Follow the instructions on the screen and switch to C++ Perspective.
At this point, a series of settings are stored in RTC.xml and saved together. When changing the settings of the RT components, the import function of the Profile in the Basic tab of the RTC Builder can be used to recall these settings.

Compile rtc

Open the terminal, move to the GripperManipulation/rtc directory, then execute the following command.

 % omniidl -bcxx GraspController.idl 

GraspController.hh and are generated. Next, execute make. It is necessary to specify the Makefile.
 % make -f Makefile.GripperManipulation

This generates GraspControllerSkel.cpp, GraspControllerStub.cpp, GraspControllerSkel.h, and GraspControllerStub.h (these do not go through the compilation process but can continue on unchanged).

Prepare the bridging class for the Choreonoid plugin and the RT components

Copy GraspRtcController.h and GraspRtcController.cpp from graspPlugin/GraspConsumer to GripperManipulation, then edit them.
Since it may be confused with ManipController.h(cpp), the file name is changed to ManipRtc.h(cpp).

Sample patch

A patch file that edits a series of files all at once was prepared as a sample.

 % svn co -r131

After checking out revision 131 of GripperManipulation, perform settings for RTC Builder and prepare ManipRtc.h(cpp), then download the patch file GripperManipulation_patch.txt, then execute the following command.
 % patch -p0 < GripperManipulation_patch.txt

This applies all changes simultaneously and the build can be performed immediately.
The following is a summary of the changes made using the patch file.


Changes the class name to ManipRtc (the refactoring function of Eclipse is useful, but care must be taken to ensure that the source, GraspConsumer, is not changed also!).
Change the part that includes GraspConsumer.h, GraspController.hh, and GripperManipulation.h under rtc. Change the type of comp from GraspConsumer * to ::GripperManipulation *. The parts that are the arguments of graspPlanResult and have become const GraspPlanResult, are all changed to ::GraspPlanResult. The identifier of the include guard is also changed to match the header and becomes MANIPRTC_H.
Add codes to start the RT components in the ManipPlugin::initialize method.
    virtual bool initialize() {
      //Robotics::SceneBodyManager* manager = Robotics::SceneBodyManager::instance();


Change the class of grasp::ManipRtc to a friend class of GripperManipulation.
 using namespace RTC;
 namespace  grasp {
    class ManipRtc;


 class GripperManipulation
  : public RTC::DataFlowComponentBase
  friend class grasp::ManipRtc; 


Since RTCBuilder outputs the arguments of the IDL data type as CORBA, but omniidl outputs the same data as ::CORBA, compiler errors occur when the types are different. For this reason, a declaration for the CORBA namespace-type argument is rewritten to ::CORBA, in order to match the output of omniidl. In addition, with regard to the argument for the method of GraspPlanResultSVC_impl class, the declaration for the GraspPlanStart name space-type argument is rewritten to GraspPlanResult (this may be a bug in RTCBuilder).


  • set(rtc-dir ./rtc) is added
  • include_directories(${rtc-dir}) is added
ManipRtc.cpp, ${rtc-dir}/GraspControllerSVC_impl.cpp, ${rtc-dir}/GripperManipulation.cpp, ${rtc­
dir}/GraspControllerSkel.cpp are added to sources.
  • ManipRtc.h, ${rtc-dir}/GraspController.hh, ${rtc-dir}/GraspControllerSVC_impl.h, ${rtc­dir}/GripperManipulation.h, ${rtc-dir}/GraspControllerSkel.h, ${rtc-dir}/GraspControllerStub.h are added to the headers.
  • -fPIC -O2 -I/usr/include -I/usr/include/rtm/idl -I. is added to add_definitions.
  • uuid dl pthread omniORB4 omnithread omniDynamic4 RTC coil is added to target_link_libraries.
  • Lines elseif(MSVC) to endif(UNIX), which are paired with if(UNIX), are deleted.

Build and verify movements

In the first instance, execute ccmake in the Choreonoid directory.

 % ccmake. 

Add GripperManipulation to GRASP_PLUGINS and execute configure and generate to prepare Makefile. Execute make and if lib/choreonoid-0.9/ is built successfully, verify the movements.
Boot Choreonoid and the RT System Editor, then verify that GripperManipulation0|rtc exists under (host name)| host_cxt, which is under in the NameServer tab. If this can be dragged and dropped into the System Diagram, the process has been completed successfully.
(However, if nothing happens when this is linked to other RT components, then continue on to the Section on Modify GripperManipulation to RT components and implement).