@@ -645,7 +645,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
645
645
const auto element_name = element->Name ();
646
646
const auto element_ID = element->Attribute (" ID" );
647
647
648
- // TODO: Pull out this node type logic
649
648
auto node_type = convertFromString<NodeType>(element_name);
650
649
// name used by the factory
651
650
std::string type_ID;
@@ -690,8 +689,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
690
689
691
690
PortsRemapping port_remap;
692
691
NonPortAttributes other_attributes;
693
- // Only relevant for subtrees
694
- bool do_autoremap = false ;
695
692
696
693
// Parse ports and validate them where we can.
697
694
for (const XMLAttribute* att = element->FirstAttribute (); att; att = att->Next ())
@@ -739,16 +736,22 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
739
736
740
737
port_remap[port_name] = port_value;
741
738
}
742
- else if (node_type == NodeType::SUBTREE && port_name == " _autoremap" )
743
- {
744
- do_autoremap = convertFromString<bool >(port_value);
745
- }
746
739
else if (!IsReservedAttribute (port_name))
747
740
{
748
741
other_attributes[port_name] = port_value;
749
742
}
750
743
}
751
744
745
+ bool do_autoremap = false ;
746
+ if (node_type == NodeType::SUBTREE)
747
+ {
748
+ const XMLAttribute* auto_remap_ptr = element->FindAttribute (" _autoremap" );
749
+ if (auto_remap_ptr != nullptr )
750
+ {
751
+ do_autoremap = convertFromString<bool >(auto_remap_ptr->Value ());
752
+ }
753
+ }
754
+
752
755
NodeConfig config;
753
756
config.blackboard = blackboard;
754
757
config.path = prefix_path + instance_name;
@@ -784,7 +787,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
784
787
// ---------------------------------------------
785
788
TreeNode::Ptr new_node;
786
789
787
- // TODO: in order to set the config at this point, we need the subtree model, which is parsed after this function call in recursivelyCreateSubtree
788
790
if (node_type == NodeType::SUBTREE)
789
791
{
790
792
// check if this subtree has a model. If it does,
@@ -818,7 +820,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
818
820
// populate the node config
819
821
for (const auto & [port_name, port_value] : port_remap)
820
822
{
821
- PortDirection direction = PortDirection::INPUT;
823
+ auto direction = PortDirection::INPUT;
822
824
if (subtree_model_it != subtree_models.end ())
823
825
{
824
826
const PortsList& subtree_model_ports = subtree_model_it->second .ports ;
@@ -1019,7 +1021,7 @@ void BT::XMLParser::PImpl::recursivelyCreateSubtree(const std::string& tree_ID,
1019
1021
1020
1022
// Populate the subtree's blackboard with it's port values.
1021
1023
PortsRemapping subtree_remapping = const_node->config ().input_ports ;
1022
- const PortsRemapping output_ports = const_node->config ().output_ports ;
1024
+ const PortsRemapping& output_ports = const_node->config ().output_ports ;
1023
1025
subtree_remapping.insert (output_ports.begin (), output_ports.end ());
1024
1026
for (const auto & [port_name, port_value] : subtree_remapping)
1025
1027
{
0 commit comments