Pepper robot: upload python modules

2020-03-24 06:52发布

问题:

I'm programming a Pepper robot with Choregraphe and I'm using a real robot. The problem I have is how can I install python modules to the robot? because I need to use the requests package to make API calls.

I have been browsing in the internet but I don't found any solution.

回答1:

Root access is deactivated for security reasons so you won't be able to install a package on the robot. If you wish to use external libraries you need to package them as part of your app, as explained below (from https://community.ald.softbankrobotics.com/en/forum/import-libs-py-choregraphe-3578):

You will need to add the path to your packages to Python's sys.path.

  1. Do to that from your Choregraphe Python box do something like this:

    import os, sys
    python_path = os.path.join(self.behaviorAbsolutePath(), 'lib')
    if python_path not in sys.path:
        sys.path.append(python_path)
    

This will make any Python files in the "lib" directory in your application importable. Make sure to import those files in your Choregraphe package, otherwise they won't be installed.

  1. If we do this from a Python module that is at the root of the project, you will need to use:

python_path = os.path.join(os.path.abspath(__file__), 'lib')

to get "current_path/lib" to be added to sys.path