ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
--- string return_value
The basic approach seems ok, but I'd add a new-line between the ---
and your string return_value
, like so:
---
string return_value
You write:
However, when I try to call it, I get an error that function accepted 0 arguments and got 1
Could you please add a snippet to your question that shows exactly what you're trying to do, and what the exact error message is?
2 | No.2 Revision |
--- string return_value
The basic approach seems ok, but I'd add a new-line between the ---
and your string return_value
, like so:
---
string return_value
You write:
However, when I try to call it, I get an error that function accepted 0 arguments and got 1
Could you please add a snippet to your question that shows exactly what you're trying to do, and what the exact error message is?
Edit:
EDIT: I noticed that one way to do it would be to add (some) argument to service_implementation so that it looks like
def service_implementation(request): return "answer"
Ah, yes.
When talking about 'services', we (I ?) always think of the abstracted ROS API level. So a 'no arguments service' is a ROS service that takes no arguments (like you defined), but at the C++/Python implementation level, you'll always need to accept (and handle) the request-reply pair that gets supplied by the ROS middleware to your client program.
For a 'no arguments service', that will just mean that the Request
type has no (public) member fields. In Python, returning just a str
probably then works because it's automatically transformed using the appropriate constructor of the Reply
type.