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

Add wrappers for common operation signatures to rtt_std_srvs #123

Merged

Conversation

meyerj
Copy link
Member

@meyerj meyerj commented May 7, 2019

Implements #101.

With this patch it is possible to create ROS service servers for some common operation signatures out of the box, without the need to write custom wrappers or to add extra operations with the ROS specific callback signature.

Supported service types and associated signatures:

std_srvs/Empty:
- bool empty()                     // The service call fails if empty() returns false!
                                   // Use std_srvs/Trigger if the result should be returned as the response.
- void empty()

std_srvs/SetBool:
- bool setBool(bool, std::string &message_out)
- bool setBool(bool)               // response.message will be empty
- std::string setBool(bool)        // response.success = true
- void setBool(bool)               // response.success = true and response.message will be empty

std_srvs/Trigger:
- bool trigger(std::string &message_out)
- bool trigger()                   // response.message will be empty
- std::string trigger()            // response.success = true

The approach can be easily extended to other ROS service types.

@meyerj meyerj added this to the 2.9 milestone May 7, 2019
…s to rtt_std_srvs (fix #101)

With this patch it is possible to create ROS service servers for some common operation signatures out of the box,
without the need to write custom wrappers or to add extra operations with the ROS specific callback signature.

Supported service types and associated signatures:

std_srvs/Empty:
- bool empty()                     // The service call fails if empty() returns false!
                                   // Use std_srvs/Trigger if the result should be returned as the response.
- void empty()

std_srvs/SetBool:
- bool setBool(bool, std::string &message_out)
- bool setBool(bool)               // response.message will be empty
- std::string setBool(bool)        // response.success = true
- void setBool(bool)               // response.success = true and response.message will be empty

std_srvs/Trigger:
- bool trigger(std::string &message_out)
- bool trigger()                   // response.message will be empty
- std::string trigger()            // response.success = true

The approach can be easily extended to other ROS service types.
@meyerj meyerj force-pushed the rtt_std_srvs-for-standard-operations branch from 7564c75 to 524f976 Compare May 8, 2019 00:16
Copy link
Collaborator

@francisco-miguel-almeida francisco-miguel-almeida left a comment

Choose a reason for hiding this comment

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

LGTM, there was just a build failure due to pre-C++11 incompatibility. Issue is easily circumvented, however.

@@ -118,12 +118,23 @@ TEST(TransportTest, VectorTest)
}

static int callback_called = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: do we control in which thread the callbacks are made? If not, maybe this counter should be atomic. Not important right now, just curious.

Copy link
Member Author

@meyerj meyerj May 8, 2019

Choose a reason for hiding this comment

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

The callbacks are executed by a thread pool owned by a ros::AsyncSpinner in rtt_rosnode. They could execute in parallel, but the service calls in the unit tests are synchronous and block until the callback has been processed and the results are returned through the network stack and roscpp. So no concurrency.

@francisco-miguel-almeida
Copy link
Collaborator

LGTM, there was just a build failure due to pre-C++11 incompatibility. Issue is easily circumvented, however.

Was not quite as easily circumvented as it appeared at first, but now it works as intended.
We can address the SFINAE hackiness later.

@francisco-miguel-almeida francisco-miguel-almeida merged commit 8586e84 into toolchain-2.9 May 8, 2019
@meyerj meyerj deleted the rtt_std_srvs-for-standard-operations branch May 8, 2019 15:38
@ahoarau
Copy link
Contributor

ahoarau commented May 8, 2019

Very nice !

@ahoarau
Copy link
Contributor

ahoarau commented May 8, 2019

very nice !

meyerj added a commit that referenced this pull request Jun 26, 2019
…ion from #123)

Clang seems to handle SFINAE differently than gcc and compilation of generated service proxy plugins failed with errors like:

In file included from rtt_diagnostic_msgs/diagnostic_msgs_service_proxies/rtt_rosservice_proxies.cpp:7:
rtt_roscomm/rtt_rosservice_proxy.h:99:30: error: implicit instantiation of undefined template 'ROSServiceServerOperationCallerWrapper<diagnostic_msgs::AddDiagnostics, 1>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants