SteveMacenski / spatio_temporal_voxel_layer

A new voxel layer leveraging modern 3D graphics tools to modernize navigation environmental representations
http://wiki.ros.org/spatio_temporal_voxel_layer
GNU Lesser General Public License v2.1
616 stars 183 forks source link

openvdb_vendor package to fix humble and iron compilation #281

Closed Timple closed 6 months ago

Timple commented 7 months ago

Replaces #267, closes #232

I took a swing at it as we would like to use this package pre-compiled in ROS Iron :slightly_smiling_face:

@nachovizzo: I cherry-picked your commits as those where most of the work here. I simply moved around some files to split them into two packages.

The only difference in the cmake files is this: https://github.com/SteveMacenski/spatio_temporal_voxel_layer/pull/281/files#diff-1db6bbb2d6230bd2efa7c049f4b0ff23f34192c8a8de7ef5e734e0d11b7e4af7R66-R69

nachovizzo commented 7 months ago

@Timple thanks for taking the lead! I was honestly not finding the time to build openvdb and test that everything was working after this move. Thanks thanks!!!

SteveMacenski commented 7 months ago

How did you test this @Timple? Also, @nachovizzo did you test this as well to make sure its OK as a third party?

This doesn't seem to follow the guide (https://github.com/ros2/ros2_documentation/pull/3759/files) or example (https://github.com/mjcarroll/ogre_next_vendor/blob/0e73c5e3cbb3098e9cef1c900bc79e918371c133/CMakeLists.txt#L7-L26). Not to say that anything's wrong with it, but following standard practices can make things easier on us all in the long-run

Timple commented 7 months ago

Since compilation was the issue, I verified compilation :). And additionaly loading it. We will only be able to do some integration tests with actual data in a few weeks from now.

Since the PR of @nachovizzo sounded like it was good to go: I sticked to only moving files around. However, if we can get the _vendor implementation as clean as this, I would be very much in favor. The less delta the better. I will give this another go.

Timple commented 7 months ago

So I was unaware of this doc: https://github.com/ros2/ros2_documentation/pull/3759/files

But great starting point. I started from scratch and got the same results with much less lines. Still untested with actual data. Perhaps @nachovizzo beats me to it, otherwise I'll report back once done.

agoeckner commented 7 months ago

Thank you so much @Timple and @nachovizzo! This is a huge help for us.

jmm-slamcore commented 7 months ago

I'm getting the following error after installing ros-iron-ament-cmake-vendor-package, building this branch with colcon build and trying to run with the STVL costmap layer

Original error: Failed to load library /home/jorge/ros_ws/spatio_temporal_voxel_layer/lib/libspatio_temporal_voxel_layer_core.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML.
Error string: Could not load library dlopen error: /home/jorge/ros_ws/install/spatio_temporal_voxel_layer/lib/libspatio_temporal_voxel_layer_core.so: undefined symbol: _ZN7openvdb5v10_04math8internal4half5_eLutE, at ./src/shared_library.c:99

My nav2 params yaml has:

      stvl_layer:
        plugin: "spatio_temporal_voxel_layer/SpatioTemporalVoxelLayer"
        enabled: true
        [... rest of parameters]
agoeckner commented 6 months ago

Hey guys! What remains for this?

Timple commented 6 months ago

I totally overlooked the issues about linking. Due to lots of DDS issues, I still haven't gotten around to actually testing this.

Did anyone make any progress on the linking? Otherwise I'll dive into it when I run into it within the next few weeks somewhere.

SteveMacenski commented 6 months ago

@Timple @agoeckner the linking I believe is the last bit (and then testing it still works; run it for 10 minutes)

ashwinvkNV commented 6 months ago

@SteveMacenski @Timple We are looking forward to getting this PR through to enable spatio_temporal_voxel_layer in Jammy and Humble.

I'm planning to test this on a Nova Carter this week.

SteveMacenski commented 6 months ago

Show the linking works (or fix) and that you can run it and I can merge this :-)

Rayman commented 6 months ago

I fixed the build on iron. To do this I had to:

SteveMacenski commented 6 months ago

@ashwinvkNV want to give it a whirl now and see that it works?

ashwinvkNV commented 6 months ago

@SteveMacenski we were able to successfully verify this PR.

Before(commit hash: a395a569de365c58a0fc0e97fbd915b874f1193a) @Rayman 's fix today I was getting the undefined symbol: _ZN7openvdb5v10_04math8internal4half5_eLutE, at ./src/shared_library.c:99 error.

But after the fix(commit hash: 4aaf65327a31624702ae57c0e837b30168d92781), the error is gone. The spatio_temporal_voxel_layer populates the costmap and the robot avoids obstacles as expected.

Attached below is a screenshot of the local_costmap which is updated by spatio_temporal_voxel_layer image

Timple commented 6 months ago

Awesome! Thanks @Rayman

SteveMacenski commented 6 months ago

image

SimonGiampy commented 6 months ago

I'm getting the following error after installing ros-iron-ament-cmake-vendor-package, building this branch with colcon build and trying to run with the STVL costmap layer

Original error: Failed to load library /home/jorge/ros_ws/spatio_temporal_voxel_layer/lib/libspatio_temporal_voxel_layer_core.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML.
Error string: Could not load library dlopen error: /home/jorge/ros_ws/install/spatio_temporal_voxel_layer/lib/libspatio_temporal_voxel_layer_core.so: undefined symbol: _ZN7openvdb5v10_04math8internal4half5_eLutE, at ./src/shared_library.c:99

My nav2 params yaml has:

      stvl_layer:
        plugin: "spatio_temporal_voxel_layer/SpatioTemporalVoxelLayer"
        enabled: true
        [... rest of parameters]

Hi, I tested the code after this pull request was merged, but I got a similar error to @jmm-slamcore . I applied the STVL layer to the local costmap, but fails to load it due to a linking error. Compilation of the packages openvdb_vendor and spatio_temporal_voxel_layer completed successfully.

This is the error I got:

[component_container_isolated-1] [INFO] [1709801044.633225026] [local_costmap.local_costmap]: Configuring
[component_container_isolated-1] [INFO] [1709801044.637609308] [local_costmap.local_costmap]: Using plugin "spatio_temporal_voxel_layer"
[component_container_isolated-1] [ERROR] [1709801044.639278119] [local_costmap.local_costmap]: Caught exception in callback for transition 10
[component_container_isolated-1] [ERROR] [1709801044.639353356] [local_costmap.local_costmap]: Original error: Failed to load library /home/airlab/simon/scout_nav2/install/spatio_temporal_voxel_layer/lib/libspatio_temporal_voxel_layer_core.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library dlopen error: libopenvdb.so.11.0: cannot open shared object file: No such file or directory, at ./src/shared_library.c:99
[component_container_isolated-1] [WARN] [1709801044.639397920] [local_costmap.local_costmap]: Error occurred while doing error handling.
[component_container_isolated-1] [FATAL] [1709801044.639415252] [local_costmap.local_costmap]: Lifecycle node local_costmap does not have error state implemented

I believe there is something missing in the cmake files but I don't know how to fix this and if this can be fixed.

The parameters I used inside the local_costmap:

 plugins: ["spatio_temporal_voxel_layer", "denoise_layer", "inflation_layer"]

            spatio_temporal_voxel_layer:
                plugin: "spatio_temporal_voxel_layer/SpatioTemporalVoxelLayer"
                enabled: true

Can I also suggest to update the readme to include the installation and compiling instructions, to make it more clear how to compile the packages? Also to mention that is necessary to install ros-iron-ament-cmake-vendor-package.

Rayman commented 6 months ago

@SimonGiampy which ros version are you using? Which OS? Which commit hash did you compile? I suspect either you are not on the latest ros2 branch or there are some compilation artefacts which you could solve by cleaning your build and install folder.

SimonGiampy commented 6 months ago

@SimonGiampy which ros version are you using? Which OS? Which commit hash did you compile? I suspect either you are not on the latest ros2 branch or there are some compilation artefacts which you could solve by cleaning your build and install folder.

I'm running ROS2 Iron (latest binary build to date) on Ubuntu 22.04. I downloaded the latest ros2 branch build of this repository and did a clean build with colcon. I'm referring to the latest commit with hash 403d9ed769e78beec4c6ec437a1143943e2a4630. I was following the issue #281 because I couldn't compile the repository on ROS2 Iron. The error message is the one I mentioned above.

I'll also include the output from the compilation of the 2 new packages.

[Processing: openvdb_vendor]                                        
Finished <<< openvdb_vendor [7min 32s]                              
Starting >>> spatio_temporal_voxel_layer
--- stderr: spatio_temporal_voxel_layer                                     
COMPONENT = openvdb
CMake Warning (dev) at /opt/ros/iron/share/ament_cmake_ros/cmake/build_shared_libs.cmake:15 (option):
  Policy CMP0077 is not set: option() honors normal variables.  Run "cmake
  --help-policy CMP0077" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  For compatibility with older versions of CMake, option is clearing the
  normal variable 'BUILD_SHARED_LIBS'.
Call Stack (most recent call first):
  /opt/ros/iron/share/ament_cmake_ros/cmake/ament_cmake_ros-extras.cmake:24 (include)
  /opt/ros/iron/share/ament_cmake_ros/cmake/ament_cmake_rosConfig.cmake:41 (include)
  /opt/ros/iron/share/rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_c_generate_interfaces.cmake:21 (find_package)
  /opt/ros/iron/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
  /opt/ros/iron/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:316 (ament_execute_extensions)
  CMakeLists.txt:81 (rosidl_generate_interfaces)
This warning is for project developers.  Use -Wno-dev to suppress it.

/home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/src/spatio_temporal_voxel_layer.cpp: In member function ‘virtual void spatio_temporal_voxel_layer::SpatioTemporalVoxelLayer::onInitialize()’:
/home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/src/spatio_temporal_voxel_layer.cpp:154:81: warning: ‘typename rclcpp::Service<ServiceT>::SharedPtr rclcpp_lifecycle::LifecycleNode::create_service(const string&, CallbackT&&, const rmw_qos_profile_t&, rclcpp::CallbackGroup::SharedPtr) [with ServiceT = spatio_temporal_voxel_layer::srv::SaveGrid; CallbackT = std::_Bind<void (spatio_temporal_voxel_layer::SpatioTemporalVoxelLayer::*(spatio_temporal_voxel_layer::SpatioTemporalVoxelLayer*, std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(std::shared_ptr<rmw_request_id_s>, std::shared_ptr<spatio_temporal_voxel_layer::srv::SaveGrid_Request_<std::allocator<void> > >, std::shared_ptr<spatio_temporal_voxel_layer::srv::SaveGrid_Response_<std::allocator<void> > >)>&; typename rclcpp::Service<ServiceT>::SharedPtr = std::shared_ptr<rclcpp::Service<spatio_temporal_voxel_layer::srv::SaveGrid> >; std::string = std::__cxx11::basic_string<char>; rmw_qos_profile_t = rmw_qos_profile_s; rclcpp::CallbackGroup::SharedPtr = std::shared_ptr<rclcpp::CallbackGroup>]’ is deprecated: use rclcpp::QoS instead of rmw_qos_profile_t [-Wdeprecated-declarations]
  154 |   _grid_saver = node->create_service<spatio_temporal_voxel_layer::srv::SaveGrid>(
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  155 |     "save_grid", save_grid_callback, rmw_qos_profile_services_default, callback_group_);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/ros/iron/include/rclcpp_lifecycle/rclcpp_lifecycle/lifecycle_node.hpp:1109,
                 from /home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/include/spatio_temporal_voxel_layer/spatio_temporal_voxel_grid.hpp:58,
                 from /home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/include/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer.hpp:54,
                 from /home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/src/spatio_temporal_voxel_layer.cpp:45:
/opt/ros/iron/include/rclcpp_lifecycle/rclcpp_lifecycle/lifecycle_node_impl.hpp:149:1: note: declared here
  149 | LifecycleNode::create_service(
      | ^~~~~~~~~~~~~
/home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/src/spatio_temporal_voxel_layer.cpp:342:63: warning: ‘typename rclcpp::Service<ServiceT>::SharedPtr rclcpp_lifecycle::LifecycleNode::create_service(const string&, CallbackT&&, const rmw_qos_profile_t&, rclcpp::CallbackGroup::SharedPtr) [with ServiceT = std_srvs::srv::SetBool; CallbackT = std::function<void(std::shared_ptr<rmw_request_id_s>, std::shared_ptr<std_srvs::srv::SetBool_Request_<std::allocator<void> > >, std::shared_ptr<std_srvs::srv::SetBool_Response_<std::allocator<void> > >)>&; typename rclcpp::Service<ServiceT>::SharedPtr = std::shared_ptr<rclcpp::Service<std_srvs::srv::SetBool> >; std::string = std::__cxx11::basic_string<char>; rmw_qos_profile_t = rmw_qos_profile_s; rclcpp::CallbackGroup::SharedPtr = std::shared_ptr<rclcpp::CallbackGroup>]’ is deprecated: use rclcpp::QoS instead of rmw_qos_profile_t [-Wdeprecated-declarations]
  342 |     auto server = node->create_service<std_srvs::srv::SetBool>(
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
  343 |       toggle_topic, toggle_srv_callback, rmw_qos_profile_services_default, callback_group_);
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/ros/iron/include/rclcpp_lifecycle/rclcpp_lifecycle/lifecycle_node.hpp:1109,
                 from /home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/include/spatio_temporal_voxel_layer/spatio_temporal_voxel_grid.hpp:58,
                 from /home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/include/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer.hpp:54,
                 from /home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/src/spatio_temporal_voxel_layer.cpp:45:
/opt/ros/iron/include/rclcpp_lifecycle/rclcpp_lifecycle/lifecycle_node_impl.hpp:149:1: note: declared here
  149 | LifecycleNode::create_service(
      | ^~~~~~~~~~~~~
/home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/src/spatio_temporal_voxel_grid.cpp: In member function ‘void volume_grid::SpatioTemporalVoxelGrid::ResetGridArea(const volume_grid::occupany_cell&, const volume_grid::occupany_cell&, bool)’:
/home/airlab/simon/scout_nav2/src/spatio_temporal_voxel_layer/spatio_temporal_voxel_layer/src/spatio_temporal_voxel_grid.cpp:404:8: warning: statement has no effect [-Wunused-value]
  404 |   for (cit_grid; cit_grid.test(); ++cit_grid)
      |        ^~~~~~~~
---
Finished <<< spatio_temporal_voxel_layer [25.6s]
mbharatheesha commented 6 months ago

@SimonGiampy I am slightly concerned by this line in your error message:

[component_container_isolated-1] [ERROR] [1709801044.639353356] [local_costmap.local_costmap]: Original error: Failed to load library /home/airlab/simon/scout_nav2/install/spatio_temporal_voxel_layer/lib/libspatio_temporal_voxel_layer_core.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library dlopen error: libopenvdb.so.11.0: cannot open shared object file: No such file or directory, at ./src/shared_library.c:99

Specifically the version of libopenvdb that is listed as 11.0. Can you confirm what is the version of libopenvdb in your install space by running: ls <path_to_your_install_space>/openvdb_vendor/opt/openvdb_vendor/lib?

On my system, the version is libopenvdb.so.10.0.1 which aligns exactly with the VCS version mentioned in the openvdb_vendor package's CMakeLists.txt on the latest ros2 branch.

So, it is unclear why your setup is trying to look for libopenvdb.so.11.0.

SimonGiampy commented 6 months ago

@SimonGiampy I am slightly concerned by this line in your error message:

[component_container_isolated-1] [ERROR] [1709801044.639353356] [local_costmap.local_costmap]: Original error: Failed to load library /home/airlab/simon/scout_nav2/install/spatio_temporal_voxel_layer/lib/libspatio_temporal_voxel_layer_core.so. Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in the library code, and that names are consistent between this macro and your XML. Error string: Could not load library dlopen error: libopenvdb.so.11.0: cannot open shared object file: No such file or directory, at ./src/shared_library.c:99

Specifically the version of libopenvdb that is listed as 11.0. Can you confirm what is the version of libopenvdb in your install space by running: ls <path_to_your_install_space>/openvdb_vendor/opt/openvdb_vendor/lib?

On my system, the version is libopenvdb.so.10.0.1 which aligns exactly with the VCS version mentioned in the openvdb_vendor package's CMakeLists.txt on the latest ros2 branch.

So, it is unclear why your setup is trying to look for libopenvdb.so.11.0.

Thank you @mbharatheesha , you helped me understand the cause of the error, and I managed to solve it!.

It was my fault. The error was indeed caused by the code trying to find openvdb version 11.0 instead of 10.0. This was because on my machine I previously installed libopenvdb-dev when I was trying to compile the repository before I found the issue #281. In fact, I gave up trying to compile the repository by installing several packages when I found out there was this issue where some people were already aware of the problem and trying to fix it. Then I waited for the fix which was finally merged yesterday. So basically I solved the problem by simply uninstalling the version of openvdb that I had already installed, and then the code worked fine. Removing the existing version of openvdb (which was newer than the one used in this repository) was the fix required to solve my problem. Thanks again!