@@ -639,7 +639,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
639639 const auto element_name = element->Name ();
640640 const auto element_ID = element->Attribute (" ID" );
641641
642- // TODO: Pull out this node type logic
643642 auto node_type = convertFromString<NodeType>(element_name);
644643 // name used by the factory
645644 std::string type_ID;
@@ -684,8 +683,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
684683
685684 PortsRemapping port_remap;
686685 NonPortAttributes other_attributes;
687- // Only relevant for subtrees
688- bool do_autoremap = false ;
689686
690687 // Parse ports and validate them where we can.
691688 for (const XMLAttribute* att = element->FirstAttribute (); att; att = att->Next ())
@@ -733,16 +730,22 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
733730
734731 port_remap[port_name] = port_value;
735732 }
736- else if (node_type == NodeType::SUBTREE && port_name == " _autoremap" )
737- {
738- do_autoremap = convertFromString<bool >(port_value);
739- }
740733 else if (!IsReservedAttribute (port_name))
741734 {
742735 other_attributes[port_name] = port_value;
743736 }
744737 }
745738
739+ bool do_autoremap = false ;
740+ if (node_type == NodeType::SUBTREE)
741+ {
742+ const XMLAttribute* auto_remap_ptr = element->FindAttribute (" _autoremap" );
743+ if (auto_remap_ptr != nullptr )
744+ {
745+ do_autoremap = convertFromString<bool >(auto_remap_ptr->Value ());
746+ }
747+ }
748+
746749 NodeConfig config;
747750 config.blackboard = blackboard;
748751 config.path = prefix_path + instance_name;
@@ -778,7 +781,6 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
778781 // ---------------------------------------------
779782 TreeNode::Ptr new_node;
780783
781- // TODO: in order to set the config at this point, we need the subtree model, which is parsed after this function call in recursivelyCreateSubtree
782784 if (node_type == NodeType::SUBTREE)
783785 {
784786 // check if this subtree has a model. If it does,
@@ -812,7 +814,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
812814 // populate the node config
813815 for (const auto & [port_name, port_value] : port_remap)
814816 {
815- PortDirection direction = PortDirection::INPUT;
817+ auto direction = PortDirection::INPUT;
816818 if (subtree_model_it != subtree_models.end ())
817819 {
818820 const PortsList& subtree_model_ports = subtree_model_it->second .ports ;
@@ -1013,7 +1015,7 @@ void BT::XMLParser::PImpl::recursivelyCreateSubtree(const std::string& tree_ID,
10131015
10141016 // Populate the subtree's blackboard with it's port values.
10151017 PortsRemapping subtree_remapping = const_node->config ().input_ports ;
1016- const PortsRemapping output_ports = const_node->config ().output_ports ;
1018+ const PortsRemapping& output_ports = const_node->config ().output_ports ;
10171019 subtree_remapping.insert (output_ports.begin (), output_ports.end ());
10181020 for (const auto & [port_name, port_value] : subtree_remapping)
10191021 {
0 commit comments