ros_sugar.launch.executable
#
Module Contents#
Functions#
Executable main function to run a component as a ROS2 node in a new process. Used to start a node using Launcher |
API#
- ros_sugar.launch.executable.executable_main(*, list_of_components: List[Type], list_of_configs: List[Type])#
Executable main function to run a component as a ROS2 node in a new process. Used to start a node using Launcher
To use in your custom package based on ros_sugar:
Create an executable.py with a main and import your custom components and their config classes in it:
#!/usr/bin/env python3 from ros_sugar import executable_main my_components_list = ... my_configs_list = ... def main(args=None): executable_main(list_of_components=my_components_list, list_of_configs=my_configs_list)
Add your executable as an entry point in your custom package setup.py:
from setuptools import find_packages, setup package_name = "my_awesome_pkg" console_scripts = [ "executable = my_awesome_pkg.executable:main", ] setup( name=package_name, version="1", packages=find_packages(), install_requires=["setuptools"], zip_safe=True, maintainer="Cyberdyne Systems", maintainer_email="contact@cyberdynesystems.com", description="My awesome ROS2 sugar package", entry_points={ "console_scripts": console_scripts, }, )
Provide your package name and your entry point name to ros_sugar launcher in your script.
- Parameters:
list_of_components (List[Type]) – List of all known Component classes in the package
list_of_configs (List[Type]) – List of all known ComponentConfig classes in the package
- Raises:
ValueError – If component or component config are unknown classes
ValueError – If component cannot be started with provided arguments