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

use new type identification for service calls #242

Merged
merged 4 commits into from
May 20, 2019
Merged

Conversation

Karsten1987
Copy link
Contributor

Similar problem as described here: #241
ros2 service call ... fails because the new service types are parsed incorrectly.

Signed-off-by: Karsten Knese karsten@openrobotics.org

Signed-off-by: Karsten Knese <karsten@openrobotics.org>
@Karsten1987 Karsten1987 added bug Something isn't working in review Waiting for review (Kanban column) labels May 17, 2019
@Karsten1987 Karsten1987 self-assigned this May 17, 2019
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
Signed-off-by: Karsten Knese <karsten@openrobotics.org>
@dirk-thomas
Copy link
Member

Why not just (without error checking)?

parts = service_type.split('/')
module = importlib.import_module('.'.join(parts[:-1]))
srv_module = getattr(module, parts[-1])

@Karsten1987
Copy link
Contributor Author

I don't have enough insights about this to answer whether or not the error checking makes sense or not. I'd naively say yes (error checking makes sense) so that we catch easier when this behavior changes in the future, but I am open for whatever is best practice here.

@jacobperron
Copy link
Member

I think more generally having what @dirk-thomas suggests makes sense, since we haven't settle on how many parts to the message namespace there can be. Probably a better way to error check is to wrap the whole thing in a try-except since the import_module / getattr should tell us if the name is valid, right?

@Karsten1987
Copy link
Contributor Author

@dirk-thomas is the proposed way what you envisioned? I am happy to change it to whatever is recommended.

@dirk-thomas
Copy link
Member

My snippet was meant as this-is-how-the-logic-should-work and would get rid of all the extra steps currently being used. The snippet doesn't do any error checking - but the actual patch should certainly do that - I just left that out for brevity.

Signed-off-by: Karsten Knese <karsten@openrobotics.org>
@Karsten1987
Copy link
Contributor Author

@jacobperron @dirk-thomas does 468289d look like what you've suggested?

Copy link
Member

@dirk-thomas dirk-thomas left a comment

Choose a reason for hiding this comment

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

LGTM.

Have you ensure that it continues to work for actions?

@Karsten1987
Copy link
Contributor Author

Did it work before this patch with actions? I haven't tested it with actions. Do we have a working example for this?

@dirk-thomas
Copy link
Member

I assume it worked before. Since you are changing the code dealing with action types in this patch please also check it with an action type. I don't have an example at hand.

@Karsten1987
Copy link
Contributor Author

How do we get the type information of the actual action service?
Let's say I run:

ros2 run examples_rclcpp_minimal_action_server action_server_member_functions

what's the respective type to the service:

ros2 service call /fibonacci/_action/send_goal <type> "{order: 10}"

I've tried:

ros2 service call /fibonacci/_action/send_goal example_interfaces/action/Fibonacci_SendGoal_Request "{order: 10}"

but this fails with AttributeError: module 'example_interfaces.action' has no attribute 'Fibonacci_SendGoal_Request'. This makes me believe that the split logic works correctly, but I've specified the wrong type.

@jacobperron
Copy link
Member

The "send goal" service is defined in the module example_interfaces.action._fibonacci. Even with the code before, I don't think it is possible to make the service call work for actions. But maybe now with multiple namespaces allowed, it could be possible with something like:

ros2 service call /fibonacci/_action/send_goal example_interfaces/action/_fibonacci/Fibonacci_SendGoal "{goal: {order: 10}}"

@Karsten1987
Copy link
Contributor Author

Great! @jacobperron example does work.

@Karsten1987
Copy link
Contributor Author

CI (build: --packages-up-to ros2service | test: --packages-select ros2service)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@Karsten1987 Karsten1987 merged commit ee3a2c7 into master May 20, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix_ros2service branch May 20, 2019 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in review Waiting for review (Kanban column)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants