ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How can I generate deb installable file from the python files in my ROS package(script folder), so I can deliver the deb file to the client who can install deb file and run the python executables on their machine?

asked 2017-08-03 04:18:15 -0500

freeleons gravatar image

updated 2017-08-08 04:37:43 -0500

Hello Everyone,

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?

For example, I just completed the ROS tutorial and created the beginner_tutorials package in my catkin workspace. 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:

$ bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic

$ fakeroot debian/rules binary

So it generated the deb file. After I installed the deb to a new machine and I try to run the command:

$ rosrun beginner_tutorials talker

$ rosrun beginner_tutorials talker.py

$ rosrun beginner_tutorials listener

$ 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. but look inside of the deb file, there are python files in the /opt/ros/kinetic/lib folder. I don't know where the python file went after install the deb file. 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?

If someone can give me some hints or guidance, I would really appreciate it. Thanks in advance!

Patrick

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-09-08 13:51:48 -0500

freeleons gravatar image

updated 2017-09-08 13:54:54 -0500

I wrote this document in word format and copy pasted here. If you want to see the prettier formated document or discuss about the topic shoot me an email at: freeleons at qq.com

Section 1, Package beginner_tutorial into Debian File This tutorial assumes you have already created the ros beginner_tutorial package by following the ROS beginner tutorial(http://wiki.ros.org/ROS/Tutorials). You can also refer to the zipped package files which is beginner_tutorials.tar.gz and beginner_tutorials_cpp.tar.gz, and experiment with it. Install Python files using deb In the beginner_tutorials ROS package folder, the tree structure of the folder is as following:

To add the python source code files to the deb, you need to add following lines to the CMakeLists.txt: FILE(GLOB openag_script_files "${CMAKE_CURRENT_SOURCE_DIR}/script/.") FILE(GLOB openag_subdirectory_script_files "${CMAKE_CURRENT_SOURCE_DIR}/script/srv/.")

catkin_install_python(PROGRAMS ${openag_script_files} DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

catkin_install_python(PROGRAMS ${openag_subdirectory_script_files} DESTINATION "${CATKIN_PACKAGE_BIN_DESTINATION}/srv")

If you don’t add the code above to the CMakeLists.txt file, your deb file do not contain the python executable files. After install the deb, the python executable files will NOT be installed on your machine. Another alternative way of install python script files in the deb file, it is writing following macros. It has the same effect as catkin_install_python: install(PROGRAMS script/listener.py script/talker.py script/add_two_ints_client.py script/add_two_ints_server.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} )

install(PROGRAMS script/srv/_AddTwoInts.py script/srv/__init__.py DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/srv )

The following code block which should be placed in the CMakeLists.txt will add launch folder and launch file in the deb installable file: install(DIRECTORY launch/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch PATTERN ".svn" EXCLUDE)

Then run the following command in the package folder to generate Debian source folder, my case is ~/ROS/catkin_workspace/src/beginner_tutorials: $ bloom-generate rosdebian --os-name ubuntu --ros-distro kinetic

It creates Debian folder in the package folder. Then run the following command in the package folder to generate deb file: $ fakeroot debian/rules binary

It generates the deb file, ros-kinetic-beginner-tutorials_0.1.0-0xenial_amd64.deb, in the src folder. Then you can give deb to someone to install it. Install C++ files using deb In the beginner_tutorials_cpp ROS package folder, the tree structure of the folder is as following:

To add build target/executable files using catkin_make, you need to add the following line to the CMakeLists.txt: add_executable(talker src/talker.cpp) target_link_libraries(talker ${catkin_LIBRARIES}) add_dependencies(talker beginner_tutorials_generate_messages_cpp)

add_executable(listener src/listener.cpp) target_link_libraries(listener ${catkin_LIBRARIES}) add_dependencies(listener beginner_tutorials_generate_messages_cpp)

add_executable(add_two_ints_server src/add_two_ints_server.cpp) target_link_libraries(add_two_ints_server ${catkin_LIBRARIES}) add_dependencies(add_two_ints_server beginner_tutorials_gencpp)

add_executable(add_two_ints_client src/add_two_ints_client.cpp) target_link_libraries(add_two_ints_client ${catkin_LIBRARIES}) add_dependencies(add_two_ints_client beginner_tutorials_gencpp)

To add executables to the deb file, you need add following lines to the CMakeLists.txt: install(TARGETS talker listener add_two_ints_server add_two_ints_client RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

If you don’t add the code above to the CMakeLists.txt file, your deb file do not contain the C++ executable files. After install the deb, the C++ executable files will NOT be installed on your machine. Then run the following command in the ... (more)

edit flag offensive delete link more

Comments

Please use the 101010 button to format your code.

jayess gravatar image jayess  ( 2017-09-08 17:46:57 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2017-08-03 04:18:15 -0500

Seen: 612 times

Last updated: Sep 08 '17