Skip to content

Commit ebb835c

Browse files
committed
revert API change
1 parent b89dc19 commit ebb835c

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

behaviortree_ros2/include/behaviortree_ros2/bt_topic_sub_node.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class RosTopicSubNode : public BT::ConditionNode
154154
*
155155
* @return the new status of the Node, based on last_msg
156156
*/
157-
virtual NodeStatus onTick(const std::shared_ptr<TopicT> last_msg) = 0;
157+
virtual NodeStatus onTick(const std::shared_ptr<TopicT>& last_msg) = 0;
158158

159159
private:
160160

btcpp_ros2_interfaces/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ rosidl_generate_interfaces(btcpp_ros2_interfaces
1111
"action/Sleep.action")
1212

1313
ament_export_dependencies(rosidl_default_runtime)
14-
ament_package()
14+
ament_package()

btcpp_ros2_samples/src/subscriber_test.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ReceiveString: public RosTopicSubNode<std_msgs::msg::String>
2121
{
2222
if(last_msg) // empty if no new message received, since the last tick
2323
{
24-
RCLCPP_INFO(logger(), "New message: %s", last_msg->data.c_str());
24+
RCLCPP_INFO(logger(), "[%s] new message: %s", name().c_str(), last_msg->data.c_str());
2525
}
2626
return NodeStatus::SUCCESS;
2727
}
@@ -32,9 +32,9 @@ class ReceiveString: public RosTopicSubNode<std_msgs::msg::String>
3232
<root BTCPP_format="4">
3333
<BehaviorTree>
3434
<Sequence>
35-
<ReceiveString/>
36-
<ReceiveString/>
37-
<ReceiveString/>
35+
<ReceiveString name="A"/>
36+
<ReceiveString name="B"/>
37+
<ReceiveString name="C"/>
3838
</Sequence>
3939
</BehaviorTree>
4040
</root>
@@ -52,11 +52,15 @@ int main(int argc, char **argv)
5252
params.default_port_value = "btcpp_string";
5353
factory.registerNodeType<ReceiveString>("ReceiveString", params);
5454

55-
auto tree = factory.createTreeFromText(xml_text);
56-
5755
while(rclcpp::ok())
5856
{
59-
tree.tickWhileRunning();
57+
auto tree = factory.createTreeFromText(xml_text);
58+
for(int i=0; i<10; i++)
59+
{
60+
tree.tickWhileRunning();
61+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
62+
}
63+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
6064
}
6165

6266
return 0;

0 commit comments

Comments
 (0)