OPT4SMART / ChoiRbot

A ROS 2 Toolbox for Cooperative Robotics
https://opt4smart.github.io/ChoiRbot/
GNU General Public License v3.0
38 stars 14 forks source link

Build Error after adding entry points in choirbot_examples/setup.py #5

Closed JayanthS18 closed 1 year ago

JayanthS18 commented 1 year ago

I am trying to implement the formation control example by following the instructions.When I build the package after adding entry points in the setup.py, I am getting the following error

  File "<string>", line 1, in <module>
  File "/usr/lib/python3.8/distutils/core.py", line 225, in run_setup
    raise RuntimeError(("'distutils.core.setup()' was never called -- "
RuntimeError: 'distutils.core.setup()' was never called -- perhaps 'setup.py' is not a Distutils setup script?
--- stderr: choirbot_examples                    
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/executor/__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/colcon_core/task/__init__.py", line 93, in __call__
    return await task_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 51, in build
    setup_py_data = get_setup_data(self.context.pkg, env)
  File "/usr/lib/python3/dist-packages/colcon_core/task/python/__init__.py", line 20, in get_setup_data
    return dict(pkg.metadata[key](env))
  File "/usr/lib/python3/dist-packages/colcon_ros/package_augmentation/ros_ament_python.py", line 57, in getter
    return get_setup_information(
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 241, in get_setup_information
    _setup_information_cache[hashable_env] = _get_setup_information(
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 281, in _get_setup_information
    result = subprocess.run(
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', "import sys;from setuptools.extern.packaging.specifiers import SpecifierSet;from distutils.core import run_setup;dist = run_setup(    'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = {    key: value for key, value in dist.__dict__.items()     if (        not key.startswith('_') and         not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data['metadata'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))"]' returned non-zero exit status 1.
---
Failed   <<< choirbot_examples [0.40s, exited with code 1]

Summary: 2 packages finished [10.3s]
  1 package failed: choirbot_examples
  1 package had stderr output: choirbot_examples
Command '['/usr/bin/python3', '-c', "import sys;from setuptools.extern.packaging.specifiers import SpecifierSet;from distutils.core import run_setup;dist = run_setup(    'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = {    key: value for key, value in dist.__dict__.items()     if (        not key.startswith('_') and         not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data['metadata'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))"]' returned non-zero exit status 1.

I have used the foxy-devel for my package However, when I colcon build with out adding the entry points in the setup.py

andrea-testa commented 1 year ago

Hi, thank you for your inquiry. Can you show us the setup.py and the package structure?

JayanthS18 commented 1 year ago

My setup.py file in src

from setuptools import setup, find_packages
from glob import glob

package_name = 'choirbot_examples'
scripts = {
    'containment':      ['guidance', 'integrator', 'rviz'],
    'bearingformationcontrol': ['guidance', 'integrator' ],
    'quadrotorbearingformationcontrol': ['guidance', 'controller', 'integrator' ],
    'formationcontrol': ['guidance', 'controller'],
    'mpc':              ['guidance', 'integrator', 'rviz'],
    'taskassignment':   ['guidance', 'table', 'planner', 'controller'],
    }

setup(
    name=package_name,
    version='0.0.0',
    packages=find_packages(),
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
        ('share/' + package_name, glob('launch/*.launch.py')),
        ('share/' + package_name, glob('resource/*.rviz')),
        ('share/' + package_name, glob('resource/*.sdf')),
    ],
    install_requires=['setuptools', 'choirbot'],
    zip_safe=True,
    maintainer='OPT4SMART',
    maintainer_email='info@opt4smart.eu',
    description='Example files for ChoiRbot',
    license='GNU General Public License v3.0',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'choirbot_{0}_{1} = choirbot_examples.{0}.{1}:main'.format(package, file)
            for package, files in scripts.items() for file in files
        ] + [
        'choirbot_formationcontrol_guidance = choirbot_examples.formationcontrol.guidance:main',
        'choirbot_formationcontrol_control = choirbot_examples.formationcontrol.control:main',
        'choirbot_turtlebot_spawner = choirbot_examples.turtlebot_spawner:main'
        ],
    },
)

My src package structure

├── choirbot
│   ├── choirbot
│   │   ├── communicator
│   │   │   ├── callback_group.py
│   │   │   ├── communicator.py
│   │   │   ├── executor.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── callback_group.cpython-38.pyc
│   │   │       ├── communicator.cpython-38.pyc
│   │   │       ├── executor.cpython-38.pyc
│   │   │       └── __init__.cpython-38.pyc
│   │   ├── controller
│   │   │   ├── controller.py
│   │   │   ├── __init__.py
│   │   │   ├── __pycache__
│   │   │   │   ├── controller.cpython-38.pyc
│   │   │   │   ├── __init__.cpython-38.pyc
│   │   │   │   ├── quadrotor_accelerationcontroller.cpython-38.pyc
│   │   │   │   ├── quadrotor_controller.cpython-38.pyc
│   │   │   │   └── unicycle_velocity.cpython-38.pyc
│   │   │   ├── quadrotor_accelerationcontroller.py
│   │   │   ├── quadrotor_controller.py
│   │   │   └── unicycle_velocity.py
│   │   ├── guidance
│   │   │   ├── distributed_control
│   │   │   │   ├── bearing_formationcontrol.py
│   │   │   │   ├── containment.py
│   │   │   │   ├── distributed_control.py
│   │   │   │   ├── formationcontrol.py
│   │   │   │   ├── __init__.py
│   │   │   │   └── __pycache__
│   │   │   │       ├── bearing_formationcontrol.cpython-38.pyc
│   │   │   │       ├── containment.cpython-38.pyc
│   │   │   │       ├── distributed_control.cpython-38.pyc
│   │   │   │       ├── formationcontrol.cpython-38.pyc
│   │   │   │       └── __init__.cpython-38.pyc
│   │   │   ├── guidance.py
│   │   │   ├── __init__.py
│   │   │   ├── mpc
│   │   │   │   ├── __init__.py
│   │   │   │   ├── mpc.py
│   │   │   │   └── __pycache__
│   │   │   │       ├── __init__.cpython-38.pyc
│   │   │   │       └── mpc.cpython-38.pyc
│   │   │   ├── optimization_thread.py
│   │   │   ├── __pycache__
│   │   │   │   ├── guidance.cpython-38.pyc
│   │   │   │   ├── __init__.cpython-38.pyc
│   │   │   │   └── optimization_thread.cpython-38.pyc
│   │   │   └── task
│   │   │       ├── executor.py
│   │   │       ├── __init__.py
│   │   │       ├── __pycache__
│   │   │       │   ├── executor.cpython-38.pyc
│   │   │       │   ├── __init__.cpython-38.pyc
│   │   │       │   ├── table.cpython-38.pyc
│   │   │       │   └── task.cpython-38.pyc
│   │   │       ├── table.py
│   │   │       └── task.py
│   │   ├── __init__.py
│   │   ├── integrator
│   │   │   ├── double_integrator.py
│   │   │   ├── __init__.py
│   │   │   ├── integrator.py
│   │   │   ├── __pycache__
│   │   │   │   ├── double_integrator.cpython-38.pyc
│   │   │   │   ├── __init__.cpython-38.pyc
│   │   │   │   ├── integrator.cpython-38.pyc
│   │   │   │   ├── quadrotor_integrator.cpython-38.pyc
│   │   │   │   ├── single_integrator.cpython-38.pyc
│   │   │   │   └── unicycle_integrator.cpython-38.pyc
│   │   │   ├── quadrotor_integrator.py
│   │   │   ├── single_integrator.py
│   │   │   └── unicycle_integrator.py
│   │   ├── optimizer
│   │   │   ├── __init__.py
│   │   │   ├── mpc_optimizer.py
│   │   │   ├── optimizer.py
│   │   │   ├── __pycache__
│   │   │   │   ├── __init__.cpython-38.pyc
│   │   │   │   ├── mpc_optimizer.cpython-38.pyc
│   │   │   │   ├── optimizer.cpython-38.pyc
│   │   │   │   └── task_optimizer.cpython-38.pyc
│   │   │   └── task_optimizer.py
│   │   ├── planner
│   │   │   ├── __init__.py
│   │   │   ├── planner.py
│   │   │   └── __pycache__
│   │   │       ├── __init__.cpython-38.pyc
│   │   │       └── planner.cpython-38.pyc
│   │   ├── __pycache__
│   │   │   └── __init__.cpython-38.pyc
│   │   └── utils
│   │       ├── __init__.py
│   │       ├── or_event.py
│   │       ├── position_getter.py
│   │       ├── __pycache__
│   │       │   ├── __init__.cpython-38.pyc
│   │       │   ├── or_event.cpython-38.pyc
│   │       │   ├── position_getter.cpython-38.pyc
│   │       │   ├── simple_visualizer.cpython-38.pyc
│   │       │   └── visualizer.cpython-38.pyc
│   │       ├── simple_visualizer.py
│   │       └── visualizer.py
│   ├── package.xml
│   ├── resource
│   │   └── choirbot
│   ├── setup.cfg
│   ├── setup.py
│   └── tests
│       └── communicators
│           └── test_callback_groups.py
├── choirbot_examples
│   ├── choirbot_examples
│   │   ├── bearingformationcontrol
│   │   │   ├── guidance.py
│   │   │   ├── __init__.py
│   │   │   └── integrator.py
│   │   ├── containment
│   │   │   ├── guidance.py
│   │   │   ├── __init__.py
│   │   │   ├── integrator.py
│   │   │   └── rviz.py
│   │   ├── formationcontrol
│   │   │   ├── controller.py
│   │   │   ├── guidance.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── controller.cpython-38.pyc
│   │   │       ├── guidance.cpython-38.pyc
│   │   │       └── __init__.cpython-38.pyc
│   │   ├── __init__.py
│   │   ├── mpc
│   │   │   ├── guidance.py
│   │   │   ├── __init__.py
│   │   │   ├── integrator.py
│   │   │   ├── __pycache__
│   │   │   │   ├── guidance.cpython-38.pyc
│   │   │   │   ├── __init__.cpython-38.pyc
│   │   │   │   ├── integrator.cpython-38.pyc
│   │   │   │   └── rviz.cpython-38.pyc
│   │   │   └── rviz.py
│   │   ├── __pycache__
│   │   │   ├── __init__.cpython-38.pyc
│   │   │   └── turtlebot_spawner.cpython-38.pyc
│   │   ├── quadrotorbearingformationcontrol
│   │   │   ├── controller.py
│   │   │   ├── guidance.py
│   │   │   ├── __init__.py
│   │   │   └── integrator.py
│   │   ├── taskassignment
│   │   │   ├── controller.py
│   │   │   ├── guidance.py
│   │   │   ├── __init__.py
│   │   │   ├── planner.py
│   │   │   ├── __pycache__
│   │   │   │   ├── controller.cpython-38.pyc
│   │   │   │   ├── guidance.cpython-38.pyc
│   │   │   │   ├── __init__.cpython-38.pyc
│   │   │   │   ├── planner.cpython-38.pyc
│   │   │   │   ├── table.cpython-38.pyc
│   │   │   │   └── turtlebot3_position_control_feedback.cpython-38.pyc
│   │   │   ├── table.py
│   │   │   ├── turtlebot3_position_control_feedback.py
│   │   │   └── turtlebot3_position_control.py
│   │   └── turtlebot_spawner.py
│   ├── launch
│   │   ├── bearingformationcontrol.launch.py
│   │   ├── containment.launch.py
│   │   ├── formationcontrol.launch.py
│   │   ├── gazebo.launch.py
│   │   ├── mpc.launch.py
│   │   ├── quadrotorbearingformationcontrol.launch.py
│   │   └── taskassignment.launch.py
│   ├── package.xml
│   ├── resource
│   │   ├── choirbot_examples
│   │   ├── model_burger.sdf
│   │   └── rvizconf.rviz
│   ├── setup.cfg
│   └── setup.py
├── choirbot_interfaces
│   ├── action
│   │   └── PositionAction.action
│   ├── choirbot_interfaces
│   │   └── __init__.py
│   ├── CMakeLists.txt
│   ├── msg
│   │   ├── PositionTaskArray.msg
│   │   └── PositionTask.msg
│   ├── package.xml
│   ├── setup.py
│   └── srv
│       ├── PositionTaskService.srv
│       └── TaskCompletionService.srv
├── docs
│   ├── make.bat
│   ├── Makefile
│   ├── requirements.txt
│   └── source
│       ├── acknowledgements
│       │   └── index.rst
│       ├── api_documentation
│       │   ├── choirbot.communicator.rst
│       │   ├── choirbot.guidance.distributed_control.rst
│       │   ├── choirbot.guidance.mpc.rst
│       │   ├── choirbot.guidance.rst
│       │   ├── choirbot.guidance.task.rst
│       │   └── index.rst
│       ├── biblio.bib
│       ├── citing
│       │   └── index.rst
│       ├── conf.py
│       ├── examples
│       │   ├── dynamic_task_assignment.rst
│       │   ├── formation_control.rst
│       │   ├── index.rst
│       │   └── mpc.rst
│       ├── index.rst
│       ├── installation
│       │   └── index.rst
│       ├── quick_start
│       │   └── index.rst
│       └── _static
│           ├── formationcontrol.png
│           ├── logo_ERC.png
│           ├── logo_OPT4Smart.png
│           ├── mpc.png
│           ├── taskassignment_gazebo.png
│           └── taskassignment_table.png
├── LICENSE
├── README.md
├── readthedocs.yaml
├── requirements_disropt.txt
└── requirements.txt

54 directories, 182 files
andrea-testa commented 1 year ago

Hi, I would suggest not to add new entrypoints as in the last lines of your scripts. Once you declare them in the 'script' dictionary, the loop 'choirbot{0}{1} = choirbot_examples.{0}.{1}:main'.format(package, file) for package, files in scripts.items() for file in files automatically declares them. So when you add ''choirbot_formationcontrol_guidance = choirbot_examples.formationcontrol.guidance:main' I believe you are creating some kind of duplicate which may be the cause of the error