Robotics StackExchange | Archived questions

Cannot compile ros2 control demo from the github

I'm trying to colcon build the ros2_control, controller, and the demo but it gave me the error enter code here

    error: no matching function for call to ‘from_chars(const char*, const char*, double&)’
       37 |   const auto parse_result = std::from_chars(text.data(), text.data() + text.size(), result_value);
          |                                                                                                 ^
     In file included from /home/tharit/control_ws/src/ros2_control/hardware_interface/src/mock_components/generic_system.cpp:20:
        /usr/include/c++/9/charconv:600:5: note: candidate: ‘template<class _Tp> std::__detail::__integer_from_chars_result_type<_Tp> std::from_chars(const char*, const char*, _Tp&, int)’
          600 |     from_chars(const char* __first, const char* __last, _Tp& __value,
              |     ^~~~~~~~~~

    /usr/include/c++/9/charconv:600:5: note:   template argument deduction/substitution failed:
    In file included from /usr/include/c++/9/bits/move.h:55,
                     from /usr/include/c++/9/bits/stl_pair.h:59,
                     from /usr/include/c++/9/bits/stl_algobase.h:64,
                     from /usr/include/c++/9/bits/char_traits.h:39,
                     from /usr/include/c++/9/string:40,
                     from /home/tharit/control_ws/src/ros2_control/hardware_interface/include/mock_components/generic_system.hpp:20,
                     from /home/tharit/control_ws/src/ros2_control/hardware_interface/src/mock_components/generic_system.cpp:17:
    /usr/include/c++/9/type_traits: In substitution of ‘template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = std::integral_constant<bool, false>::value; _Tp = std::from_chars_result]’:
    /usr/include/c++/9/charconv:592:11:   required by substitution of ‘template<class _Tp> using __integer_from_chars_result_type = std::enable_if_t<std::__and_<std::is_integral<_Tp>, std::__not_<std::__or_<std::is_same<_Tp, bool>, std::is_same<_Tp, char16_t>, std::is_same<_Tp, char32_t>, std::is_same<_Tp, wchar_t> > > >::value, std::from_chars_result> [with _Tp = double]’
    /usr/include/c++/9/charconv:600:5:   required by substitution of ‘template<class _Tp> std::__detail::__integer_from_chars_result_type<_Tp> std::from_chars(const char*, const char*, _Tp&, int) [with _Tp = double]’
    /home/tharit/control_ws/src/ros2_control/hardware_interface/src/mock_components/generic_system.cpp:37:97:   required from here
    /usr/include/c++/9/type_traits:2378:11: error: no type named ‘type’ in ‘struct std::enable_if<false, std::from_chars_result>’
     2378 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
          |           ^~~~~~~~~~~
    /home/tharit/control_ws/src/ros2_control/hardware_interface/src/mock_components/generic_system.cpp: In function ‘double mock_components::parse_double(const string&)’:
    /home/tharit/control_ws/src/ros2_control/hardware_interface/src/mock_components/generic_system.cpp:37:97: error: no matching function for call to ‘from_chars(const char*, const char*, double&)’
       37 |   const auto parse_result = std::from_chars(text.data(), text.data() + text.size(), result_value);
          |                                                                                                 ^
    In file included from /home/tharit/control_ws/src/ros2_control/hardware_interface/src/mock_components/generic_system.cpp:20:
    /usr/include/c++/9/charconv:600:5: note: candidate: ‘template<class _Tp> std::__detail::__integer_from_chars_result_type<_Tp> std::from_chars(const char*, const char*, _Tp&, int)’
      600 |     from_chars(const char* __first, const char* __last, _Tp& __value,
          |     ^~~~~~~~~~
    /usr/include/c++/9/charconv:600:5: note:   template argument deduction/substitution failed:
    In file included from /usr/include/c++/9/bits/move.h:55,
                     from /usr/include/c++/9/bits/stl_pair.h:59,
                     from /usr/include/c++/9/bits/stl_algobase.h:64,
                     from /usr/include/c++/9/bits/char_traits.h:39,
                     from /usr/include/c++/9/string:40,
                     from /home/tharit/control_ws/src/ros2_control/hardware_interface/include/mock_components/generic_system.hpp:20,
                     from /home/tharit/control_ws/src/ros2_control/hardware_interface/src/mock_components/generic_system.cpp:17:
    /usr/include/c++/9/type_traits: In substitution of ‘template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = std::integral_constant<bool, false>::value; _Tp = std::from_chars_result]’:
    /usr/include/c++/9/charconv:592:11:   required by substitution of ‘template<class _Tp> using __integer_from_chars_result_type = std::enable_if_t<std::__and_<std::is_integral<_Tp>, std::__not_<std::__or_<std::is_same<_Tp, bool>, std::is_same<_Tp, char16_t>, std::is_same<_Tp, char32_t>, std::is_same<_Tp, wchar_t> > > >::value, std::from_chars_result> [with _Tp = double]’
    /usr/include/c++/9/charconv:600:5:   required by substitution of ‘template<class _Tp> std::__detail::__integer_from_chars_result_type<_Tp> std::from_chars(const char*, const char*, _Tp&, int) [with _Tp = double]’
    /home/tharit/control_ws/src/ros2_control/hardware_interface/src/mock_components/generic_system.cpp:37:97:   required from here
    /usr/include/c++/9/type_traits:2378:11: error: no type named ‘type’ in ‘struct std::enable_if<false, std::from_chars_result>’
     2378 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
          |           ^~~~~~~~~~~
    /home/tharit/control_ws/src/ros2_control/hardware_interface/src/component_parser.cpp: In function ‘double hardware_interface::detail::get_parameter_value_or(const tinyxml2::XMLElement*, const char*, double)’:
    /home/tharit/control_ws/src/ros2_control/hardware_interface/src/component_parser.cpp:141:83: error: no matching function for call to ‘from_chars(const char* const&, const char*, double&)’
      141 | _chars(tag_text, tag_text + std::strlen(tag_text), result_value);
          |                                                                ^

    In file included from /home/tharit/control_ws/src/ros2_control/hardware_interface/src/component_parser.cpp:16:
    /usr/include/c++/9/charconv:600:5: note: candidate: ‘template<class _Tp> std::__detail::__integer_from_chars_result_type<_Tp> std::from_chars(const char*, const char*, _Tp&, int)’
      600 |     from_chars(const char* __first, const char* __last, _Tp& __value,
          |     ^~~~~~~~~~
    /usr/include/c++/9/charconv:600:5: note:   template argument deduction/substitution failed:
    In file included from /usr/include/c++/9/charconv:36,
                     from /home/tharit/control_ws/src/ros2_control/hardware_interface/src/component_parser.cpp:16:
    /usr/include/c++/9/type_traits: In substitution of ‘template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = std::integral_constant<bool, false>::value; _Tp = std::from_chars_result]’:
    /usr/include/c++/9/charconv:592:11:   required by substitution of ‘template<class _Tp> using __integer_from_chars_result_type = std::enable_if_t<std::__and_<std::is_integral<_Tp>, std::__not_<std::__or_<std::is_same<_Tp, bool>, std::is_same<_Tp, char16_t>, std::is_same<_Tp, char32_t>, std::is_same<_Tp, wchar_t> > > >::value, std::from_chars_result> [with _Tp = double]’
    /usr/include/c++/9/charconv:600:5:   required by substitution of ‘template<class _Tp> std::__detail::__integer_from_chars_result_type<_Tp> std::from_chars(const char*, const char*, _Tp&, int) [with _Tp = double]’
    /home/tharit/control_ws/src/ros2_control/hardware_interface/src/component_parser.cpp:141:83:   required from here
    /usr/include/c++/9/type_traits:2378:11: error: no type named ‘type’ in ‘struct std::enable_if<false, std::from_chars_result>’
     2378 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
          |           ^~~~~~~~~~~
    make[2]: *** [CMakeFiles/fake_components.dir/build.make:63: CMakeFiles/fake_components.dir/src/mock_components/generic_system.cpp.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:195: CMakeFiles/fake_components.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....
    make[2]: *** [CMakeFiles/mock_components.dir/build.make:63: CMakeFiles/mock_components.dir/src/mock_components/generic_system.cpp.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:419: CMakeFiles/mock_components.dir/all] Error 2
    make[2]: *** [CMakeFiles/hardware_interface.dir/build.make:76: CMakeFiles/hardware_interface.dir/src/component_parser.cpp.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:141: CMakeFiles/hardware_interface.dir/all] Error 2
    make: *** [Makefile:141: all] Error 2
    ---
    Failed   <<< hardware_interface [1.19s, exited with code 2]
    Aborted  <<< rqt_controller_manager [0.86s]
    Aborted  <<< rqt_joint_trajectory_controller [0.87s]

    Summary: 4 packages finished [1.80s]
      1 package failed: hardware_interface
      2 packages aborted: rqt_controller_manager rqt_joint_trajectory_controller
      1 package had stderr output: hardware_interface
      30 packages not processed

Could you please guide me the way to fix this. I use UBUNTU20.04 and ros2 foxy

Asked by Tharit Sinsunthorn on 2023-06-12 21:25:58 UTC

Comments

Quick comment: you tagged foxy. Have you checked you're building the correct branches of ros2_control et al.?

Asked by gvdhoorn on 2023-06-14 03:15:11 UTC

Thank you for your comment, I follow this link https://github.com/ros-controls/ros2_control_demos/tree/foxy. However, I'm a beginner for ros2 and robot programming so I'm not sure that I have done something wrong or not.

Asked by Tharit Sinsunthorn on 2023-06-14 03:25:47 UTC

If git -C /home/tharit/control_ws/src/ros2_control status does not say you're on the foxy branch, you're not building the correct versions.

Asked by gvdhoorn on 2023-06-14 04:31:28 UTC

It says On branch master. I understand the situation. Maybe I should clone form the foxy branch directly. Thank you very much for your helps!

Asked by Tharit Sinsunthorn on 2023-06-15 03:39:08 UTC

Answers