diff --git a/test/Basic/node.cpp b/test/Basic/node.cpp index bfb46a0..77a4a9c 100644 --- a/test/Basic/node.cpp +++ b/test/Basic/node.cpp @@ -1,5 +1,6 @@ #include "node.h" #include +#include Node::Node(): chatter("chatter"), @@ -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; + } }); }