osrf / system_data_recorder

A rosbag2 recorder node that backs up split files to an external location during recording
Apache License 2.0
7 stars 4 forks source link

Building with ros2 humble and gbiggs backport branch of rosbag2 fails #1

Open cgarry-vs opened 2 years ago

cgarry-vs commented 2 years ago

Pulling in the rosbag2 events from this PR https://github.com/ros2/rosbag2/pull/1037 and attempting to build with ROS2 Humble fails with the following output:

colcon build --symlink-install --packages-select system_data_recorder
Starting >>> system_data_recorder
--- stderr: system_data_recorder                             
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp: In member function ‘virtual rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)’:
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp:101:6: error: ‘rosbag2_cpp::bag_events::WriteSplitInfo’ has not been declared
  101 |     (rosbag2_cpp::bag_events::WriteSplitInfo & info) {
      |      ^~~~~~~~~~~
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp: In lambda function:
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp:104:29: error: request for member ‘opened_file’ in ‘info’, which is of non-class type ‘int’
  104 |       last_bag_file_ = info.opened_file;
      |                             ^~~~~~~~~~~
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp:106:36: error: request for member ‘closed_file’ in ‘info’, which is of non-class type ‘int’
  106 |       notify_new_file_to_copy(info.closed_file);
      |                                    ^~~~~~~~~~~
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp: In member function ‘virtual rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)’:
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp:107:5: error: no match for ‘operator=’ (operand types are ‘rosbag2_cpp::bag_events::BagSplitCallbackType’ {aka ‘std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>’} and ‘sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)::<lambda(int&)>’)
  107 |     };
      |     ^
In file included from /usr/include/c++/9/future:48,
                 from /home/veesai/ros2_humble/install/rclcpp/include/rclcpp/rclcpp/executors.hpp:18,
                 from /home/veesai/ros2_humble/install/rclcpp/include/rclcpp/rclcpp/rclcpp.hpp:155,
                 from /home/veesai/ros2_humble/src/system_data_recorder/include/sdr/sdr_component.hpp:25,
                 from /home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp:15:
/usr/include/c++/9/bits/std_function.h:462:7: note: candidate: ‘std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(const std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {rosbag2_cpp::bag_events::BagSplitInfo&}]’
  462 |       operator=(const function& __x)
      |       ^~~~~~~~
/usr/include/c++/9/bits/std_function.h:462:33: note:   no known conversion for argument 1 from ‘sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)::<lambda(int&)>’ to ‘const std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>&’
  462 |       operator=(const function& __x)
      |                 ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/std_function.h:480:7: note: candidate: ‘std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::function<_Res(_ArgTypes ...)>&&) [with _Res = void; _ArgTypes = {rosbag2_cpp::bag_events::BagSplitInfo&}]’
  480 |       operator=(function&& __x) noexcept
      |       ^~~~~~~~
/usr/include/c++/9/bits/std_function.h:480:28: note:   no known conversion for argument 1 from ‘sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)::<lambda(int&)>’ to ‘std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>&&’
  480 |       operator=(function&& __x) noexcept
      |                 ~~~~~~~~~~~^~~
/usr/include/c++/9/bits/std_function.h:494:7: note: candidate: ‘std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::nullptr_t) [with _Res = void; _ArgTypes = {rosbag2_cpp::bag_events::BagSplitInfo&}; std::nullptr_t = std::nullptr_t]’
  494 |       operator=(nullptr_t) noexcept
      |       ^~~~~~~~
/usr/include/c++/9/bits/std_function.h:494:17: note:   no known conversion for argument 1 from ‘sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)::<lambda(int&)>’ to ‘std::nullptr_t’
  494 |       operator=(nullptr_t) noexcept
      |                 ^~~~~~~~~
/usr/include/c++/9/bits/std_function.h:523:2: note: candidate: ‘template<class _Functor> std::function<_Res(_ArgTypes ...)>::_Requires<std::function<_Res(_ArgTypes ...)>::_Callable<typename std::decay<_Functor>::type>, std::function<_Res(_ArgTypes ...)>&> std::function<_Res(_ArgTypes ...)>::operator=(_Functor&&) [with _Functor = _Functor; _Res = void; _ArgTypes = {rosbag2_cpp::bag_events::BagSplitInfo&}]’
  523 |  operator=(_Functor&& __f)
      |  ^~~~~~~~
/usr/include/c++/9/bits/std_function.h:523:2: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/std_function.h: In substitution of ‘template<class _Res, class ... _ArgTypes> template<class _Cond, class _Tp> using _Requires = typename std::enable_if<_Cond::value, _Tp>::type [with _Cond = std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>::_Callable<sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)::<lambda(int&)>, std::__invoke_result<sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)::<lambda(int&)>&, rosbag2_cpp::bag_events::BagSplitInfo&> >; _Tp = std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>&; _Res = void; _ArgTypes = {rosbag2_cpp::bag_events::BagSplitInfo&}]’:
/usr/include/c++/9/bits/std_function.h:523:2:   required by substitution of ‘template<class _Functor> std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>::_Requires<std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>::_Callable<typename std::decay<_Tp>::type, std::__invoke_result<typename std::decay<_Tp>::type&, rosbag2_cpp::bag_events::BagSplitInfo&> >, std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>&> std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>::operator=<_Functor>(_Functor&&) [with _Functor = sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)::<lambda(int&)>]’
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp:107:5:   required from here
/usr/include/c++/9/bits/std_function.h:385:8: error: no type named ‘type’ in ‘struct std::enable_if<false, std::function<void(rosbag2_cpp::bag_events::BagSplitInfo&)>&>’
  385 |  using _Requires = typename enable_if<_Cond::value, _Tp>::type;
      |        ^~~~~~~~~
/usr/include/c++/9/bits/std_function.h:532:2: note: candidate: ‘template<class _Functor> std::function<_Res(_ArgTypes ...)>& std::function<_Res(_ArgTypes ...)>::operator=(std::reference_wrapper<_Functor>) [with _Functor = _Functor; _Res = void; _ArgTypes = {rosbag2_cpp::bag_events::BagSplitInfo&}]’
  532 |  operator=(reference_wrapper<_Functor> __f) noexcept
      |  ^~~~~~~~
/usr/include/c++/9/bits/std_function.h:532:2: note:   template argument deduction/substitution failed:
/home/veesai/ros2_humble/src/system_data_recorder/src/sdr_component.cpp:107:5: note:   ‘sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)::<lambda(int&)>’ is not derived from ‘std::reference_wrapper<_Tp>’
  107 |     };
      |     ^
make[2]: *** [CMakeFiles/sdr_component.dir/build.make:63: CMakeFiles/sdr_component.dir/src/sdr_component.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:107: CMakeFiles/sdr_component.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< system_data_recorder [2.82s, exited with code 2]

Summary: 0 packages finished [3.28s]
  1 package failed: system_data_recorder
  1 package had stderr output: system_data_recorder
MichaelOrlov commented 2 years ago

@gbiggs Can you please take a look on build failure from this report?

fyu-vs commented 2 years ago

I tried building SDR in ros2 rolling and have issues with bag events not being implemented.

I have run apt-update and apt-upgrade before updating ros2bag using sudo apt-get install ros-$CHOOSE_ROS_DISTRO-ros2bag ros-$CHOOSE_ROS_DISTRO-rosbag2* after setting the ROS distro version to rolling.

My build fails with the following:

veesai@dev ~/simulator $ colcon build --symlink-install --packages-select system_data_recorder
Starting >>> system_data_recorder
--- stderr: system_data_recorder
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp: In member function ‘virtual rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)’:
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp:98:16: error: ‘rosbag2_cpp::bag_events’ has not been declared
   98 |   rosbag2_cpp::bag_events::WriterEventCallbacks callbacks;
      |                ^~~~~~~~~~
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp:99:3: error: ‘callbacks’ was not declared in this scope
   99 |   callbacks.write_split_callback =
      |   ^~~~~~~~~
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp:101:19: error: ‘rosbag2_cpp::bag_events’ has not been declared
  101 |     (rosbag2_cpp::bag_events::WriteSplitInfo & info) {
      |                   ^~~~~~~~~~
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp: In lambda function:
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp:104:29: error: request for member ‘opened_file’ in ‘info’, which is of non-class type ‘int’
  104 |       last_bag_file_ = info.opened_file;
      |                             ^~~~~~~~~~~
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp:106:36: error: request for member ‘closed_file’ in ‘info’, which is of non-class type ‘int’
  106 |       notify_new_file_to_copy(info.closed_file);
      |                                    ^~~~~~~~~~~
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp: In member function ‘virtual rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn sdr::SystemDataRecorder::on_configure(const rclcpp_lifecycle::State&)’:
/home/veesai/simulator/src/system_data_recorder/src/sdr_component.cpp:108:12: error: ‘using element_type = class rosbag2_cpp::Writer’ {aka ‘class rosbag2_cpp::Writer’} has no member named ‘add_event_callbacks’
  108 |   writer_->add_event_callbacks(callbacks);
      |            ^~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/sdr_component.dir/build.make:63: CMakeFiles/sdr_component.dir/src/sdr_component.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:107: CMakeFiles/sdr_component.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
---
Failed   <<< system_data_recorder [3.27s, exited with code 2]

Summary: 0 packages finished [3.42s]
  1 package failed: system_data_recorder
  1 package had stderr output: system_data_recorder
MichaelOrlov commented 2 years ago

@fyu-vs bag events feature not yet present in rolling release. You will need to build rosbag2 from source.