Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues bulding own package when including pcl_ros / does not find libstatistics_collector libraries #362

Open
floriankittelmann opened this issue Apr 13, 2022 · 0 comments

Comments

@floriankittelmann
Copy link

I am using ros2 - foxy and want to build a colcon package written in C++, which includes the pcl_ros library. But somehow it can not find the libstatistics_collector libraries. For debugging reasons I just included the basics libraries to find the root cause of the problem.

The basic ROS2 node:

#include "rclcpp/rclcpp.hpp"
#include <sensor_msgs/msg/point_cloud2.hpp>

class LidarPerceptionNode : public rclcpp::Node
{
    public:
        LidarPerceptionNode() : Node("lidar_perception_node")
        {
            // Does nothing
        }

    private:
        void topic_callback(const sensor_msgs::msg::PointCloud2::SharedPtr msg) const
        {
             // Does nothing
        }
};

int main(int argc, char ** argv)
{
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<LidarPerceptionNode>());
    rclcpp::shutdown();
    return 0;
}

The package.xml file:

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
  <name>fs_zhaw_lidar_perception</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="[email protected]">florian</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <exec_depend>velodyne</exec_depend>
  <exec_depend>pcl_ros</exec_depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

My CMakeLists.txt

cmake_minimum_required(VERSION 3.5)
project(fs_zhaw_lidar_perception)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(PCL 1.8 REQUIRED)
find_package(pcl_ros REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})

add_executable(lidar_perception_node src/lidar_perception_node.cpp)
target_include_directories(lidar_perception_node PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)

ament_target_dependencies(lidar_perception_node "rclcpp" "pcl_ros")

install(TARGETS lidar_perception_node
  DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()

When I try to build it the package, I get an error msg:

CMake Error at CMakeLists.txt:26 (add_executable):
  Target "lidar_perception_node" links to target
  "libstatistics_collector::libstatistics_collector_test_msgs__rosidl_generator_c"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:26 (add_executable):
  Target "lidar_perception_node" links to target
  "libstatistics_collector::libstatistics_collector_test_msgs__rosidl_typesupport_introspection_c"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:26 (add_executable):
  Target "lidar_perception_node" links to target
  "libstatistics_collector::libstatistics_collector_test_msgs__rosidl_typesupport_c"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:26 (add_executable):
  Target "lidar_perception_node" links to target
  "libstatistics_collector::libstatistics_collector_test_msgs__rosidl_generator_cpp"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:26 (add_executable):
  Target "lidar_perception_node" links to target
  "libstatistics_collector::libstatistics_collector_test_msgs__rosidl_typesupport_introspection_cpp"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:26 (add_executable):
  Target "lidar_perception_node" links to target
  "libstatistics_collector::libstatistics_collector_test_msgs__rosidl_typesupport_cpp"
  but the target was not found.  Perhaps a find_package() call is missing for
  an IMPORTED target, or an ALIAS target is missing?


CMake Warning at CMakeLists.txt:26 (add_executable):
  Cannot generate a safe runtime search path for target lidar_perception_node
  because there is a cycle in the constraint graph:

    dir 0 is [/opt/ros/foxy/lib]
      dir 1 must precede it due to runtime library [liborocos-kdl.so.1.4]
    dir 1 is [/home/florian/ros2_foxy/ros2-linux/lib]
      dir 0 must precede it due to runtime library [libmessage_filters.so]

  Some of these libraries may not be found correctly.


CMake Generate step failed.  Build files cannot be regenerated correctly.
make: *** [Makefile:266: cmake_check_build_system] Error 1
---
Failed   <<< fs_zhaw_lidar_perception [1.94s, exited with code 2]

I usually source foxy and build my packages like this:

source /opt/ros/foxy/setup.bash
. ~/ros2_foxy/ros2-linux/setup.bash
cd ~/colcon_ws
rosdep install --from-paths src --ignore-src -r -y --rosdistro foxy
colcon build --symlink-install
. install/local_setup.bash

When I remove the pcl_ros from the ament_target_dependencies() in the CMakeLists.txt, it compiles without any error. Do I source my foxy distribution wrongly or is there somewhere a bug?

Thanks in advance for the help!

@floriankittelmann floriankittelmann changed the title Issues bulding own package when including pcl_ros / does not find Issues bulding own package when including pcl_ros / does not find libstatistics_collector libraries Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant