BehaviorTree/Groot2

Inconsistent ordering of attributes in XML output

Opened this issue · 3 comments

Is your feature request related to a problem? Please describe.
This is probably less a bug than a feature request: It seems currently the XML that Groot2 saves has very inconsistent ordering of attributes of XML tags. That means if you save XML with Groot2 and then after some edits save again it mixes up the order of attributes in otherwise unchanged elements. If you track your XML in a versioning system this generates much more than the necessary changes which is very annoying.

I didn't find a real pattern when and where it happens, so I can't give a minimal reproducing example. But with my projects it happens basically with every edit & save.

Describe the solution you'd like
Groot2 should not change XML that has not been modified. It could e.g. preserve the order in which the attributes have been added. Or I would also be okay if it just enforced an ordering in the XML output (e.g. alphabetically).

Yes, and the same weird ordering is show in the GUI:

image

i would expect something like grouping IN/OUT keys, or better respect the order provided by the user.

Can you provide your TreeNodesModel XML files

Can you provide your TreeNodesModel XML files

In my case I create the TreeNodesModel XML file by dumping the bt_factory with writeTreeNodesModelXML. So in the node I showed as example, it looks like:

        <Action ID="SelectNextTarget">
            <output_port name="tightening" type="float"/>
            <input_port name="failures" type="std::map&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, unsigned int, std::less&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const, unsigned int&gt; &gt; &gt;"/>
            <output_port name="target_name" type="std::string"/>
            <input_port name="objects" type="std::vector&lt;moveit_msgs::CollisionObject_&lt;std::allocator&lt;void&gt; &gt;, std::allocator&lt;moveit_msgs::CollisionObject_&lt;std::allocator&lt;void&gt; &gt; &gt; &gt;"/>
        </Action>

But in providedPorts I have a different ordering, more meaningful to me:

  static BT::PortsList providedPorts()
  {
    return { BT::InputPort<std::vector<Object>>("objects"),               //
             BT::InputPort<std::map<std::string, uint32_t>>("failures"),  //
             BT::OutputPort<std::string>("target_name"),                  //
             BT::OutputPort<float>("tightening") };
  }

To me the expected behavior is that writeTreeNodesModelXML dumps ports in the same order as listed in providedPorts.