-
Notifications
You must be signed in to change notification settings - Fork 227
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
Composition API #599
base: rolling
Are you sure you want to change the base?
Composition API #599
Conversation
Missing features/TODO list records:
|
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.
Looks like a good start! I've left some preliminary feedback. I'll take a look at the connected ros2cli PR and examples next.
self.components = {} # key: unique_id, value: full node name and component instance | ||
self.unique_id_index = 0 | ||
|
||
self.executor.spin() |
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.
Given that we're also calling spin in the containers, which is a blocking call, I'm surprised that the advertised services work (I haven't tried it myself yet). I would think that we don't need to call spin here.
rclpy_components/package.xml
Outdated
<license>TODO: License declaration</license> | ||
|
||
<depend>rclpy</depend> | ||
<depend>std_msgs</depend> |
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.
looks like we're not depending on std_msgs
, but instead we need composition_interfaces
.
|
||
def main(): | ||
try: | ||
_main() |
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.
Rather than wrapping all of the logic in _main()
in a try-catch, I think we can narrow the scope to the spin()
call and remove the redundant "main" function. For example, see how it looks in this demo.
from importlib_metadata import entry_points | ||
|
||
RCLPY_COMPONENTS = 'rclpy_components' | ||
logger = get_logger('ComponentManager') |
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.
Instead of creating a global logger, why not just use the nodes logger? For example.
rclpy_components/setup.py
Outdated
zip_safe=True, | ||
maintainer='root', | ||
maintainer_email='[email protected]', | ||
description='TODO: Package description', |
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.
Please populate the description.
rclpy_components/package.xml
Outdated
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">root</maintainer> | ||
<license>TODO: License declaration</license> |
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.
<license>TODO: License declaration</license> | |
<license>Apache License 2.0</license> |
rclpy_components/package.xml
Outdated
<name>rclpy_components</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="[email protected]">root</maintainer> |
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.
<maintainer email="[email protected]">root</maintainer> | |
<maintainer email="[email protected]">Jacob Perron</maintainer> |
rclpy_components/package.xml
Outdated
<package format="3"> | ||
<name>rclpy_components</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> |
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.
Please populate this description.
rclpy_components/package.xml
Outdated
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>rclpy_components</name> | ||
<version>0.0.0</version> |
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.
For maintenance reasons, this should match the version of other packages in this repository.
<version>0.0.0</version> | |
<version>1.1.0</version> |
Thanks for the review! Just get myself back to work after a LONG business travel. I'll look into the code and make some fixes/improvments |
eb9f93a
to
a05946f
Compare
171d13b
to
cbe3290
Compare
@jacobperron Hi, I've made some changes following the reviews, make a list here for better track:
Also with the basic unit/integrated test code added. Let's first make this PR merged and then move to next PRs related to ros2cli and examples |
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.
Great start! I like the use of entry points for finding components. Any idea why the multithreaded test is failing?
rclpy_components/package.xml
Outdated
<name>rclpy_components</name> | ||
<version>1.1.0</version> | ||
<description>The dynamic node management package</description> | ||
<maintainer email="[email protected]">Zhen Ju</maintainer> |
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.
Mind adding yourself as an <author>
tag, and adding @claireyywang @ivanpauno and myself as maintainers?
Lines 8 to 10 in 22816b4
<maintainer email="[email protected]">Claire Wang</maintainer> | |
<maintainer email="[email protected]">Ivan Paunovic</maintainer> | |
<maintainer email="[email protected]">Shane Loretz</maintainer> |
executor.spin() | ||
except KeyboardInterrupt: | ||
print('KeyboardInterrupt received, exit') | ||
pass |
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.
nit - no need for pass
here :)
assert mock_res.error_message | ||
assert (not mock_res.success) | ||
|
||
# Unload the first node |
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 might become the only test in rclpy that depends on the state of the previous tests. I've never seen this style before. IIUC it works because the test runner sorts tests alphabetically.
No need to change anything here - I'm fine with this as is.
unload_res: UnloadNode.Response = self.__class__.unload_node(1000) | ||
assert unload_res.error_message != "" | ||
assert unload_res.success is False | ||
list_res: ListNodes.Response = self.__class__.list_nodes() |
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.
nit - don't need to specify __class__
when calling class methods; self.list_nodes()
works
|
||
def list_nodes_test(self): | ||
container_name = self.__class__.container_name | ||
print(f'{container_name}: list_nodes tested within test_load_node and test_unload_node') |
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.
nit, I would delete this function since it doesn't test anything.
self.list_nodes_test() | ||
|
||
|
||
class TestComponentManagerMT(TestComponentManager): |
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 see a test failure here when I merged this branch into master locally. Any ideay why?
============================= test session starts ==============================
platform linux -- Python 3.8.2, pytest-4.6.9, py-1.8.1, pluggy-0.13.0
cachedir: /home/sloretz/bigssd/ros2/build/rclpy_components/.pytest_cache
rootdir: /home/sloretz/bigssd/ros2/src/ros2/rclpy, inifile: pytest.ini
plugins: ament-copyright-0.10.0, ament-pep257-0.10.0, ament-flake8-0.10.0, ament-lint-0.10.0, colcon-core-0.6.0, cov-2.8.1, mock-1.10.4
collecting ...
collected 13 items
test/test_component_manager.py .F [ 15%]
test/test_component_manager_ut.py ........ [ 76%]
test/test_copyright.py . [ 84%]
test/test_flake8.py . [ 92%]
test/test_pep257.py . [100%]
=================================== FAILURES ===================================
_________________ TestComponentManagerMT.test_composition_api __________________
test/test_component_manager.py:187: in test_composition_api
self.load_node_test()
test/test_component_manager.py:130: in load_node_test
load_res = self.__class__.load_node(TEST_COMPOSITION, TEST_COMPOSITION_FOO)
test/test_component_manager.py:93: in load_node
raise RuntimeError(f'No load service found in /{cls.container_name}')
E RuntimeError: No load service found in /TestComponentManagerMT
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 remember to add some components specifically for the test, so the test won't have to rely on any pre-existing components. It seems the testing components are not installed, I'll take a look into this.
Any update on this? We have the need for launching python components and having that integrated would be very neat. |
@buschbapti Thanks for the attention. I'll make a recheck on this and see if it can be merged ASAP. |
I copied your |
This seems to be an important feature and it is almost done! Any update on this? |
+1 |
@crystaldust Are you still working on this? If not I'd be take over and help push this PR through. |
Hello any updates on this? Will it be integrated? |
@mjcarroll @sloretz @crystaldust just trying to bump this again, we've been using it for 2 years and works as expected |
The project provide component container(special Node) and component_manager Signed-off-by: Zhen Ju <[email protected]>
Signed-off-by: Zhen Ju <[email protected]>
This is to get rid of the impact of global remapping rules on node name, which will create nodes with duplicated names. Remove *args in ComponentManager's constructor. Signed-off-by: Zhen Ju <[email protected]>
* Update the meta info in package.xml and setup.py * Try-except executor.spin instead of main in executables * Use f string to format infos * Pass error message to response objectc instead of logging it * Use node's logger instead of init a global one * Call node.get_qualified_name() to assign response obj's full_node_name * Other super tiny changes Signed-off-by: Zhen Ju <[email protected]>
Signed-off-by: Zhen Ju <[email protected]>
cbe3290
to
875d84c
Compare
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Since it had been a while I rebased this onto
And with that, this PR LGTM, but I've made so many changes I think it needs another reviewer. |
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.
LGTM with green CI and a second reviewer!
CI (repos file build: EDIT: the tests on Windows got stuck. I don't have access to a Windows machine at the moment to debug this :( |
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.
Code looks reasonable to me, and since it's a new package then it comes with little enough risk in my opinion. I'd say if you @sloretz and @adityapande-1995 are ok with it (since you're the new maintainers of the new package), then lgtm.
Are there any examples?
Any chance this could get merged soon? I'd also be interested in a backport at least through Humble. |
Ditto to the value of a |
@Mergifyio Update |
❌ Sorry but I didn't understand the command. Please consult the commands documentation 📚. |
@Mergifyio update |
✅ Branch has been successfully updated |
The composition API for rclpy.
Add a new rclpy_components sub project just like what rclcpp_components does. The project provides the component manager(essentially a wrapper of Node and executor), which provides the required services described in the composition design doc for the ros2cli to load/unload/list components
Related PR: ros2/ros2cli#554