Skip to content

BT XML exporter generates only the rightmost element when reactive nodes have the same parent

When two or more reactive control flow nodes (sequence and fallback) have the same parent node, the BT exporter generates only the rightmost branch.

Here's an example with 2 reactive sequence nodes that have the same parent. In this case the parent is a reactive fallback, but this happens for any supported node type, i.e., when the parent is a sequence/fallback wh or wo memory, a parallel node, etc.

20250326-test_model_for_wrong_xml_gen_wh_some_control_nodes.png

The generated XML is:

<?xml version="1.0" encoding="ASCII"?>
<root main_tree_to_execute="Test">
  <BehaviorTree ID="Test">
    <ReactiveFallback name="RFallback">
      <ReactiveSequence name="RSequence2">
        <Condition name="Cond2" ID="TestCondition"/>
        <Action name="Action2" ID="TestAction"/>
      </ReactiveSequence>
    </ReactiveFallback>
  </BehaviorTree>
</root>

Note that the exporter traverses the tree correctly and both the reactive sequences are accessed, though only the rightmost one is finally wrote down in the XML file:

Transformation begins...
* Generating RootType (root element) in the destination model...
Done.
* going to add nodes to BehaviorTreeType 'Test' ...
adding node RFallback
  adding node RSequence1
    adding node TestCondition
    adding node TestAction
  adding node RSequence2
    adding node TestCondition
    adding node TestAction
Transformation ends.