Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to configure domain ID #594

Conversation

Barry-Xu-2018
Copy link
Contributor

Related to #484

@Barry-Xu-2018
Copy link
Contributor Author

After checking failure log for Rpr__rclpy__ubuntu_focal_amd64 — Build finished., I find the error is the same as below.
It seems that test environment has problem.

Traceback:
../../src/rclpy/rclpy/test/__init__.py:23: in <module>
    import rclpy.impl  # noqa
../../src/rclpy/rclpy/rclpy/__init__.py:47: in <module>
    from rclpy.context import Context
../../src/rclpy/rclpy/rclpy/context.py:21: in <module>
    from rclpy.impl.implementation_singleton import rclpy_implementation
../../src/rclpy/rclpy/rclpy/impl/implementation_singleton.py:31: in <module>
    rclpy_implementation = _import('._rclpy')
../../src/rclpy/rclpy/rclpy/impl/__init__.py:28: in _import
    return importlib.import_module(name, package='rclpy')
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'rclpy._rclpy'
E   The C extension '/tmp/ws/src/rclpy/rclpy/rclpy/_rclpy.cpython-38-x86_64-linux-gnu.so' isn't present on the system. Please refer to 'https://index.ros.org/doc/ros2/Troubleshooting/Installation-Troubleshooting/#import-failing-without-library-present-on-the-system' for possible solutions

* \return the defined domain id
*/
static PyObject *
rclpy_get_default_domain_id(PyObject * Py_UNUSED(self), PyObject * args)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is called at
https://github.com/Barry-Xu-2018/rclpy/blob/02d0bb6aa33b8e44a97ecac6cae4bbb8fce20f34/rclpy/rclpy/__init__.py#L63-L68.
rcl_get_default_domain_id() may return error.
rclpy_get_default_domain_id() directly return RCL_DEFAULT_DOMAIN_ID defined in rcl layer.

Besides, this domain id (RCL_DEFAULT_DOMAIN_ID) will be set to init_options in rclpy_init() (_rclpy.c)
In rcl_init(), if domain id equal to RCL_DEFAULT_DOMAIN_ID, rcl_get_default_domain_id() will be called.
Refer to https://github.com/ros2/rcl/blob/6f3c3fb10391edaacb2676e2345a754bef1b76f2/rcl/src/rcl/init.c#L146-L154.

So not directly call rcl_get_default_domain_id() here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense.

args: Optional[List[str]] = None,
*,
initialize_logging: bool = True,
domain_id: int = rclpy_implementation.rclpy_get_default_domain_id()):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why call implementation instead of calling utilities.get_default_domain_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is because utilities.py has imported context.py.
https://github.com/Barry-Xu-2018/rclpy/blob/02d0bb6aa33b8e44a97ecac6cae4bbb8fce20f34/rclpy/rclpy/utilities.py#L22

In order to avoid interdependence, have to call rclpy_implementation.

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to add some test.

* \return the defined domain id
*/
static PyObject *
rclpy_get_default_domain_id(PyObject * Py_UNUSED(self), PyObject * args)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense.

@@ -39,6 +39,12 @@ def get_default_context(*, shutting_down=False):
return g_default_context


def get_default_domain_id():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I will supplement test codes.


# Avoid loading extensions on module import
if TYPE_CHECKING:
from rclpy.executors import Executor # noqa: F401
from rclpy.node import Node # noqa: F401


def init(*, args: Optional[List[str]] = None, context: Context = None) -> None:
def init(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I will supplement test codes.

@Barry-Xu-2018
Copy link
Contributor Author

#594 (comment)

Sorry. It is my mistake.
The failure is caused from my modification.
I will fix it.

@Barry-Xu-2018
Copy link
Contributor Author

Barry-Xu-2018 commented Jul 8, 2020

@fujitatomoya

Sorry.
Since the change is a bit big, I will close this PR and create new PR to review.
New PR is #596.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants