traversaro / drake-lite-cmake

Reduced (lite) unofficial version of drake (https://drake.mit.edu/) that can be built with CMake.
11 stars 0 forks source link

Add files belonging to the //multibody/parsing:parsing Bazel target #9

Closed traversaro closed 4 years ago

traversaro commented 4 years ago

In drake-lite-cmake we already include the //multibody/plant:plant Bazel target that provides Drake's multibody physics engine (see https://github.com/traversaro/drake-lite-cmake/blob/8cc0e905bf9e09db435bf791bf65abc7ffc45eb0/GenerateSourceFiles.cmake#L14). However, to use it in practice it is necessary to also include the files corresponding to the //multibody/parsing:parsing Bazel target, that contains the class drake::multibody::Parser.

traversaro commented 4 years ago

I gave a quick shot to this, see . There is compilation failure in drake/multibody/parsing/detail_urdf_parser.cc that probably needs to be understood :

straversaro@IITICUBLAP102:~/drake-lite-cmake/build$ make
[  1%] Built target tinyobjloader_double
[  1%] Building CXX object CMakeFiles/drake-lite-cmake.dir/drake/multibody/parsing/detail_urdf_parser.cc.o
/home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc: In function ‘void drake::multibody::internal::{anonymous}::ParseTransmission(drake::multibody::ModelInstanceIndex, const std::map<std::__cxx11::basic_string<char>, double>&, tinyxml2::XMLElement*, drake::multibody::MultibodyPlant<double>*)’:
/home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:517:48: error: no matching function for call to ‘drake::logging::logger::warn(std::__cxx11::basic_string<char>, const double&)’
         "effort limit {}.", effort_iter->second);
                                                ^
In file included from /home/straversaro/drake-lite-cmake/build/drake/geometry/proximity/hydroelastic_internal.h:10:0,
                 from /home/straversaro/drake-lite-cmake/build/drake/geometry/proximity_engine.h:15,
                 from /home/straversaro/drake-lite-cmake/build/drake/geometry/geometry_state.h:21,
                 from /home/straversaro/drake-lite-cmake/build/drake/geometry/scene_graph.h:9,
                 from /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.h:5,
                 from /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:1:
/home/straversaro/drake-lite-cmake/build/drake/common/text_logging.h:131:8: note: candidate: template<class ... Args> void drake::logging::logger::warn(const char*, const Args& ...)
   void warn(const char*, const Args&...) {}
        ^~~~
/home/straversaro/drake-lite-cmake/build/drake/common/text_logging.h:131:8: note:   template argument deduction/substitution failed:
/home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:516:33: note:   cannot convert ‘std::operator+(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>](((const char*)"\" which has a zero effort limit {}."))’ (type ‘std::__cxx11::basic_string<char>’) to type ‘const char*’
         "WARNING: Skipping transmission since it's attached to "
     "joint \"" + joint_name + "\" which has a zero "
     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
     "effort limit {}.", effort_iter->second);
     ~~~~~~~~~~~~~~~~~~

In file included from /home/straversaro/drake-lite-cmake/build/drake/geometry/proximity/hydroelastic_internal.h:10:0, from /home/straversaro/drake-lite-cmake/build/drake/geometry/proximity_engine.h:15, from /home/straversaro/drake-lite-cmake/build/drake/geometry/geometry_state.h:21, from /home/straversaro/drake-lite-cmake/build/drake/geometry/scene_graph.h:9, from /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.h:5, from /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:1: /home/straversaro/drake-lite-cmake/build/drake/common/text_logging.h:140:30: note: candidate: template void drake::logging::logger::warn(const T&) template void warn(const T&) {} ^~~~ /home/straversaro/drake-lite-cmake/build/drake/common/text_logging.h:140:30: note: template argument deduction/substitution failed: /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:517:48: note: candidate expects 1 argument, 2 provided "effort limit {}.", effort_iter->second); ^ CMakeFiles/drake-lite-cmake.dir/build.make:1336: recipe for target 'CMakeFiles/drake-lite-cmake.dir/drake/multibody/parsing/detail_urdf_parser.cc.o' failed


I thought problem could  be related to the fact that we do not depend on `spdlog` and we do not define `HAVE_SPDLOG`, but after enabling  `HAVE_SPDLOG` there is a similar problem:

[ 1%] Building CXX object CMakeFiles/drake-lite-cmake.dir/drake/multibody/parsing/detail_urdf_parser.cc.o /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc: In function ‘void drake::multibody::internal::{anonymous}::ParseTransmission(drake::multibody::ModelInstanceIndex, const std::map<std::cxx11::basic_string, double>&, tinyxml2::XMLElement, drake::multibody::MultibodyPlant)’: /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:517:48: error: no matching function for call to ‘spdlog::logger::warn(std::__cxx11::basic_string, const double&)’ "effort limit {}.", effort_iter->second); ^ In file included from /usr/include/spdlog/logger.h:110:0, from /usr/include/spdlog/spdlog.h:14, from /home/straversaro/drake-lite-cmake/build/drake/common/text_logging.h:72, from /home/straversaro/drake-lite-cmake/build/drake/geometry/proximity/hydroelastic_internal.h:10, from /home/straversaro/drake-lite-cmake/build/drake/geometry/proximity_engine.h:15, from /home/straversaro/drake-lite-cmake/build/drake/geometry/geometry_state.h:21, from /home/straversaro/drake-lite-cmake/build/drake/geometry/scene_graph.h:9, from /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.h:5, from /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:1: /usr/include/spdlog/details/logger_impl.h:149:13: note: candidate: template<class Arg1, class ... Args> void spdlog::logger::warn(const char, const Arg1&, const Args& ...) inline void spdlog::logger::warn(const char fmt, const Arg1 &arg1, const Args&... args) ^~ /usr/include/spdlog/details/logger_impl.h:149:13: note: template argument deduction/substitution failed: /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:516:33: note: cannot convert ‘std::operator+(std::cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _CharT) [with _CharT = char; _Traits = std::char_traits; _Alloc = std::allocator](((const char)"\" which has a zero effort limit {}."))’ (type ‘std::__cxx11::basic_string’) to type ‘const char*’ "WARNING: Skipping transmission since it's attached to "

         "joint \"" + joint_name + "\" which has a zero "
         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
         "effort limit {}.", effort_iter->second);

In file included from /usr/include/spdlog/logger.h:110:0, from /usr/include/spdlog/spdlog.h:14, from /home/straversaro/drake-lite-cmake/build/drake/common/text_logging.h:72, from /home/straversaro/drake-lite-cmake/build/drake/geometry/proximity/hydroelastic_internal.h:10, from /home/straversaro/drake-lite-cmake/build/drake/geometry/proximity_engine.h:15, from /home/straversaro/drake-lite-cmake/build/drake/geometry/geometry_state.h:21, from /home/straversaro/drake-lite-cmake/build/drake/geometry/scene_graph.h:9, from /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.h:5, from /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:1: /usr/include/spdlog/details/logger_impl.h:188:13: note: candidate: template void spdlog::logger::warn(const T&) inline void spdlog::logger::warn(const T& msg) ^~ /usr/include/spdlog/details/logger_impl.h:188:13: note: template argument deduction/substitution failed: /home/straversaro/drake-lite-cmake/build/drake/multibody/parsing/detail_urdf_parser.cc:517:48: note: candidate expects 1 argument, 2 provided "effort limit {}.", effort_iter->second); ^ CMakeFiles/drake-lite-cmake.dir/build.make:1336: recipe for target 'CMakeFiles/drake-lite-cmake.dir/drake/multibody/parsing/detail_urdf_parser.cc.o' failed make[2]: [CMakeFiles/drake-lite-cmake.dir/drake/multibody/parsing/detail_urdf_parser.cc.o] Error 1 CMakeFiles/Makefile2:144: recipe for target 'CMakeFiles/drake-lite-cmake.dir/all' failed make[1]: [CMakeFiles/drake-lite-cmake.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2 straversaro@IITICUBLAP102:~/drake-lite-cmake/build$

traversaro commented 4 years ago

The preliminary branch is https://github.com/traversaro/drake-lite-cmake/tree/fix/9 . However, installing sdformat9 is not obvious on Windows (for example, there is a build time dependency on Ruby) so probably it is better to wait to get sdformat9 in vcpkg first.

traversaro commented 4 years ago

It turns out that the compilation problem on drake/multibody/parsing/detail_urdf_parser.cc is due to the fact that HAVE_SPDLOG set to OFF is not really a supported configuration for the internal drake source code, and it is just in place to be used when text_logging.h is included by non-drake files. Installing a sufficient new (>= 1.3) version of spdlog fixed indeed the problem.

traversaro commented 4 years ago

The preliminary branch is https://github.com/traversaro/drake-lite-cmake/tree/fix/9 . However, installing sdformat9 is not obvious on Windows (for example, there is a build time dependency on Ruby) so probably it is better to wait to get sdformat9 in vcpkg first.

As the fix in this PR will also require a newer version of fmt and spdlog w.r.t. to the one available in Ubuntu 18.04, I don't think it is a bit problem if the dependency are tricky to install in some OS, at least at this stage, as long as the CI is correctly updated. Once sdformat9 is available in vcpkg and Ubuntu 20.04 is out, we will track the problem of document the simple installation of dependencies in https://github.com/traversaro/drake-lite-cmake/issues/10 .