简体   繁体   English

如何为ROS软件包(脚本文件夹中的python代码)生成deb可安装文件?

[英]How can I generate deb installable file for my ROS package(python code in the script folder)?

How can I generate deb installable file from the python files in my package(in the script folder), so I can deliver the deb file to the client who can run the python executables in the package? 如何从包中(脚本文件夹中)的python文件生成deb可安装文件,以便将deb文件交付给可以在包中运行python可执行文件的客户端?

For example, I just completed the ROS tutorial and created the beginner_tutorials package in my catkin workspace. 例如,我刚刚完成ROS教程,并在我的catkin工作区中创建了beginner_tutorials包。 I also completed the Simple Publisher and Subscriber tutorials which mean the python talker.py and listener.py in the script folder in the beginner_tutorials package.Then I run the following command in the package folder,~/ROS/catkin_workspace/src/beginner_tutorials: 我还完成了Simple Publisher和Subscriber教程,这意味着在beginner_tutorials软件包的脚本文件夹中的python talker.py和listener.py。然后在软件包文件夹〜/ ROS / catkin_workspace / src / beginner_tutorials中运行以下命令:

$ bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic $ Bloom-generate rosdebian --os-name ubuntu --ros-distro动力学

$ fakeroot debian/rules binary $ fakeroot debian / rules二进制

So it generated the deb file. 因此,它生成了deb文件。 After I installed the deb to a new machine and I try to run the command: 在将deb安装到新计算机上之后,我尝试运行命令:

$ rosrun beginner_tutorials talker $ rosrun beginner_tutorials对话者

$ rosrun beginner_tutorials talker.py $ rosrun beginner_tutorials talker.py

$ rosrun beginner_tutorials listener $ rosrun beginner_tutorials侦听器

$ rosrun beginner_tutorials listener.py $ rosrun beginner_tutorials listener.py

After the installation on the new machine. 在新机器上安装后。 I can't run the talker and listener. 我无法运行说话者和听众。 There is no python file in the /opt/ros/kinetic/lib. / opt / ros / kinetic / lib中没有python文件。 but look inside of the deb file, there are python files in the /opt/ros/kinetic/lib folder. 但是在deb文件的内部,/ opt / ros / kinetic / lib文件夹中有python文件。 I don't know where the python file went after install the deb file. 安装deb文件后,我不知道python文件在哪里。 I was wondering how can I export the package with python script to a installable deb file and after I install the deb file on a new machine, I can run the python executable file on the new machine? 我想知道如何将带有python脚本的软件包导出到可安装的deb文件,并且在将deb文件安装到新计算机上之后,可以在新计算机上运行python可执行文件吗?

If someone can give me some hints or guidance, I would really appreciate it. 如果有人可以给我一些提示或指导,我将不胜感激。 Thank you in advance! 先感谢您!

Jue Wang(Patrick) 王(帕特里克)

You may just use CPack with following options: 您可以将CPack与以下选项一起使用:

(Package-wide CMakeLists.txt file) (程序包范围的CMakeLists.txt文件)

#############
## Install ##
#############

set(CPACK_GENERATOR "DEB")

#Creating UNIX structured package
set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../..")
set(CPACK_PACKAGE_VERSION 0.2.9)

#Set directory to /../ to avoid /share part of ROS_PACKAGE_PATH
set(CPACK_PACKAGING_INSTALL_PREFIX "$ENV{ROS_PACKAGE_PATH}/../")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${PROJECT_NAME};ALL;/./")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
    "${PROJECT_NAME} - ${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VENDOR "RCS")

#Now we can simply create the dependencies using almost the same package names as they declared in ROS repository
set(CPACK_DEBIAN_PACKAGE_DEPENDS "ros-kinetic-roscpp, ros-kinetic-std-msgs, ros-kinetic-message-runtime, ros-kinetic-sensor-msgs")

#IMPORTANT: set this to keep on auto-introspection for system dependencies like libc++6
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)

#Keep Debian package structure untouched
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)

#Standard naming schema for Debian-based distros
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}~${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_PACKAGE_VENDOR "Technical University")
set(CPACK_PACKAGE_CONTACT "<your@email.com>")

#Turn the process on    
include(CPack)

In case of simple catkin package structure you can simply uncomment and edit install sections of your CMakeLists.txt according to files your package required to install. 如果使用简单的catkin软件包结构,则可以根据安装所需软件包的文件来取消注释和编辑CMakeLists.txt install部分。 Then run 然后跑

catkin_make package

After that you will have the .deb package archive in the root directory of your ROS package. 之后,您将在ROS软件包的根目录中拥有.deb软件包档案。 Now you can use dpkg-deb -c command to ensure the paths defined within the package are correct. 现在,您可以使用dpkg-deb -c命令来确保软件包中定义的路径正确。 To obtain the example download and examine any ROS package from the official binaries repository. 要获取示例下载,并从官方二进制存储库中检查任何ROS软件包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM