Skip to content

Commit

Permalink
Modify service client to retrieve if the service call has succeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
romainreignier committed Jan 4, 2018
1 parent a898fcd commit 052525e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/ros_lib/ros/service_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace ros {
public:
typedef typename MType::Request MReq;
typedef typename MType::Response MRes;
typedef std::function<void(const MRes&)> CallbackT;
typedef std::function<void(const MRes&, bool)> CallbackT;

ServiceClient(const char* topic_name) :
pub(topic_name, rosserial_msgs::TopicInfo::ID_SERVICE_CLIENT + rosserial_msgs::TopicInfo::ID_PUBLISHER)
Expand All @@ -74,11 +74,18 @@ namespace ros {
// these refer to the subscriber
void callback(unsigned char *data) override{
MRes ret;
ret.deserialize(data);
// First byte give us the success status
bool success = data[0];

if(success)
{
// Access from the second byte
ret.deserialize(data+1);
}
waiting = false;
if(cb_)
{
cb_(ret);
cb_(ret, success);
}
cb_ = nullptr;
}
Expand Down

0 comments on commit 052525e

Please sign in to comment.