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

Give just the application ROS without the code (src)

asked 2022-04-27 09:50:50 -0600

mros gravatar image

updated 2022-04-27 09:52:46 -0600

Hi all, I am using ROS Noetic. I have 3 nodes communicating with each other, 2 in Python and one with C language (darknet_ROS). Now I want to give my application but without the code (src), i.e, just the executable. It is possible to do this with ROS?

Thank you

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2022-04-28 17:56:31 -0600

tfoote gravatar image

In c++ it's naturally separated into libraries that you can choose to install into the debian package. However by default python is installed in the script form for greater portability. And then some platforms will generate the pyc locally for optimization.

In python it is possible to distributed binary artifacts. You can use pyc distributions [1] there are pros and cons[2].

None of the standard ROS toolchains are setup to do that in the open source project we generally do not work to hide or suppress our source code. Note that these techniques will protect against things like decompiling your released code.

[1] https://stackoverflow.com/questions/3...

[2] https://www.curiousefficiency.org/pos...

edit flag offensive delete link more

Comments

Hi, thank you for your reply. I tried to use the pyc file instead py, but I got this error:

RuntimeError: Bad magic number in .pyc file

Is there any tutorial explains that, please?

mros gravatar image mros  ( 2022-05-02 19:07:55 -0600 )edit

A quick searchsuggests that you're using a different version of python on your separate targets. This is why most python is distributed in source format. You have all the binary compatibility problems with pyc files that you have with other compiled formats. You're getting outside of anything ROS related and are getting into general python issues which is going to be better resolved elsewhere.

tfoote gravatar image tfoote  ( 2022-05-02 19:11:33 -0600 )edit
0

answered 2022-04-27 10:10:53 -0600

Yes, of course. The easiest is to generate debian packages using bloom. Then users can simply install them on their computer as normal package. There are many informations about this in ROS wiki and industrial_ci supports also some pre-release checks which are good to do before you generate packages.

Here is an part of the script how we do this in a project using GH-Actions to automatically generate packages. The commands are actually bash-compatible, so you should be able to replicate things locally.

- name: Industial CI build
  uses: 'ros-industrial/industrial_ci@master'

- name: Install deployment dependencies  # other dependencies should be already installed by industrial_ci
  run: |
    sudo DEBIAN_FRONTEND=noninteractive apt -y install python3-catkin-tools fakeroot python3-argcomplete python3-bloom dh-make

- name: Generate DEBs
  env:
    PACKAGE_SOURCE_DIR: ${{ env.BASEDIR }}/target_ws/src/PACKAGE/
  run: |
    ls -al ${{ env.BASEDIR }}
    ls -al ${{ env.BASEDIR }}/target_ws/src/PACKAGE
    source ${{ env.BASEDIR }}/target_ws/install/setup.bash

    cd ${{ env.BASEDIR }}

    bloom-generate rosdebian --os-name ubuntu --os-version ${{ env.OS_CODE_NAME }} --ros-distro ${{ env.ROS_DISTRO }} ${{ env.PACKAGE_SOURCE_DIR }}
    mv debian ${{ env.PACKAGE_SOURCE_DIR }}
    cd ${{ env.PACKAGE_SOURCE_DIR }}
    echo "Building debian package"
    fakeroot debian/rules binary

    rm -r obj-x86_64-linux-gnu
    rm -r debian

    cd ${{ env.PACKAGE_SOURCE_DIR }}/..
    echo "All generated packages: "
    ls -al ros-${ROS_DISTRO}-*deb
    deb_name_original=`ls ros-${ROS_DISTRO}-*amd64.deb`
    deb_name="${deb_name_original:0:${#deb_name_original}-4}"
    deb_name="${deb_name}.deb"
    mv $deb_name_original $deb_name
    echo "Current generated deb is: $deb_name"
    ls -al ros-${ROS_DISTRO}-*deb

    # Install PACKAGE dependencies and test install the package
    sudo DEBIAN_FRONTEND=noninteractive apt -y install ./$deb_name
    sudo DEBIAN_FRONTEND=noninteractive apt --fix-broken -y install
    sudo DEBIAN_FRONTEND=noninteractive apt -y install ./$deb_name

    sudo apt remove -y ros-${ROS_DISTRO}-package
edit flag offensive delete link more

Comments

Hi,

Thank you for your reply. In fact, I used the following commands to generate the deb file:

$ bloom-generate rosdebian --os-name ubuntu --ros-distro noetic
$ fakeroot debian/rules binary

And after that, I install the deb package and it works. The problem is that I found the python script in /opt/ros/noetic/lib/ and I want to hide the code (src). So, how I can do this, please? i.e, hide the code (src) of my package ? Thank you.

mros gravatar image mros  ( 2022-04-28 06:38:43 -0600 )edit

AFAIK, You will find all the source code of ROS inside the /opt/ros/** atleast I see all the python code and the header files. What you can do is may be consider using c++ instead of python?

I do not know if it make sense but people will be lazy to readout/figureout the c++ code than python haha (Just kidding)

aarsh_t gravatar image aarsh_t  ( 2022-04-28 15:12:09 -0600 )edit

There is a python library called pyarmor which encrypts python files and packages. Although I am not sure how easy it is to apply it to ROS nodes, you can take a look at it here and give it a try: https://github.com/dashingsoft/pyarmor

rosberrypi gravatar image rosberrypi  ( 2022-04-29 02:50:51 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2022-04-27 09:50:50 -0600

Seen: 686 times

Last updated: Apr 28 '22