Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 222384b

Browse files
committed
change getPortAny name and fic loop_node
1 parent bbd2576 commit 222384b

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

include/behaviortree_cpp/decorators/loop_node.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ class LoopPopNode : public DecoratorNode
7171
{
7272
// if the port is static, any_ref is empty, otherwise it will keep access to
7373
// port locked for thread-safety
74-
AnyWriteRef any_ref = static_queue_ ? AnyWriteRef() : getPortAny("queue");
74+
AnyWriteRef any_ref = static_queue_ ?
75+
AnyWriteRef() :
76+
getLockedPortContent("queue");
7577
if(any_ref)
7678
{
7779
current_queue_ = any_ref.get()->cast<SharedQueue<T>>();
@@ -98,6 +100,11 @@ class LoopPopNode : public DecoratorNode
98100
NodeStatus child_state = child_node_->executeTick();
99101
child_running_ = (child_state == NodeStatus::RUNNING);
100102

103+
if(isStatusCompleted(child_state))
104+
{
105+
resetChild();
106+
}
107+
101108
if(child_state == NodeStatus::FAILURE)
102109
{
103110
return NodeStatus::FAILURE;

include/behaviortree_cpp/tree_node.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class TreeNode
241241
Result setOutput(const std::string& key, const T& value);
242242

243243
/**
244-
* @brief getPortAny should be used when:
244+
* @brief getLockedPortContent should be used when:
245245
*
246246
* - your port contains an object with reference semantic (usually a smart pointer)
247247
* - you want to modify the object we are pointing to.
@@ -255,7 +255,7 @@ class TreeNode
255255
*
256256
* What you must do, instead, to guaranty thread-safety, is:
257257
*
258-
* if(auto any_ref = getPortAny("port_name")) {
258+
* if(auto any_ref = getLockedPortContent("port_name")) {
259259
* Any* any = any_ref.get();
260260
* auto foo_ptr = any->cast<std::shared_ptr<Foo>>();
261261
* // modifying the content of foo_ptr inside this scope IS thread-safe
@@ -270,7 +270,7 @@ class TreeNode
270270
* @return empty AnyWriteRef if the blackboard entry doesn't exist or the content
271271
* of the port was a static string.
272272
*/
273-
AnyWriteRef getPortAny(const std::string& key);
273+
AnyWriteRef getLockedPortContent(const std::string& key);
274274

275275
// function provided mostly for debugging purpose to see the raw value
276276
// in the port (no remapping and no conversion to a type)

src/tree_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ std::string toStr<PostCond>(PostCond pre)
411411
}
412412
}
413413

414-
AnyWriteRef BT::TreeNode::getPortAny(const std::string &key)
414+
AnyWriteRef BT::TreeNode::getLockedPortContent(const std::string &key)
415415
{
416416
if(auto remapped_key = getRemappedKey(key, getRawPortValue(key)))
417417
{

0 commit comments

Comments
 (0)