Commit b31c1856 authored by Valentin Platzgummer's avatar Valentin Platzgummer

topic publishing issue solved

parent 591ba07e
...@@ -28,12 +28,11 @@ QGCROOT = $$PWD ...@@ -28,12 +28,11 @@ QGCROOT = $$PWD
DebugBuild { DebugBuild {
DESTDIR = $${OUT_PWD}/debug DESTDIR = $${OUT_PWD}/debug
DEFINES += DEBUG DEFINES += DEBUG
DEFINES += ROS_BRIDGE_DEBUG #DEFINES += ROS_BRIDGE_DEBUG
#DEFINES += ROS_BRIDGE_CLIENT_DEBUG
} }
else { else {
DESTDIR = $${OUT_PWD}/release DESTDIR = $${OUT_PWD}/release
DEFINES += ROS_BRIDGE_DEBUG #DEFINES += ROS_BRIDGE_DEBUG
DEFINES += NDEBUG DEFINES += NDEBUG
} }
......
...@@ -122,10 +122,6 @@ void RosbridgeWsClient::run() ...@@ -122,10 +122,6 @@ void RosbridgeWsClient::run()
// ==================================================================================== // ====================================================================================
if ( std::chrono::high_resolution_clock::now() > poll_time_point) { if ( std::chrono::high_resolution_clock::now() > poll_time_point) {
poll_time_point = std::chrono::high_resolution_clock::now() + poll_interval; poll_time_point = std::chrono::high_resolution_clock::now() + poll_interval;
#ifdef ROS_BRIDGE_DEBUG
std::cout << "Starting new poll." << std::endl;
std::cout << "connected: " << this->isConnected->load() << std::endl;
#endif
std::string reset_status_task_name = "reset_status_task"; std::string reset_status_task_name = "reset_status_task";
// Add status task if necessary. // Add status task if necessary.
auto const it = std::find_if(task_list.begin(), task_list.end(), auto const it = std::find_if(task_list.begin(), task_list.end(),
...@@ -133,16 +129,10 @@ void RosbridgeWsClient::run() ...@@ -133,16 +129,10 @@ void RosbridgeWsClient::run()
return t.name == reset_status_task_name; return t.name == reset_status_task_name;
}); });
if ( it == task_list.end() ){ if ( it == task_list.end() ){
#ifdef ROS_BRIDGE_DEBUG
std::cout << "Adding status_task" << std::endl;
#endif
// Check connection status. // Check connection status.
auto status_set = std::make_shared<std::atomic_bool>(false); auto status_set = std::make_shared<std::atomic_bool>(false);
auto status_client = std::make_shared<WsClient>(this->server_port_path); auto status_client = std::make_shared<WsClient>(this->server_port_path);
status_client->on_open = [status_set, this](std::shared_ptr<WsClient::Connection>) { status_client->on_open = [status_set, this](std::shared_ptr<WsClient::Connection>) {
#ifdef ROS_BRIDGE_DEBUG
std::cout << "status_client opened" << std::endl;
#endif
this->isConnected->store(true); this->isConnected->store(true);
status_set->store(true); status_set->store(true);
}; };
...@@ -190,9 +180,6 @@ void RosbridgeWsClient::run() ...@@ -190,9 +180,6 @@ void RosbridgeWsClient::run()
}); });
if ( topics_it == task_list.end() ){ if ( topics_it == task_list.end() ){
// Call /rosapi/topics service. // Call /rosapi/topics service.
#ifdef ROS_BRIDGE_DEBUG
std::cout << "Adding reset_topics_task" << std::endl;
#endif
auto topics_set = std::make_shared<std::atomic_bool>(false); auto topics_set = std::make_shared<std::atomic_bool>(false);
this->callService("/rosapi/topics", [topics_set, this]( this->callService("/rosapi/topics", [topics_set, this](
std::shared_ptr<WsClient::Connection> connection, std::shared_ptr<WsClient::Connection> connection,
...@@ -238,9 +225,6 @@ void RosbridgeWsClient::run() ...@@ -238,9 +225,6 @@ void RosbridgeWsClient::run()
}); });
if ( services_it == task_list.end() ){ if ( services_it == task_list.end() ){
// Call /rosapi/services service. // Call /rosapi/services service.
#ifdef ROS_BRIDGE_DEBUG
std::cout << "Adding reset_services_task" << std::endl;
#endif
auto services_set = std::make_shared<std::atomic_bool>(false); auto services_set = std::make_shared<std::atomic_bool>(false);
this->callService("/rosapi/services", [this, services_set]( this->callService("/rosapi/services", [this, services_set](
std::shared_ptr<WsClient::Connection> connection, std::shared_ptr<WsClient::Connection> connection,
......
...@@ -19,11 +19,7 @@ std::size_t ros_bridge::com_private::getHash(const char *str) ...@@ -19,11 +19,7 @@ std::size_t ros_bridge::com_private::getHash(const char *str)
bool ros_bridge::com_private::getTopic(const ros_bridge::com_private::JsonDoc &doc, std::string &topic) bool ros_bridge::com_private::getTopic(const ros_bridge::com_private::JsonDoc &doc, std::string &topic)
{ {
if ( doc.HasMember("topic") && doc["topic"].IsString() ){ if ( doc.HasMember("topic") && doc["topic"].IsString() ){
topic = doc["topic"].GetString();
rapidjson::StringBuffer sb;
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
doc["topic"].Accept(writer);
topic = sb.GetString();
return true; return true;
} else } else
return false; return false;
...@@ -41,10 +37,7 @@ bool ros_bridge::com_private::removeTopic(ros_bridge::com_private::JsonDoc &doc) ...@@ -41,10 +37,7 @@ bool ros_bridge::com_private::removeTopic(ros_bridge::com_private::JsonDoc &doc)
bool ros_bridge::com_private::getType(const ros_bridge::com_private::JsonDoc &doc, std::string &type) bool ros_bridge::com_private::getType(const ros_bridge::com_private::JsonDoc &doc, std::string &type)
{ {
if ( doc.HasMember("type") && doc["type"].IsString() ){ if ( doc.HasMember("type") && doc["type"].IsString() ){
rapidjson::StringBuffer sb; type = doc["type"].GetString();
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
doc["type"].Accept(writer);
type = sb.GetString();
return true; return true;
} else } else
return false; return false;
......
...@@ -39,7 +39,17 @@ void ros_bridge::com_private::TopicPublisher::start() ...@@ -39,7 +39,17 @@ void ros_bridge::com_private::TopicPublisher::start()
std::string topic; std::string topic;
bool ret = com_private::getTopic(*pJsonDoc, topic); bool ret = com_private::getTopic(*pJsonDoc, topic);
assert(ret); assert(ret);
(void)ret; (void)ret;
// Debug
rapidjson::StringBuffer sb;
rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
pJsonDoc->Accept(writer);
std::cout << "message: " << sb.GetString() << std::endl;
std::cout << "topic: " << topic << std::endl;
ret = com_private::removeTopic(*pJsonDoc); ret = com_private::removeTopic(*pJsonDoc);
assert(ret); assert(ret);
(void)ret; (void)ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment