Custom ROS types in OROCOS again

I want to transmit custom ROS types from OROCOS but I am missing one single step it seems.

I have seen the other posts in this forum and also the example, I still don't know the answer.

I am using OROCOS 2.5.0 and ROS Fuerte.

Here is my workflow:

- - - - - - - - - - - - - - - - - 8< - - - - - - - - - - - - - - - - -

1) rosrun ocl orocreate-pkg MyPackage

2) create a src folder and copy all the cpp and hpp files into it

3) edit the cmakelists:

- adding src/ to all cpp and hpp files - add three lines for the ros message stuff:

 if (ROS_ROOT)
  include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
  rosbuild_init()
  rosbuild_find_ros_package( rtt )
  set( RTT_HINTS HINTS ${rtt_PACKAGE_PATH}/install )
 endif()
->

 if (ROS_ROOT)
  include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
  rosbuild_init()
  rosbuild_find_ros_package( rtt )
  set( RTT_HINTS HINTS ${rtt_PACKAGE_PATH}/install )
  
    rosbuild_genmsg()
    rosbuild_include(rtt_rosnode GenerateRTTtypekit )
    ros_generate_rtt_typekit(MyPackage)

 endif()
4) add dependencies in manifest.xml:

<depend package="rtt" /> <depend package="roslib" /> <depend package="rtt_rosnode" />

(otherwise there were compilation errors which I googled and these depends helped)

5) add an msg folder and add msg files, for instance:

double_int.msg containing

 Header header
 float64[7] doubledata
 int64[7] longdata
6) rosmake

- - - - - - - - - - - - - - - - - 8< - - - - - - - - - - - - - - - - -

Everything compiles fine (when my custom types are not used inside the code). A nice double_int.h file is created inside msg_gen\cpp\include\MyPackage. It just seems that it is used nowhere... I cannot use my new type inside MyPackage-component.hpp, it is unknown. A collegue of mine told me I just had to #include <MyPackage/typegen/Types.hpp>. Then however, I get compiler errors:

  In file included from .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:1:0:
  .../ros_workspace/orocos/MyPackage/src/MyPackage-component.hpp:9:7: error: ‘struct MyPackage’ redeclared as different kind of symbol
  .../ros_workspace/orocos/MyPackage/msg_gen/cpp/include/MyPackage/double_int.h:20:1: error: previous declaration of ‘namespace MyPackage { }’
  .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp: In function ‘RTT::TaskContext* createComponent(std::string)’:
  .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: error: expected type-specifier before ‘MyPackage’
  .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: error: cannot convert ‘int*’ to ‘RTT::TaskContext*’ in return
  .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: error: expected ‘;’ before ‘MyPackage’
  .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: error: expected primary-expression before ‘(’ token
  .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type]
  make[3]: *** [CMakeFiles/MyPackage.dir/src/MyPackage-component.cpp.o] Error 1
Even if it compiled, I don't think it includes my type-h files. It includes

include "MyPackage/types/MyPackage/src/MyPackage-types.hpp"

which contains:

 /**
 * In this header you may define a number of classes or structs,
 * which will be picked up by the typegen tool.
 *
 * typegen will not process headers included by this header.
 * If you want to generate type support for another header than
 * this one, add that header in the CMakeLists.txt file.
 */

 #include "vector" // actually not "" but the smaller and bigger signs, this forum just uses them for formatting

 /**
 * Just an example struct. You may remove/modify it.
 * Note that there are restrictions. Take a look at the
 * Orocos typekit plugin manuals and the typegen documentation.
 */
 struct MyPackageData
 {
    /** Contains a sequence of doubles. */
    std::vector3 samples;
 };
What am I doing wrong or missing? Do I have to include all the generated mytype.h files manually?

Kind regards, Mirko

Custom ROS types in OROCOS again

On 02/15/2013 12:40 PM, mirko [dot] kunze [..] ... wrote:
> I want to transmit custom ROS types from OROCOS but I am missing one single
> step it seems.
>
> I have seen the other posts in this forum and also the example, I still don't
> know the answer.
>
> I am using OROCOS 2.5.0 and ROS Fuerte.
>
> Here is my workflow:
>
> - - - - - - - - - - - - - - - - - 8< - - - - - - - - - - - - - - - - -
>
> 1) rosrun ocl orocreate-pkg MyPackage
>
> 2) create a src folder and copy all the cpp and hpp files into it
>
> 3) edit the cmakelists:
>
> - adding src/ to all cpp and hpp files
> - add three lines for the ros message stuff:
>
> if (ROS_ROOT)
> include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
> rosbuild_init()
> rosbuild_find_ros_package( rtt )
> set( RTT_HINTS HINTS ${rtt_PACKAGE_PATH}/install )
> endif()
>
> ->
>
> if (ROS_ROOT)
> include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
> rosbuild_init()
> rosbuild_find_ros_package( rtt )
> set( RTT_HINTS HINTS ${rtt_PACKAGE_PATH}/install )
>
> rosbuild_genmsg()
> rosbuild_include(rtt_rosnode GenerateRTTtypekit )
> ros_generate_rtt_typekit(MyPackage)
>
> endif()
>
> 4) add dependencies in manifest.xml:
>
>
>
>
>
> (otherwise there were compilation errors which I googled and these depends
> helped)
>
> 5) add an msg folder and add msg files, for instance:
>
> double_int.msg containing
>
> Header header
> float64[7] doubledata
> int64[7] longdata
>
> 6) rosmake
>
> - - - - - - - - - - - - - - - - - 8< - - - - - - - - - - - - - - - - -
>
> Everything compiles fine (when my custom types are not used inside the code).
> A nice double_int.h file is created inside msg_gen\cpp\include\MyPackage. It
> just seems that it is used nowhere...
> I cannot use my new type inside MyPackage-component.hpp, it is unknown.
> A collegue of mine told me I just had to #include . Then however, I get
> compiler errors:
>
> In file included from
> .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:1:0:
> .../ros_workspace/orocos/MyPackage/src/MyPackage-component.hpp:9:7: error:
> ‘struct MyPackage’ redeclared as different kind of symbol
>
> .../ros_workspace/orocos/MyPackage/msg_gen/cpp/include/MyPackage/double_int.h:20:1:
> error: previous declaration of ‘namespace MyPackage { }’
> .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp: In function
> ‘RTT::TaskContext* createComponent(std::string)’:
> .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: error:
> expected type-specifier before ‘MyPackage’
> .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: error:
> cannot convert ‘int*’ to ‘RTT::TaskContext*’ in return
> .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: error:
> expected ‘;’ before ‘MyPackage’
> .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1: error:
> expected primary-expression before ‘(’ token
> .../ros_workspace/orocos/MyPackage/src/MyPackage-component.cpp:16:1:
> warning: control reaches end of non-void function [-Wreturn-type]
> make[3]: *** [CMakeFiles/MyPackage.dir/src/MyPackage-component.cpp.o] Error
> 1
>
> Even if it compiled, I don't think it includes my type-h files. It includes
>
> include "MyPackage/types/MyPackage/src/MyPackage-types.hpp"
You should not include this one but:

#include <MyPkg/typekit/MsgName.h>

as is indicated on the webpage: http://www.ros.org/wiki/rtt_ros_integration

>
> which contains:
>
> /**
> * In this header you may define a number of classes or structs,
> * which will be picked up by the typegen tool.
> *
> * typegen will not process headers included by this header.
> * If you want to generate type support for another header than
> * this one, add that header in the CMakeLists.txt file.
> */
>
> #include "vector" // actually not "" but the smaller and bigger signs, this
> forum just uses them for formatting
>
> /**
> * Just an example struct. You may remove/modify it.
> * Note that there are restrictions. Take a look at the
> * Orocos typekit plugin manuals and the typegen documentation.
> */
> struct MyPackageData
> {
> /** Contains a sequence of doubles. */
> std::vector samples;
> };
>
> What am I doing wrong or missing?
> Do I have to include all the generated mytype.h files manually?

Hope this helps.

Tinne
>
> Kind regards,
> Mirko

Custom ROS types in OROCOS again

Thank you! Now I am one step further.

This links to:

include/MyPkg/typekit

There even is a Types.hpp in that directory which seems to include all my custom types. There are also headers for all my custom types. However, these include:

 // note: we preferably would include the message header instead of the boost stuff.
 #include <MyPkg/boost/MyMsg.h>
and the compiler says no such file or directory. Do I have to add some boost dependency?

EDIT:

I noticed that in some working examples, there is also a boost directory inside include/PACKAGENAME. However, such directory is not created in my package. How can I generate it?

Custom ROS types in

On 02/25/2013 03:44 PM, mirko [dot] kunze [..] ... wrote:
> Thank you! Now I am one step further.
>
> This links to:
>
> include/MyPkg/typekit
>
> There even is a Types.hpp in that directory which seems to include all my
> custom types.
> There are also headers for all my custom types. However, these include:
>
> // note: we preferably would include the message header instead of the boost
> stuff.
> #include
>
> and the compiler says no such file or directory. Do I have to add some boost
> dependency?

If the manifest of your original package included all necessary
dependencies everything should work out of the box.
In your original email I saw that you had to adapt the manifest by hand.
I think you should restart from scratch and try to follow the
instructions as close as possible. As soon something is wrong you should
send us an error report.
This would make sure that we are not trying to solve some "hacked"
solution you are trying.

Tinne

PS: try to stick to the mailinglist guidelines to not top-post, to reply
inline (interleaved posting),... such that there can be no confusion on
what you actually replying on ..

Re: Custom ROS types in OROCOS again

Tinne De Laet wrote:

On 02/25/2013 03:44 PM, mirko [dot] kunze [..] ... wrote:
> Thank you! Now I am one step further.
>
> This links to:
>
> include/MyPkg/typekit
>
> There even is a Types.hpp in that directory which seems to include all my
> custom types.
> There are also headers for all my custom types. However, these include:
>
> // note: we preferably would include the message header instead of the boost
> stuff.
> #include
>
> and the compiler says no such file or directory. Do I have to add some boost
> dependency?

If the manifest of your original package included all necessary
dependencies everything should work out of the box.
In your original email I saw that you had to adapt the manifest by hand.
I think you should restart from scratch and try to follow the
instructions as close as possible. As soon something is wrong you should
send us an error report.
This would make sure that we are not trying to solve some "hacked"
solution you are trying.

Tinne

PS: try to stick to the mailinglist guidelines to not top-post, to reply
inline (interleaved posting),... such that there can be no confusion on
what you actually replying on ..

Sorry, I am using the forum, not the mailinglist. Actually I find it quite annoying that the whole discussion appears in each post. I hope the quote thing is what you wanted. My main target is to create an OROCOS component which is able to send and receive custom ROS messages.

Now I retried everything on another system (OROCOS 2.5.0, ROS 1.6.8 (electric I think)). This time, I tried not to put everything into a src folder.

After I created the component, I tried rosmake without changing anything. There were some errors. I changed "string" to "std::string" in the component hpp file and it compiled. No additional dependencies required this time. Afterwards I added the msg folder with some .msg files inside and added the three lines to the cmakelists:

rosbuild_genmsg()
rosbuild_include(rtt_rosnode GenerateRTTtypekit )
ros_generate_rtt_typekit(RosComTest)

rosmake again. CMake Error: Failed to include GenerateRTTtypekit from rtt_rosnode. Edited the manifest.xml: It only contained the dependency (depend package="rtt"/) and I added (depend package="rtt_rosnode"/).

rosmake

Everything compiled without problems, the previously missing boost folder was also created. Woohoo! Now the last step: include RosComTest/typekit/Types.hpp (This file actually contains includes of all my custom types)

Aaaand I am back to the original errors:

[ 33%] Building CXX object CMakeFiles/RosComTest.dir/RosComTest-component.cpp.o
In file included from .../RosComTest/RosComTest-component.cpp:1:0:
.../RosComTest/RosComTest-component.hpp:10:7: Error: `struct RosComTest´ redeclared as different kind of symbol
.../RosComTest/msg_gen/cpp/include/RosComTest/cartCmd.h:19:1: Error: previous declaration of `namespace RosComTest { }´
.../RosComTest/RosComTest-component.cpp: In function `RTT::TaskContext* createComponent(std::string)´:
.../RosComTest/RosComTest-component.cpp:16:1: Error: expected type-specifier before `RosComTest´
.../RosComTest/RosComTest-component.cpp:16:1: Error: cannot convert ‘int*’ to ‘RTT::TaskContext*’ in return
.../RosComTest/RosComTest-component.cpp:16:1: Error: expected `;´ before `RosComTest´
.../RosComTest/RosComTest-component.cpp:16:1: Error: expected primary-expression before `(´ token
.../RosComTest/RosComTest-component.cpp:16:1: Warning: control reaches end of non-void function [-Wreturn-type]

The full folder with all the stuff can be downloaded here:
https://dl.dropbox.com/u/11704339/RosComTest.tar.gz

I would appreciate any help! Thanks in advance!

Re: Custom ROS types in OROCOS again

Mircode wrote:
Tinne De Laet wrote:

On 02/25/2013 03:44 PM, mirko [dot] kunze [..] ... wrote:
> Thank you! Now I am one step further.
>
> This links to:
>
> include/MyPkg/typekit
>
> There even is a Types.hpp in that directory which seems to include all my
> custom types.
> There are also headers for all my custom types. However, these include:
>
> // note: we preferably would include the message header instead of the boost
> stuff.
> #include
>
> and the compiler says no such file or directory. Do I have to add some boost
> dependency?

If the manifest of your original package included all necessary
dependencies everything should work out of the box.
In your original email I saw that you had to adapt the manifest by hand.
I think you should restart from scratch and try to follow the
instructions as close as possible. As soon something is wrong you should
send us an error report.
This would make sure that we are not trying to solve some "hacked"
solution you are trying.

Tinne

PS: try to stick to the mailinglist guidelines to not top-post, to reply
inline (interleaved posting),... such that there can be no confusion on
what you actually replying on ..

Sorry, I am using the forum, not the mailinglist. Actually I find it quite annoying that the whole discussion appears in each post. I hope the quote thing is what you wanted. My main target is to create an OROCOS component which is able to send and receive custom ROS messages.

Now I retried everything on another system (OROCOS 2.5.0, ROS 1.6.8 (electric I think)). This time, I tried not to put everything into a src folder.

After I created the component, I tried rosmake without changing anything. There were some errors. I changed "string" to "std::string" in the component hpp file and it compiled. No additional dependencies required this time. Afterwards I added the msg folder with some .msg files inside and added the three lines to the cmakelists:

rosbuild_genmsg()
rosbuild_include(rtt_rosnode GenerateRTTtypekit )
ros_generate_rtt_typekit(RosComTest)

rosmake again. CMake Error: Failed to include GenerateRTTtypekit from rtt_rosnode. Edited the manifest.xml: It only contained the dependency (depend package="rtt"/) and I added (depend package="rtt_rosnode"/).

rosmake

Everything compiled without problems, the previously missing boost folder was also created. Woohoo! Now the last step: include RosComTest/typekit/Types.hpp (This file actually contains includes of all my custom types)

Aaaand I am back to the original errors:

[ 33%] Building CXX object CMakeFiles/RosComTest.dir/RosComTest-component.cpp.o
In file included from .../RosComTest/RosComTest-component.cpp:1:0:
.../RosComTest/RosComTest-component.hpp:10:7: Error: `struct RosComTest´ redeclared as different kind of symbol
.../RosComTest/msg_gen/cpp/include/RosComTest/cartCmd.h:19:1: Error: previous declaration of `namespace RosComTest { }´
.../RosComTest/RosComTest-component.cpp: In function `RTT::TaskContext* createComponent(std::string)´:
.../RosComTest/RosComTest-component.cpp:16:1: Error: expected type-specifier before `RosComTest´
.../RosComTest/RosComTest-component.cpp:16:1: Error: cannot convert ‘int*’ to ‘RTT::TaskContext*’ in return
.../RosComTest/RosComTest-component.cpp:16:1: Error: expected `;´ before `RosComTest´
.../RosComTest/RosComTest-component.cpp:16:1: Error: expected primary-expression before `(´ token
.../RosComTest/RosComTest-component.cpp:16:1: Warning: control reaches end of non-void function [-Wreturn-type]

The full folder with all the stuff can be downloaded here:
https://dl.dropbox.com/u/11704339/RosComTest.tar.gz

I would appreciate any help! Thanks in advance!

So, the error is obviously, that a namespace is created in msg_gen/cpp/include/RosComTest/[typename].h, which has the same name as my component. So the compiler complains that the main-class of my component has also the same name as this namespace.

Unfortunatelly, I don't know which one I can rename, since the content of both things will be addressed elsewhere deep in the generated code, I guess.

Furthermore, I cannot imagine that I am the only person who encountered this problem... The only workaround I see is to separate my custom types into another component and include its Types.hpp from my main component. But I know that this is not the intended way.
Or I could include ROS manually in my cpp code, not via OROCOS ports.

Or someone can come up with a cool solution.

PS: ros_generate_rtt_typekit(RosComTest) <- I have to insert the exact name of my component here, right?

Custom ROS types in OROCOS again

On 02/28/2013 05:25 PM, mirko [dot] kunze [..] ... wrote:
>

Mircode wrote:
Tinne De Laet wrote:
On 02/25/2013 03:44 PM,
> mirko [dot] kunze [..] ... wrote:
> > Thank you! Now I am one step further.
> >
> > This links to:
> >
> > include/MyPkg/typekit
> >
> > There even is a Types.hpp in that directory which seems to include all my
> > custom types.
> > There are also headers for all my custom types. However, these include:
> >
> > // note: we preferably would include the message header instead of the
> boost
> > stuff.
> > #include
> >
> > and the compiler says no such file or directory. Do I have to add some
> boost
> > dependency?
>
> If the manifest of your original package included all necessary
> dependencies everything should work out of the box.
> In your original email I saw that you had to adapt the manifest by hand.
> I think you should restart from scratch and try to follow the
> instructions as close as possible. As soon something is wrong you should
> send us an error report.
> This would make sure that we are not trying to solve some "hacked"
> solution you are trying.
>
> Tinne
>
> PS: try to stick to the mailinglist guidelines to not top-post, to reply
> inline (interleaved posting),... such that there can be no confusion on
> what you actually replying on ..

>
> Sorry, I am using the forum, not the mailinglist. Actually I find it quite
> annoying that the whole discussion appears in each post. I hope the quote
> thing is what you wanted. My main target is to create an OROCOS component
> which is able to send and receive custom ROS messages.
I see. Probably the forum is not supporthing this well. If you find it
annoying it might be useful to subscribe to the mailinglist.
>
> Now I retried everything on another system (OROCOS 2.5.0, ROS 1.6.8 (electric
> I think)). This time, I tried not to put everything into a src folder.
>
> After I created the component, I tried rosmake without changing anything.
> There were some errors. I changed "string" to "std::string" in the component
> hpp file and it compiled. No additional dependencies required this time.
> Afterwards I added the msg folder with some .msg files inside and added the
> three lines to the cmakelists:
>
> rosbuild_genmsg()
> rosbuild_include(rtt_rosnode GenerateRTTtypekit )
> ros_generate_rtt_typekit(RosComTest)
>
> rosmake again. CMake Error: Failed to include GenerateRTTtypekit from
> rtt_rosnode. Edited the manifest.xml: It only contained the dependency
> (depend package="rtt"/) and I added (depend package="rtt_rosnode"/).
>
> rosmake
Mmm, this is different from what I was doing: I have a separate ROS
package (nothing to do with orocos) that defines the ROS messages.
I suggest that you try the same. So: one orocos-ros package with your
component and another pure ROS package with the ROS message definitions
(so no need to do anythin like ros_generate_rtt_typekit .... )
You can find an example of such a ROS package with message definitions
at:
http://git.mech.kuleuven.be/?p=robotics/geometric_relations_semantics.gi....

Afterward you apply create the orocos typekit for the ROS messages as
indicated in the manual.

Could you send the results?

Tinne
>
> Everything compiled without problems, the previously missing boost folder was
> also created. Woohoo! Now the last step: include RosComTest/typekit/Types.hpp
> (This file actually contains includes of all my custom types)
>
> Aaaand I am back to the original errors:
>
> [ 33%] Building CXX object
> CMakeFiles/RosComTest.dir/RosComTest-component.cpp.o
> In file included from .../RosComTest/RosComTest-component.cpp:1:0:
> .../RosComTest/RosComTest-component.hpp:10:7: Error: `struct RosComTest´
> redeclared as different kind of symbol
> .../RosComTest/msg_gen/cpp/include/RosComTest/cartCmd.h:19:1: Error:
> previous declaration of `namespace RosComTest { }´
> .../RosComTest/RosComTest-component.cpp: In function `RTT::TaskContext*
> createComponent(std::string)´:
> .../RosComTest/RosComTest-component.cpp:16:1: Error: expected
> type-specifier before `RosComTest´
> .../RosComTest/RosComTest-component.cpp:16:1: Error: cannot convert
> ‘int*’ to ‘RTT::TaskContext*’ in return
> .../RosComTest/RosComTest-component.cpp:16:1: Error: expected `;´ before
> `RosComTest´
> .../RosComTest/RosComTest-component.cpp:16:1: Error: expected
> primary-expression before `(´ token
> .../RosComTest/RosComTest-component.cpp:16:1: Warning: control reaches end
> of non-void function [-Wreturn-type]
>
> The full folder with all the stuff can be downloaded here:
> https://dl.dropbox.com/u/11704339/RosComTest.tar.gz
>
> I would appreciate any help! Thanks in advance!


>
> So, the error is obviously, that a namespace is created in
> msg_gen/cpp/include/RosComTest/[typename].h, which has the same name as my
> component. So the compiler complains that the main-class of my component has
> also the same name as this namespace.
>
> Unfortunatelly, I don't know which one I can rename, since the content of
> both things will be addressed elsewhere deep in the generated code, I guess.
>
> Furthermore, I cannot imagine that I am the only person who encountered this
> problem... The only workaround I see is to separate my custom types into
> another component and include its Types.hpp from my main component. But I
> know that this is not the intended way.
> Or I could include ROS manually in my cpp code, not via OROCOS ports.
>
> Or someone can come up with a cool solution.
>
> PS: ros_generate_rtt_typekit(RosComTest)