-
Notifications
You must be signed in to change notification settings - Fork 237
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
Add ability to configure domain ID #594
Conversation
Signed-off-by: Barry Xu <[email protected]>
After checking failure log for
|
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
Signed-off-by: Barry Xu <[email protected]>
* \return the defined domain id | ||
*/ | ||
static PyObject * | ||
rclpy_get_default_domain_id(PyObject * Py_UNUSED(self), PyObject * args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was expecting this would call https://github.com/ros2/rcl/blob/6f3c3fb10391edaacb2676e2345a754bef1b76f2/rcl/include/rcl/domain_id.h#L40-L42 to get default domain id from rcl.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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) |
There was a problem hiding this comment.
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(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could add test in https://github.com/ros2/rclpy/blob/master/rclpy/test/test_utilities.py.
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add test with specific domain_id in https://github.com/ros2/rclpy/blob/master/rclpy/test/test_init_shutdown.py?
There was a problem hiding this comment.
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.
Sorry. It is my mistake. |
Sorry. |
Related to #484