Skip to content

Commit

Permalink
Update Basic test to reflect service client API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
romainreignier committed Sep 10, 2018
1 parent 2cb51da commit e9202fe
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/Basic/node.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "node.h"
#include <roscpp_tutorials/TwoInts.h>
#include <rosserial_msgs/ServiceCallResult.h>

Node::Node():
chatter("chatter"),
Expand Down Expand Up @@ -43,9 +44,19 @@ void Node::onTimer()
chatter.publish(str_msg);

roscpp::GetLoggersRequest req;
serviceClient.call(req, [](const roscpp::GetLoggers::Response &loggers){
std::cout << "loggers : " << QJsonDocument(loggers.serializeAsJson()).toJson(QJsonDocument::Indented).toStdString() << std::endl;

serviceClient.call(req, [this](const roscpp::GetLoggers::Response &loggers, bool ok, uint8_t callResult){
switch(callResult)
{
case rosserial_msgs::ServiceCallResult::NO_EXISTENCE:
std::cout << "Service " << serviceClient.topic_ << " does not exist" << std::endl;
break;
case rosserial_msgs::ServiceCallResult::CALL_FAILED:
std::cout << "Call to service " << serviceClient.topic_ << " failed" << std::endl;
break;
case rosserial_msgs::ServiceCallResult::SUCCESS:
std::cout << "loggers : " << QJsonDocument(loggers.serializeAsJson()).toJson(QJsonDocument::Indented).toStdString() << std::endl;
break;
}
});
}

Expand Down

0 comments on commit e9202fe

Please sign in to comment.