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

Revision history [back]

click to hide/show revision 1
initial version

As discussed here, the following is needed:

  1. Place your module in <ws>/src/<pkg-name>/src/<pkg-name>
  2. Create an empty file <ws>/src/<pkg-name>/src/<pkg-name>/__init__.py
  3. Create <ws>/src/<pkg-name>/setup.py with

    from distutils.core import setup from catkin_pkg.python_setup import generate_distutils_setup

    setup_args = generate_distutils_setup() setup_args['packages'] = ['<pkg-name>'] setup_args['package_dir'] = {'': 'src'}

    setup(**setup_args)

  4. Add catkin_python_setup() to <ws>/src/<pkg-name>/CMakeLists.txt
  5. Build workspace with catkin_make
  6. Open <ws> in VS Code with ROS and Pylint extensions installed
  7. Add src/<pkg-name>/srcto "python.autoComplete.extraPaths" in <ws>/.vscode/settings.json

As discussed here, the following is needed:

  1. Place your module in <ws>/src/<pkg-name>/src/<pkg-name>
  2. Create an empty file <ws>/src/<pkg-name>/src/<pkg-name>/__init__.py
  3. Create <ws>/src/<pkg-name>/setup.py with

    from distutils.core import setup from catkin_pkg.python_setup import generate_distutils_setup

    setup_args = generate_distutils_setup() setup_args['packages'] = ['<pkg-name>'] setup_args['package_dir'] = {'': 'src'}

    setup(**setup_args)

  4. Add catkin_python_setup() to <ws>/src/<pkg-name>/CMakeLists.txt
  5. Build workspace with catkin_make
  6. Open <ws> in VS Code with ROS and Pylint extensions installed
  7. Add src/<pkg-name>/src to "python.autoComplete.extraPaths" in <ws>/.vscode/settings.json

You can then from <pkg-name>.<module-name> import <your-content> from any node script (e.g. <ws>/src/<pkg-name>/scripts/mynode)