-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BTActionServer always loads behavior tree XML files from text, which breaks relative includes in the XML #3210
Comments
I defer to @facontidavide as to which he feels is best practice. It matters not to me, though sounds like this is a topic that might be worthy of a ticket in BT.CPP. |
feel free to move this question to BT.CPP repo |
I don't have those permissions on your side. @skyler237 please reopen ticket on BT.CPP and tag me so I can track the conversation / follow up as necessary 😄 |
Part of this question may be better suited for discussion in BT.CPP, but one point @skyler237 made was that bt_->createTreeFromText() is used in bt_action_server_imp.hpp rather than bt_->createTreeFromFile(). Since bt_action_server_imp.hpp belongs to nav2, I think it is still appropriate to discuss here whether there is any reason to continue using the createTreeFromText() method rather than the createTreeFromFile(), since switching to the latter may resolve this issue. |
I simply deferred to Davide, but I have no issue w.r.t. moving to I'd be happy to field a PR along those lines if that seems reasonable to everyone 👍 |
@mradams-bastian want to open a PR? |
Yah, I can do that here soon |
👀 |
Soooo. This gives you more control and will work with both Text and Files. If you have any problem and something doesn't work as advertized, let me know |
@facontidavide is there any downside of us moving to using |
If it works for you, I don't have a technical preference. |
OK - sounds like the answer is to use BT.CPP best practices + the update in #3306 to close this ticket. Waiting on CI and will close once complete. |
Thanks @SteveMacenski for taking care of that and sorry for not having done it myself yet. In response to using the recommended method for registering subtrees, it seems like the registerBehaviorTreeFromFile() followed by createTree() methods used in the tutorial would replace the createTreeFromFile() method we will be using once this is merged. To enable users to register their own subtrees and not have to use "include" we would have to refactor loadBehaviorTree() such that it accepts a list of "bt_xml_filename" strings rather than a single string. We could open a new thread for this, but I'd say we run with these latest changes/the "include" method of specifying subtrees for now and see if everything works out fine with it |
This isn't a problem I've run into before, so if you open a PR to make the changes as required for your application, I'd be happy to take a look and merge them. I don't really see why you'd need multiple strings though, I don't think making the BT from file even takes multiple filepath strings as an argument. |
In the tutorial linked by @facontidavide, registerBehaviorTreeFromFile() is called multiple times with different filepaths (each representing a different subtree) before createTree() is called. But in short, if the changes you just made resolve the issue I was experiencing, and everyone else is happy with how it is, I will not worry about any of that. |
The XMLParser in the BehaviorTree.CPP can load a behavior tree from text or from file. When the behavior tree is loaded from a file, the parent path of the file is used as the current path for including other subtrees with relative paths. When the behavior tree is loaded from text, the current working directory is used as the parent path for relative includes, which is unreliable.
The BT Action Server always reads the xml file into a string, then loads the behavior tree from text, which breaks the ability to do reliable relative includes. Is there a good reason that behavior tree XML files are always loaded from text?
https://github.com/ros-planning/navigation2/blob/664c09f6d4dfd769592b2611a1461c9acf26b1f8/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_server_impl.hpp#L179
Another workaround here is to use the "ros_pkg" attribute in the xml "include" tag, but when I use this on Galactic, I get the error saying that the behavior tree library was not compile for ROS support. In the behavior tree CMakeList.txt, it is checking if catkin/ament were used to build the package and sets the appropriate #define values accordingly. Is there a way for that library to be built with ament_cmake?
The text was updated successfully, but these errors were encountered: