Skip to content

Commit 01e7f59

Browse files
Merge pull request #691 from galou/small_refactor_and_doc
Small code refactor, log- and doc changes
2 parents 7d8e17d + 813fe40 commit 01e7f59

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

examples/t04_reactive_sequence.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ int main()
6161
factory.registerNodeType<SaySomething>("SaySomething");
6262

6363
// Compare the state transitions and messages using either
64-
// xml_text_sequence and xml_text_sequence_star
64+
// xml_text_sequence and xml_text_reactive.
6565

6666
// The main difference that you should notice is:
67-
// 1) When Sequence is used, BatteryOK is executed at __each__ tick()
68-
// 2) When SequenceStar is used, those ConditionNodes are executed only __once__.
67+
// 1) When Sequence is used, the ConditionNode is executed only __once__ because it returns SUCCESS.
68+
// 2) When ReaciveSequence is used, BatteryOK is executed at __each__ tick()
6969

7070
for (auto& xml_text : {xml_text_sequence, xml_text_reactive})
7171
{

include/behaviortree_cpp/controls/parallel_node.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class ParallelNode : public ControlNode
4747
static PortsList providedPorts()
4848
{
4949
return {InputPort<int>(THRESHOLD_SUCCESS, -1,
50-
"number of children which need to succeed to trigger a "
50+
"number of children that need to succeed to trigger a "
5151
"SUCCESS"),
5252
InputPort<int>(THRESHOLD_FAILURE, 1,
53-
"number of children which need to fail to trigger a FAILURE")};
53+
"number of children that need to fail to trigger a FAILURE")};
5454
}
5555

5656
~ParallelNode() override = default;

src/xml_parsing.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
558558
const std::string& prefix_path,
559559
Tree& output_tree)
560560
{
561-
auto element_name = element->Name();
562-
auto element_ID = element->Attribute("ID");
561+
const auto element_name = element->Name();
562+
const auto element_ID = element->Attribute("ID");
563563

564564
auto node_type = convertFromString<NodeType>(element_name);
565565
// name used by the factory
@@ -593,7 +593,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
593593
// By default, the instance name is equal to ID, unless the
594594
// attribute [name] is present.
595595
const char* attr_name = element->Attribute("name");
596-
std::string instance_name = attr_name ? attr_name : type_ID;
596+
const std::string instance_name = (attr_name != nullptr) ? attr_name : type_ID;
597597

598598
const TreeNodeManifest* manifest = nullptr;
599599

@@ -663,13 +663,13 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
663663
}
664664

665665
//Check that name in remapping can be found in the manifest
666-
for (const auto& remap_it : port_remap)
666+
for (const auto& [name_in_subtree, _] : port_remap)
667667
{
668-
if (manifest->ports.count(remap_it.first) == 0)
668+
if (manifest->ports.count(name_in_subtree) == 0)
669669
{
670670
throw RuntimeError("Possible typo? In the XML, you tried to remap port \"",
671-
remap_it.first, "\" in node [", type_ID, " / ", instance_name,
672-
"], but the manifest of this node does not contain a port "
671+
name_in_subtree, "\" in node [", config.path, "(type ", type_ID,
672+
")], but the manifest of this node does not contain a port "
673673
"with this name.");
674674
}
675675
}
@@ -760,13 +760,13 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
760760
}
761761

762762
// add the pointer of this node to the parent
763-
if (node_parent)
763+
if (node_parent != nullptr)
764764
{
765765
if (auto control_parent = dynamic_cast<ControlNode*>(node_parent.get()))
766766
{
767767
control_parent->addChild(new_node.get());
768768
}
769-
if (auto decorator_parent = dynamic_cast<DecoratorNode*>(node_parent.get()))
769+
else if (auto decorator_parent = dynamic_cast<DecoratorNode*>(node_parent.get()))
770770
{
771771
decorator_parent->setChild(new_node.get());
772772
}

0 commit comments

Comments
 (0)