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 6fcf2b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions roseus_bt/include/roseus_bt/eus_remote_action_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ class EusRemoteActionNode : public BT::ActionNodeBase
}

// port related
// TODO: avoid unnecessary dumping & parsing
// cannot use rapidjson::Value directly because it is not `CopyConstructible'
// TODO: translate to ROS message: how to loop through slots?

void feedbackCallback(std::shared_ptr<WsClient::Connection> connection,
Expand Down
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 6fcf2b7

Please sign in to comment.