Skip to content

Commit

Permalink
revert API change
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Nov 17, 2023
1 parent b89dc19 commit ebb835c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class RosTopicSubNode : public BT::ConditionNode
*
* @return the new status of the Node, based on last_msg
*/
virtual NodeStatus onTick(const std::shared_ptr<TopicT> last_msg) = 0;
virtual NodeStatus onTick(const std::shared_ptr<TopicT>& last_msg) = 0;

private:

Expand Down
2 changes: 1 addition & 1 deletion btcpp_ros2_interfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ rosidl_generate_interfaces(btcpp_ros2_interfaces
"action/Sleep.action")

ament_export_dependencies(rosidl_default_runtime)
ament_package()
ament_package()
18 changes: 11 additions & 7 deletions btcpp_ros2_samples/src/subscriber_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ReceiveString: public RosTopicSubNode<std_msgs::msg::String>
{
if(last_msg) // empty if no new message received, since the last tick
{
RCLCPP_INFO(logger(), "New message: %s", last_msg->data.c_str());
RCLCPP_INFO(logger(), "[%s] new message: %s", name().c_str(), last_msg->data.c_str());
}
return NodeStatus::SUCCESS;
}
Expand All @@ -32,9 +32,9 @@ class ReceiveString: public RosTopicSubNode<std_msgs::msg::String>
<root BTCPP_format="4">
<BehaviorTree>
<Sequence>
<ReceiveString/>
<ReceiveString/>
<ReceiveString/>
<ReceiveString name="A"/>
<ReceiveString name="B"/>
<ReceiveString name="C"/>
</Sequence>
</BehaviorTree>
</root>
Expand All @@ -52,11 +52,15 @@ int main(int argc, char **argv)
params.default_port_value = "btcpp_string";
factory.registerNodeType<ReceiveString>("ReceiveString", params);

auto tree = factory.createTreeFromText(xml_text);

while(rclcpp::ok())
{
tree.tickWhileRunning();
auto tree = factory.createTreeFromText(xml_text);
for(int i=0; i<10; i++)
{
tree.tickWhileRunning();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

return 0;
Expand Down

0 comments on commit ebb835c

Please sign in to comment.