Skip to content

Commit

Permalink
(roseus_bt) Use CopyDocument in remote subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
Affonso-Gui committed Oct 23, 2022
1 parent 87f0415 commit 57264d5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions roseus_bt/include/roseus_bt/eus_remote_subscriber_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <behaviortree_cpp_v3/action_node.h>
#include <behaviortree_cpp_v3/bt_factory.h>
#include <roseus_bt/ws_subscriber_client.h>
#include <roseus_bt/copy_document.h>

namespace BT
{
Expand Down Expand Up @@ -34,7 +35,7 @@ class EusRemoteSubscriberNode: public BT::ActionNodeBase
static PortsList providedPorts() {
return {
InputPort<std::string>("topic_name", "name of the subscribed topic"),
OutputPort<std::string>("output_port", "port to where messages are redirected"),
OutputPort<rapidjson::CopyDocument>("output_port", "port to where messages are redirected"),
OutputPort<uint8_t>("received_port", "port set to true every time a message is received"),
InputPort<std::string>("host_name", "name of the rosbridge_server host"),
InputPort<int>("host_port", "port of the rosbridge_server host")
Expand Down Expand Up @@ -76,12 +77,9 @@ class EusRemoteSubscriberNode: public BT::ActionNodeBase

void setOutputFromMessage(const std::string& name, const rapidjson::Value& message)
{
rapidjson::StringBuffer strbuf;
rapidjson::Writer<rapidjson::StringBuffer> writer(strbuf);
rapidjson::Document document;
rapidjson::CopyDocument document;
document.CopyFrom(message, document.GetAllocator());
document.Accept(writer);
setOutput(name, strbuf.GetString());
setOutput(name, document);
}
};

Expand Down

0 comments on commit 57264d5

Please sign in to comment.