This package supports the 1.x versions of RTT. Check out the orocos_toolchain_ros for integration with the 2.x versions.
Contents
Overview
This package can be used to automatically export the dataports (read and write) of Orocos RTT components to ROS. This package supports the 1.x versions of RTT. Check out the orocos_toolchain_ros for integration with the 2.x versions.
For now only exporting dataports are supported. Method/Command interface is on its way.
To make the automatic export working you have to make sure that the conversion of RTT Types and Ros Messages is added to the RTT::RosToolkit.
Video
Mapping data types
To map the different types you must add two conversion functions (Ros to Orocos and Orocos to Ros) in the RosTypeConversion.hpp file of the package.
For each Ros type (RosType) you want to add, find out the name (RttTypeName) and C++ type (OrocosType) of the corresponding type in the RTT::Type system
Add the following conversion code to the RosTypeConversion.hpp:
1 template <> 2 struct StdRosTypeConversion<OrocosType>: 3 public RosTypeConversion<RosType,OrocosType>{ 4 static bool copyRosToOrocos(RosTypeConstPtr ros,OrocosType& orocos){ 5 //The conversion code e.g. orocos=ros->data; 6 return true; 7 }; 8 static bool copyOrocosToRos(const OrocosType& orocos,RosType& ros){ 9 //The conversion code e.g. ros.data=orocos; 10 return true; 11 }; 12 };
and add the following lines to the RosToolkit.cpp file:
If you want to add support for the RosType in the RTT::Type system you can also add it as a new RTT::Type. Add the following code to the RosTypeConversion.hpp
1 template <> 2 struct StdRosTypeConversion<RosType> 3 : public RosTypeConversion<RosType,RosType>{ 4 static bool copyRosToOrocos(RosTypeConstPtr ros,RosType& orocos){ 5 orocos=(*ros); 6 return true; 7 }; 8 static bool copyOrocosToRos(const RosType& orocos,RosType& ros){ 9 ros=orocos; 10 return true; 11 }; 12 }; 13 struct RosTypeTypeInfo 14 : public RTT::TemplateTypeInfo<RosType>{ 15 RosTypeTypeInfo() 16 : RTT::TemplateTypeInfo<RosType>("RosType") 17 {} 18 };
and the following code to the RosToolkit.cpp file:
Example
See the Components.cpp, example.xml and example.launch files for an example application using the integration