How to import msg file by using executable file?

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

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