首页 > 解决方案 > velodyne 驱动程序上的 Catkin_make 在 Windows 10 环境中失败

问题描述

我正在尝试在 Windows 中安装 ROS-Velodyne 驱动程序(https://github.com/ros-drivers/velodyne)以从 velodyne LiDAR 捕获点云,但在运行 catkin_make 时出错。

由于这些驱动程序需要 pcap 库,我在我的系统中安装了 WinPcap 并更新了 velodyne 驱动程序的 cmake 以找到所需的头文件并链接库。但是在运行 cmake 时,我在“target_link_libraries”上遇到错误(如图所示)

无法为此项目构建的目标“velodyne_driver”指定链接库

在此处输入图像描述

以下是 velodyne_driver 包的 cmake 文件:

cmake_minimum_required(VERSION 2.8.3)
project(velodyne_driver)

# Set minimum C++ standard to C++11
if (NOT "${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}")
  message(STATUS "Changing CXX_STANDARD from C++98 to C++11")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif ("${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}" STREQUAL "98")
  message(STATUS "Changing CXX_STANDARD from C++98 to C++11")
  set(CMAKE_CXX_STANDARD 11)
endif()

set(${PROJECT_NAME}_CATKIN_DEPS 
    diagnostic_updater
    dynamic_reconfigure
    nodelet
    roscpp
    tf
    velodyne_msgs)

find_package(catkin REQUIRED COMPONENTS ${${PROJECT_NAME}_CATKIN_DEPS} roslint)

# This driver uses Boost threads
find_package(Boost REQUIRED COMPONENTS thread)

# kinger: libpcap provides no pkg-config or find_package module:
#message (STATUS "****** Starting PCAP Search in folder:  ********")
set( PCAP_DIR "C:/workspace/WpdPack" )
#message (STATUS ${PCAP_DIR})
#kinger: Include file FindPCAP.cmake
include(FindPCAP.cmake)
#find_package( PCAP REQUIRED )
message (STATUS "******* FIND PCAP TASK FINISHED **********")
message (STATUS ${PCAP_FOUND})
message (STATUS ${PCAP_INCLUDE_DIRS})
message (STATUS ${PCAP_LIBRARY_DIRS})
message (STATUS ${PCAP_LIBRARIES})

#set(libpcap_LIBRARIES -lpcap)
if(PCAP_FOUND)
  # Include Directories
  include_directories( ${PCAP_INCLUDE_DIRS} )
  # Library Directories (Option)
  link_directories( ${PCAP_LIBRARY_DIRS} )

  # Dependencies
  target_link_libraries( ${PROJECT_NAME} ${PCAP_LIBRARIES} )
endif()

include_directories(include ${Boost_INCLUDE_DIR} ${catkin_INCLUDE_DIRS})

# Generate dynamic_reconfigure server
generate_dynamic_reconfigure_options(cfg/VelodyneNode.cfg)

# objects needed by other ROS packages that depend on this one
catkin_package(CATKIN_DEPENDS ${${PROJECT_NAME}_CATKIN_DEPS}
               INCLUDE_DIRS include
               LIBRARIES velodyne_input)

# compile the driver and input library
add_subdirectory(src/lib)
add_subdirectory(src/driver)

install(DIRECTORY include/${PROJECT_NAME}/
        DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
install(FILES nodelet_velodyne.xml
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})
install(DIRECTORY launch/
        DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
install(PROGRAMS src/vdump
        DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

roslint_cpp()

if (CATKIN_ENABLE_TESTING)

  # these dependencies are only needed for unit testing
  find_package(roslaunch REQUIRED)
  find_package(rostest REQUIRED)

  # Download packet capture (PCAP) files containing test data.
  # Store them in devel-space, so rostest can easily find them.
  catkin_download_test_data(
    ${PROJECT_NAME}_tests_class.pcap
    http://download.ros.org/data/velodyne/class.pcap
    DESTINATION ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/tests
    MD5 65808d25772101358a3719b451b3d015)
  catkin_download_test_data(
    ${PROJECT_NAME}_tests_32e.pcap
    http://download.ros.org/data/velodyne/32e.pcap
    DESTINATION ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/tests
    MD5 e41d02aac34f0967c03a5597e1d554a9)
  catkin_download_test_data(
    ${PROJECT_NAME}_tests_vlp16.pcap
    http://download.ros.org/data/velodyne/vlp16.pcap
    DESTINATION ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/tests
    MD5 f45c2bb1d7ee358274e423ea3b66fd73)
  
  # unit tests
  add_rostest(tests/pcap_node_hertz.test)
  add_rostest(tests/pcap_nodelet_hertz.test)
  add_rostest(tests/pcap_32e_node_hertz.test)
  add_rostest(tests/pcap_32e_nodelet_hertz.test)
  add_rostest(tests/pcap_vlp16_node_hertz.test)
  add_rostest(tests/pcap_vlp16_nodelet_hertz.test)
  
  # parse check all the launch/*.launch files
  roslaunch_add_file_check(launch)

  # unit test
  catkin_add_gtest(time_test tests/timeconversiontest.cpp)
  target_link_libraries(time_test
    ${catkin_LIBRARIES}
    ${Boost_LIBRARIES}
    ${PCAP_LIBRARIES})
endif (CATKIN_ENABLE_TESTING)

更新:解决了上述问题。它与我们需要提供“目标”而不是“项目”的 target_link_libraries 相关。我通过添加以下行更新了 cmake:

set(libpcap_LIBRARIES ${PCAP_LIBRARIES})

现在,构建在 59% 时失败,并出现以下错误:

C:\opt\ros\noetic\x64\include\diagnostic_updater/update_functions.h(188): error C2589: 'constant': illegal token on right side of '::'

看起来这是一个未解决的问题:https ://github.com/ms-iot/ROSOnWindows/issues/280

标签: windowslinker-errorsroslidarcatkin

解决方案


很高兴看到您在 Windows 上使用 ROS!我很想知道更多关于你的项目。我们(Azure Edge Robotics,在 Windows 上维护 ROS)目前没有 Velodyne 激光雷达,因此没有尝试移植它。

看起来 Velodyne Lidar ROS 节点尚未在 Windows 上启用。看起来 cmake 文件中有几个特定于 linux 的命令需要 windows 等效命令。

我们在这里有一个 Windows 移植指南 - https://ms-iot.github.io/ROSOnWindows/GettingStarted/PortingANode.html

它有一个可以在端口中使用的 winpcap vcpkg: https ://github.com/microsoft/vcpkg/tree/master/ports/winpcap

我在 ROSonWindows github 上创建了这个来跟踪: Catkin_make on the velodyne drivers failed in the windows 10 environemnt


推荐阅读