Skip to content

Commit

Permalink
(roseus_bt) Initialize subscriber ports
Browse files Browse the repository at this point in the history
  • Loading branch information
Affonso-Gui committed Oct 26, 2022
1 parent 327c0b6 commit 2191a65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion roseus_bt/include/roseus_bt/eus_remote_subscriber_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class EusRemoteSubscriberNode: public BT::ActionNodeBase
getInput<std::string>("topic_name").value(),
getInput<std::string>("message_type").value())
{
setOutput<uint8_t>("received_port", false);
setOutput<rapidjson::CopyDocument>("output_port",
rapidjson::CopyDocument(rapidjson::kObjectType));
auto cb = std::bind(&EusRemoteSubscriberNode::topicCallback, this,
std::placeholders::_1,
std::placeholders::_2);
Expand Down Expand Up @@ -59,7 +62,7 @@ class EusRemoteSubscriberNode: public BT::ActionNodeBase
protected:
virtual void callback(const rapidjson::Value& msg) {
setOutputFromMessage("output_port", msg);
setOutput("received_port", (uint8_t)true);
setOutput<uint8_t>("received_port", true);
}

void topicCallback(std::shared_ptr<WsClient::Connection> connection, std::shared_ptr<WsClient::InMessage> in_message)
Expand Down
4 changes: 3 additions & 1 deletion roseus_bt/include/roseus_bt/eus_subscriber_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class EusSubscriberNode: public BT::ActionNodeBase
EusSubscriberNode(ros::NodeHandle& nh, const std::string& name, const BT::NodeConfiguration& conf):
BT::ActionNodeBase(name, conf), node_(nh)
{
setOutput<uint8_t>("received_port", false);
setOutput<MessageT>("output_port", MessageT());
const std::string topic_name = getInput<std::string>("topic_name").value();
sub_ = node_.subscribe(topic_name, 1000, &EusSubscriberNode::callback, this);
}
Expand Down Expand Up @@ -48,7 +50,7 @@ class EusSubscriberNode: public BT::ActionNodeBase
protected:
virtual void callback(MessageT msg) {
setOutput("output_port", msg);
setOutput("received_port", (uint8_t)true);
setOutput<uint8_t>("received_port", true);
}

};
Expand Down

0 comments on commit 2191a65

Please sign in to comment.