orocos-toolchain / orogen

Code generator for components and type handling in Rock - the Robot Construction Kit - and the Orocos Toolchain
http://rock-robotics.org
Other
4 stars 35 forks source link

Fixed clang importer for double-types #63

Closed goldhoorn closed 9 years ago

goldhoorn commented 9 years ago

Otherwise /double was unknown in this code-block which results to failures.

@marvin2k took a look already

marvin2k commented 9 years ago

ducttape

...seems to work.

doudou commented 9 years ago

Wrong fix. /double is unknown to this method because this method does not need to know about /double. If some tuning of orogen_include is needed, do it in base/orogen/std.

goldhoorn commented 9 years ago

Double is already exported by the base/orogen/std typekit: https://github.com/rock-core/base-orogen-std/blob/master/std.orogen#L27

But the clang of some packages are failing, backtrace:

goldhoorn@mgoldhoorn:~/bootstraps/master/drivers/orogen/dynamixel$ /usr/bin/ruby2.1 /home/goldhoorn/bootstraps/master/tools/orogen/bin/orogen --corba --extensions=metadata_support --import=std --no-rtt-scripting --parallel-build=6 --transports=corba,mqueue,typelib --type-export-policy=used dynamixel.orogen --debug --verbose
OroGen[INFO]: loading oroGen project logger on dynamixel
OroGen[INFO]: registering oroGen project logger
OroGen[INFO]:    removing /home/goldhoorn/bootstraps/master/drivers/orogen/dynamixel/.orogen/typekit/stamp
OroGen[WARN]: The plugin MetaDataPlugin defines a "register_for_generation" hook, this got renamed to "generation_hook" please adapt the code or contact the developer.
===== Internal error =======
Please report the following error to the orogen developers
/home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/gen/typekit.rb:2185:in `include_for_type': while rendering tasks/TaskBase.hpp: no includes known for /double defined in [] (OroGen::InternalError)
    from /home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/templates/tasks/TaskBase.hpp:22:in `block in generate'
    from /home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/templates/tasks/TaskBase.hpp:20:in `each'
    from /home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/templates/tasks/TaskBase.hpp:20:in `generate'
    from /usr/lib/ruby/2.1.0/erb.rb:850:in `eval'
    from /usr/lib/ruby/2.1.0/erb.rb:850:in `result'
    from /home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/gen/templates.rb:64:in `render_template'
    from /home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/gen/tasks.rb:564:in `generate'
    from /home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/gen/project.rb:699:in `block in generate'
    from /home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/gen/project.rb:699:in `each'
    from /home/goldhoorn/bootstraps/master/tools/orogen/lib/orogen/gen/project.rb:699:in `generate'
    from /home/goldhoorn/bootstraps/master/tools/orogen/bin/orogen:172:in `<main>'
doudou commented 9 years ago

Then you'll have to find out why the std metadata is not propagated here. No way I'm merging this.

goldhoorn commented 9 years ago

Then i will gave the ball to @marvin2k

marvin2k commented 9 years ago

The two different (clang and gccxml) tlb files look remarkably similar, especially the part where "double" is mentioned... So the two importers might use different code paths -- not a big feat given the many paths available...

marvin2k commented 9 years ago

To add some real content to this thread: There is already a difference between the two importers when Generation.render_template is called in tools/orogen/lib/orogen/gen/tasks.rb:564. The '/double' types in self.self_properties there have no metadata entry named 'orogen_include' for the clang-importer, while the gccxml importer created this entry, albeit as an empty string.

In contrast, the typekit of the whole project, in tools/orogen/lib/orogen/gen/project.rb:699, does have the metadata entry for '/double' for both importers... hm...

Sidenote: pry is some awesome piece of tooling ;-)

doudou commented 9 years ago

Sidenote: pry is some awesome piece tooling ;-)

Agreed. Try pry-byebug (you will need ruby > 2.1.5 though), finally a decent debugger for Ruby

marvin2k commented 9 years ago

Ok, got it. As my gut-feeling said right in the beginning: a missing call to add_standard_cxx_types in typelibs clang-based importer was the rotten reason. But sometimes its better to stumble to the relevant location the hard way ;-)

For ports (and probably properties and attributes) of a task, its type is tried to look up in the projects database using find_type() of project.rb where registry.build() is called to obtain a type object.

Adding something like like the following in tools/typelib:

diff --git a/bindings/ruby/lib/typelib/clang.rb b/bindings/ruby/lib/typelib/clang.rb
index f5879b9..b105482 100644
--- a/bindings/ruby/lib/typelib/clang.rb
+++ b/bindings/ruby/lib/typelib/clang.rb
@@ -5,6 +5,7 @@ module Typelib
     module CLangLoader
         # Imports the given C++ file into the registry using CLANG
         def self.load(registry, file, kind, options)
+            Typelib::Registry.add_standard_cxx_types(registry)
             #Checking if the clang importer is installed and can be found on the system
             if !system("which typelib-clang-tlb-importer > /dev/null 2>&1")
                 raise RuntimeError, "typelib-clang-tlb-importer is not installed in PATH"

will fix the "problem" at hand (no empty metadata entry for "orogen_include" of '/double').

A difference can be observed in orogen_include_of_type(). There, the metadata of /double is completely empty if the above modification to typelib is done -- but contains "orogen_defining_typekits" naming "std" as source in the vanilla version using the clang-importer. So the actual bad thing to do is defining things like "double" in the std-typekit and via typelibs standard_cxx_types function.

Trying to fix this (manually setting empty metadata "orogen_include" entry in std.orogen for double and float) leads to other problems... nil-class comparison in template files... giving up... boar...

doudou commented 9 years ago

Adding add_standard_cxx_types is obviously fixing the symptom, not the cause.

One obvious problem (for me) was that base/orogen/std is meant to set the metadata already. I found out that it did, but that the typelib TLB import/export was losing the information. See https://github.com/orocos-toolchain/typelib/pull/67

Does that help ?

goldhoorn commented 9 years ago

Better no everything of rock but kdl builds

[  8%] [  8%] Building CXX object .orogen/typekit/CMakeFiles/kdl-typekit-gnulinux.dir/type_info/__KDL__Vector.cpp.o
Building CXX object .orogen/typekit/CMakeFiles/kdl-typekit-gnulinux.dir/type_info/__KDL__Vector2.cpp.o
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp: In function 'void orogen_typekits::fromIntermediate(std::vector<KDL::Frame>&, const std::vector<wrappers::KDLFrame>&)':
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp:31:38: error: invalid use of incomplete type 'class KDL::Frame'
In file included from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/typekit/OpaqueFwd.hpp:6:0,
                 from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/typekit/OpaqueConvertions.hpp:6,
                 from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp:3:
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/KDL/wrappers/KDLTypes.hpp:14:11: error: forward declaration of 'class KDL::Frame'
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp: In function 'void orogen_typekits::fromIntermediate(std::vector<KDL::Twist>&, const std::vector<wrappers::KDLTwist>&)':
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp:52:38: error: invalid use of incomplete type 'class KDL::Twist'
In file included from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/typekit/OpaqueFwd.hpp:6:0,
                 from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/typekit/OpaqueConvertions.hpp:6,
                 from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp:3:
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/KDL/wrappers/KDLTypes.hpp:17:11: error: forward declaration of 'class KDL::Twist'
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp: In function 'void orogen_typekits::fromIntermediate(std::vector<KDL::Wrench>&, const std::vector<wrappers::KDLWrench>&)':
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp:73:39: error: invalid use of incomplete type 'class KDL::Wrench'
In file included from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/typekit/OpaqueFwd.hpp:6:0,
                 from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/typekit/OpaqueConvertions.hpp:6,
                 from /home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/OpaqueConvertions.cpp:3:
/home/goldhoorn/bootstraps/master/control/orogen/kdl/.orogen/typekit/types/kdl/KDL/wrappers/KDLTypes.hpp:16:11: error: forward declaration of 'class KDL::Wrench'
In file included from /usr/include/c++/4.9/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/4.9/bits/char_traits.h:39,
                 from /usr/include/c++/4.9/string:40,

....and much more error....

goldhoorn commented 9 years ago

seems fixed by: https://github.com/orocos-toolchain/typelib/issues/67