【问题标题】:ROS1 catkin_make failed: catkin_install_python() called without required DESTINATION argumentROS1 catkin_make 失败:调用 catkin_install_python() 时不需要 DESTINATION 参数
【发布时间】:2019-06-28 06:02:07
【问题描述】:

我尝试将 python 脚本添加到我的包中,请参考这两个教程。

Handling of setup.py

Installing Python scripts and modules

所以我在根test\src\test_pkg 中添加了setup.py,在路径test\src 中更改了CMakeLists.txt。 (我的包根路径是test\,我的包路径是test\src\test_pkg,我的python脚本路径是test\src\test_pkg\scripts

这是 setup.py。

#!/usr/bin/env python
# -*- coding: utf-8 -*-


from distutils.core import setup
from catkin_pkg.python_setup import generate_distutils_setup


setup_args = generate_distutils_setup(
    packages=['test_pkg'],
    scripts=['/scripts'],
    package_dir={'': 'src'}
)

setup(**setup_args)

这是 CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(test_pkg)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  sensor_msgs
  message_generation
)

catkin_python_setup()

catkin_install_python(PROGRAMS scripts/talker
                      DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

add_message_files(
  FILES
  Num.msg
)

add_service_files(
  FILES
  AddTwoInts.srv
)

generate_messages(
  DEPENDENCIES
  std_msgs
  sensor_msgs
)

catkin_package(
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime sensor_msgs

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)

install(PROGRAMS 
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

然后我在路径test 中运行catkin_make。(我已经运行test\devel\setup.bat) 并得到了这个 CMake 错误:

Base path: E:\workspace\ros\test
Source space: E:\workspace\ros\test\src
Build space: E:\workspace\ros\test\build
Devel space: E:\workspace\ros\test\devel
Install space: E:\workspace\ros\test\install
####
#### Running command: "nmake cmake_check_build_system" in "E:\workspace\ros\test\build"
####

Microsoft (R) ?????????ù??? 14.20.27508.1 ??
??????? (C) Microsoft Corporation??  ?????????????

-- Using CATKIN_DEVEL_PREFIX: E:/workspace/ros/test/devel
-- Using CMAKE_PREFIX_PATH: E:/workspace/ros/test/devel;C:/opt/ros/melodic/x64;C:/opt/rosdeps/x64
-- This workspace overlays: E:/workspace/ros/test/devel;C:/opt/ros/melodic/x64
-- Using PYTHON_EXECUTABLE: C:/opt/python27amd64/python.exe
-- Using default Python package layout
-- Using empy: C:/opt/python27amd64/lib/site-packages/em.pyc
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: E:/workspace/ros/test/build/test_results
-- Found gtest: gtests will be built
-- Using Python nosetests: C:/opt/python27amd64/Scripts/nosetests-2.7.exe
-- catkin 0.7.14
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- Using CATKIN_WHITELIST_PACKAGES: test_pkg
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - test_pkg
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'test_pkg'
-- ==> add_subdirectory(test_pkg)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Error at C:/opt/ros/melodic/x64/share/catkin/cmake/catkin_install_python.cmake:20 (message):
  catkin_install_python() called without required DESTINATION argument.
Call Stack (most recent call first):
  test_pkg/CMakeLists.txt:27 (catkin_install_python)


-- Configuring incomplete, errors occurred!
See also "E:/workspace/ros/test/build/CMakeFiles/CMakeOutput.log".
See also "E:/workspace/ros/test/build/CMakeFiles/CMakeError.log".
NMAKE : fatal error U1077: ??C:\opt\rosdeps\x64\bin\cmake.exe??: ???????0x1??
Stop.
Invoking "nmake cmake_check_build_system" failed

如何解决这个错误?感谢您的回复。

系统:Windows10

ROS: ROS1

  • /rosdistro: 旋律
  • /rosversion: 1.14.3

【问题讨论】:

    标签: python windows cmake ros


    【解决方案1】:

    首先,虽然catkin 是一个足够通用的工具,但它通常用于机器人框架 ROS。因此,通过在 ROS 的问题社区answers.ros.org 提问,您可能会得到更多回复。

    CMake Error at C:/opt/ros/melodic/x64/share/catkin/cmake/catkin_install_python.cmake:20 (message):
      catkin_install_python() called without required DESTINATION argument.
    

    我认为您提到了正确的在线资源。我也看过他们,但他们都没有澄清这一点,但 catkin_package() 需要在 catkin_install_python 之前调用。

    【讨论】:

      【解决方案2】:

      正确的顺序是:

      cmake_minimum_required(VERSION 2.8.3)
      project(test_pkg)
      
      find_package(catkin REQUIRED COMPONENTS
        roscpp
        rospy
        std_msgs
        sensor_msgs
        message_generation
      )
      
      add_message_files(
        FILES
        Num.msg
      )
      
      add_service_files(
        FILES
        AddTwoInts.srv
      )
      
      generate_messages(
        DEPENDENCIES
        std_msgs
        sensor_msgs
      )
      
      catkin_package(
        CATKIN_DEPENDS roscpp rospy std_msgs message_runtime sensor_msgs
      
      include_directories(
      # include
        ${catkin_INCLUDE_DIRS}
      )
      
      #catkin_python_setup()
      catkin_install_python(PROGRAMS scripts/talker
                            DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
      )
      

      但是由于您删除了所有未使用的代码,因此我不确定上面是否正确。如果在原始文件中,应该在此处:

          ## Mark executable scripts (Python etc.) for installation
      ## in contrast to setup.py, you can choose the destination)
      #catkin_package()
      #catkin_python_setup()
      catkin_install_python(PROGRAMS scripts/talker.py scripts/listener.py
              DESTINATION   ${CATKIN_PACKAGE_BIN_DESTINATION}
      )
      

      几乎在文件末尾。

      【讨论】:

        【解决方案3】:

        我遇到了同样的错误。 我以为您将代码复制到错误的位置。 如果您将这些代码放在相对较早的位置,您可能会弄错。试着把代码放在这里。

        ## Mark executable scripts (Python etc.) for installation
        ## in contrast to setup.py, you can choose the destination)
        #catkin_package()
        #catkin_python_setup()
        catkin_install_python(PROGRAMS scripts/talker.py scripts/listener.py
                DESTINATION   ${CATKIN_PACKAGE_BIN_DESTINATION}
        )
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-03-14
          • 1970-01-01
          相关资源
          最近更新 更多