Conversation
ros2cli/ros2cli/node/direct.py
Outdated
| if inspect.isfunction(function): | ||
| function_signature = inspect.signature(function) | ||
| if 'node' == tuple(function_signature.parameters)[0]: | ||
| return functools.partial(function, self) |
There was a problem hiding this comment.
This is not really nice.
It would be better if DaemonNode could be used as a "normal node", instead of patching the DaemonNode and modifying the DirectNode to work in the same way.
Probably, this is not possible using XML-RPC. Maybe we could use a different IPC mechanism?
There was a problem hiding this comment.
Yeap, I agree. But the problem isn't the IPC mechanism, really. Graph API for actions in rclpy departs from the pattern that the rest follow and on which NodeStrategy implementation rests upon. On a regular node, you'd simply call rclpy.action.get_action_*(node, *args), but those simply forward down to the C layer (see here). The pattern doesn't lend itself well to polymorphism. That's why I made DirectNode look like NodeStrategy, and not the other way around.
I have yet to come up with a way to do this nicely and transparent for those who write API like that of rclpy.action. We could make our C calls through the handle, like:
def get_action_client_names_and_types_by_node(
node: Node,
remote_node_name: str,
remote_node_namespace: str
) -> List[Tuple[str, List[str]]]:
get_action_client_names_and_types_by_node = node.handle.bind(
_rclpy_action.rclpy_action_get_client_names_and_types_by_node)
return get_action_client_names_and_types_by_node(
remote_node_name, remote_node_namespace)It isn't pretty, but it gives us a chance to proxy calls.
Tagging @jacobperron @wjwwood, both probably have thoughts on this.
There was a problem hiding this comment.
I like that proposal.
It's much more work though, but the result is cleaner.
There was a problem hiding this comment.
I agree that we could be more consistent with the API in rclpy. I think any refactoring in rclpy can be left as part of a more thorough design review. For now, what if we just add a couple action specific functions to the DirectNode API?
I think it's easier to understand than inspecting function signatures, e.g.
class DirectNode:
# ...
def get_action_names_and_types():
return rclpy.action.get_action_names_and_types(self.node)
def get_action_client_names_and_types_by_node(node_name, node_ns):
return rclpy.action.get_action_client_names_and_types_by_node(self.node, node_name, node_ns)
# ... etcThere was a problem hiding this comment.
I was trying to not do that :). But I'm fine with being explicit. See c0a78fe.
There was a problem hiding this comment.
I understand, but I think the diff is easier to parse with override functions (obviously just an opinion). The TODO still holds in any case.
|
@jacobperron @ivanpauno once you are both OK with this patch, I'll rebase and run CI. |
ros2topic/test/test_cli.py
Outdated
| ), timeout=10) | ||
| assert topic_command.wait_for_shutdown(timeout=10) | ||
|
|
||
| @launch_testing.markers.retry_on_failure(times=5) |
There was a problem hiding this comment.
Why are these changes needed and how are they related to this PR?
There was a problem hiding this comment.
Those changes slipped in, my bad. These tests flaked me once locally, and later I forgot to take decorators out. We can split into their own PR if you'd like. Or drop them, truth is I cannot consistently reproduce the flake -- and I highly doubt it had anything to do with this patch.
There was a problem hiding this comment.
Yeah, splitting sounds reasonable since nobody will expect this change in the squashed commit after the fact.
jacobperron
left a comment
There was a problem hiding this comment.
LGTM with Dirks question answered and green CI.
c0a78fe to
d6e475e
Compare
|
@jacobperron @dirk-thomas @ivanpauno I've rebased to leave a clean history. I plan to keep each commit. PTAL while CI runs. |
d6e475e to
981a4db
Compare
|
Checking CI failures I came across a small pre-existing bug (645b3ee). Of course I cannot locally reproduce any of these failures. Let's see what comes out of a Windows CI now. |
645b3ee to
b7b2eb6
Compare
Support ROS graph API for actions plus basic node queries. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
b7b2eb6 to
4decccf
Compare
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
|
Ok, CI's green, which I attribute to many |
Significant changes
|
(I invalidated all previous reviews since there have been significant changes to the PR since then.) Imo the current patch contains too many unrelated changes to land in a single PR. It should be split up into individually reviewed changes. |
Fair enough, I can split it. |
Closes #419. Follow up after #420. This pull request extends daemon API support a bit more and adapts all CLI verbs to make use of it.