How to import msg file by using executable file?

asked 2019-12-23 23:51:44 -0500

MengWei gravatar image

Does ROS system offer any methods to hide the source code?

Because I receive a requirement to hide my ROS code.

Thus, I choose pyinstaller to make .py file into the executable file

After finishing the compile by command: pyinstaller -F mycode.py

Then, using launch file to launch the executable file

But it shows up a ImportError: cannot import name motorCmd (where "motorCmd" is a self-defined msg file I make)

I have tried the following method and still cannot resolve the problem:

  1. Put msg file with the executable file at the same path (ie: "dist" dir, which is auto-generated by pyinstaller).
  2. Make a hook-file under the pyinstaller hooks dir as following:

    hook file.py:

    from PyInstaller.utils.hooks import collect_data_files

    datas = collect_data_files("package") #package is ros package under the "catkin_ws" path

Configuration:

OS : ubuntu 16.04

ROS version: Kinetic

edit retag flag offensive close merge delete

Comments

You are against the spirit of ROS by hiding your code.

CroCo gravatar image CroCo  ( 2021-10-28 04:42:20 -0500 )edit