Fix/prevent warning when loading bt#5494
Conversation
|
@Jad-ELHAJJ, your PR has failed to build. Please check CI outputs and resolve issues. |
1 similar comment
|
@Jad-ELHAJJ, your PR has failed to build. Please check CI outputs and resolve issues. |
|
This causes all of the tests related to this test to fail, including system tests which are the stack functioning. Did you test your changes locally before pushing? Using CI to test changes isn't good practice 😄 Linking the issue report comment: #5494 (comment) |
|
@claude review the PR |
|
They all still fail, please look into that :-) |
Yes, I am aware of that. I am still investigating the issue. Once its ready to review I will let you know. Thanks! |
|
@Jad-ELHAJJ, your PR has failed to build. Please check CI outputs and resolve issues. |
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
|
I can actually see the warnings in the latest commit To reproduce, launch |
|
@Jad-ELHAJJ can you verify and let me know if you see this as well still locally too? |
As mentioned in the comment above, we settled on letting the user use either file or ID. And in the case of file, the user will get a warning. |
|
I thought that was only if they had the same ID, not for all tree files. Can you clarify? If just the same ID - @mini-1235 just needs to update the tree IDs to be unique |
|
I am not sure what those warnings mean, but I think they shouldn't show up when launching nav2's default bringup (tb3,tb4) |
|
I agree, the point of this PR was to remove that. If that's still happening for the default Nav2 bringup with the default Nav2 trees which have that ID set as unique for each tree, this feature may need to be reverted. |
|
Let me clarify. This warning has showed up after adding an important feature to the BT “support subtrees”. Briefly, loading a behavior tree that includes a subtree requires registering, beforehand, all the trees that are used as subtrees in the loaded main tree, therefore the usage of registerTreeFromFile before createTreeFromFile. When these two functions get called sequently, BTCPP logs a warning, but the functionality will still be the same. But in any way, in order to skip that warning, the good approach is to use registerTreeFromFile and createTree. CreateTree function takes as input the BT ID not the file path. And in this feature we also supported ID as behavior tree in the interface not only file path. So, the best practice is to have unique BT IDs and pass to the loadBehaviorTree the ID instead of the file path. But, Steve requested to still support file path in order to not break user’s work. We also added docs to the migration guide that highlights that change. |
* Added BT ID finder and used createTree to resolve btcpp warning Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Support using either bt file path or bt id Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Not necessarily a file name Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fix logic Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fix function definition Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed unit test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed BB variable Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed error msg Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed variable and its getter naming Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed definition Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fix xml check Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fix bt unit test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * added back test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * check bt id using the root or bt id Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * using tinyxml2 instead of regex Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed var name Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed var name Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * check if arg is already a BT ID Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * check if arg is already a BT ID Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Test was failing due to same BT ID MainTree among all registred trees Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Fixed error msg to be compliant Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * python linting Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Removed unused createTreeFromFile since its replaced with createTree Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * PR fixes Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Added new line at the end of BT xml Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Should cover most of the cases Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * format Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Fixed BT format Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Removed redundant check Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Allow usage of file paths with a warning, while keeping BT ID usage as the recommended option Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Additional test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Test coverage Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> --------- Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
|
A fix PR will be open soon to refactor that, making sure that BTCPP warning would never be logged. The final logic will be:
|
I believe I've mentioned in other reviews that I do not believe this is necessarily best practice and we will need to support both as first-class non-error-causing citizens :-) If folks want to use files, they should be able to. Complaining about non-unique names I think is OK as a nudge for migration, but there shouldn't be loading errors. We highlighted that this is a new feature that is supported, not that you must migrate to using ID-based requests.I believe my review comments and request to remove certain error messages from previous versions reflects that intent. I think your new PR points make sense. When can we expect that? |
There you go :-) #5594 |
* Added BT ID finder and used createTree to resolve btcpp warning Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Support using either bt file path or bt id Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Not necessarily a file name Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fix logic Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fix function definition Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed unit test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed BB variable Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed error msg Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed variable and its getter naming Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed definition Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fix xml check Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fix bt unit test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * added back test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * check bt id using the root or bt id Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * using tinyxml2 instead of regex Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed var name Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * fixed var name Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * check if arg is already a BT ID Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * check if arg is already a BT ID Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Test was failing due to same BT ID MainTree among all registred trees Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Fixed error msg to be compliant Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * python linting Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Removed unused createTreeFromFile since its replaced with createTree Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * PR fixes Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Added new line at the end of BT xml Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Should cover most of the cases Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * format Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Fixed BT format Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Removed redundant check Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Allow usage of file paths with a warning, while keeping BT ID usage as the recommended option Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Additional test Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> * Test coverage Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai> --------- Signed-off-by: Jad El Hajj <jad.elhajj@inmind.ai>
|
Hi, I have checked all Subtrees have unique IDs, and my xml file also uses I must also say that the migration guide is really unclear. I thought it is just a new option to load BTs from different directories, but actually one must rename all the BT IDs and add a new param |
Interesting. This works correctly when they are in different files, correct? I can see that it may be due to extracting the BT IDs from the XMLs in @Jad-ELHAJJ thoughts?
I'd appreciate an update to the docs to make it more clear -- I don't have the best sense of what's not clear to you, so you're in a good position to clarify for the next reader :-) The renaming of the IDs is a pain, but only if you want to use the IDs. I asked @Jad-ELHAJJ to make sure that you could use it with filenames instead without that and that should work... From the current version of the branch, on first glance it seems like it should work even if you gave the bt_search_directories a bogus path. It'll try to load those but your main XML provided in the action is loaded separately |
Sure, I can do that, though let's solve the loading issue first.
Oh, is it? I got a lot of warnings about duplicated IDs, so I assume it was a must (I did try with my xml but that has the subTree issue. I didn't try with another xml) |
|
I think the duplicate tree IDs should be fine even with warnings as long as you use the file path (not sure though if you include subtrees). Is what you're trying still using subtrees or no? |
|
It did have subTrees, but it was running the other file completely. |
|
Yes please. Please also tag @Jad-ELHAJJ in that. Do you see how a completely different file runs when conflicting names? It seems like from my reading of the code that should work correctly |
|
@adivardi can you also provide a reproducible test case? If the author doesn't reply, I can go ahead and fix this in a few days |
@adivardi any updates? 😄 |
Sorry, quite busy few days. For the subTree issue, simply extract a subtree from one of the default BT xml. Then you will get errors immediately when launching nav2: Regarding the second issue of having to rename all BT, I think you can very quickly test that by undoing the change in this PR (renaming all BTs from |
|
Thanks! Please file a ticket when you have time Just to make sure I understand correctly: does issue 2 only cause problems when a subtree is used, or does it also happen even without any subtrees? |
That's the part I didn't have time to double-check yet. I will try it out and update (probably tomorrow) |
|
@mini-1235 I also opened an issue f: |
|
Thanks, I will follow up in the corresponding ticket |
|
Thanks! |
Basic Info
Description of contribution in a few bullet points
This PR resolves the BTCPP warning that is logged when
loadBehaviorTree()callscreateTreeFromFile()immediately afterregisterTreeFromFile()The updated approach ensures that
createTree()is called directly afterregisterTreeFromFile()when appropriate, thereby eliminating the warning.To support this, a small interface change was introduced:
For Maintainers:
backport-*.