-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[behavior_tree] Add generate_nav2_tree_nodes_xml #4073
Merged
SteveMacenski
merged 7 commits into
ros-navigation:main
from
facontidavide:behaviortree/generate_xml
Feb 20, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a6bcb34
Add generate_nav2_tree_nodes_xml
facontidavide c8b4eb5
behavior_tree: removed list of plugins from yaml
facontidavide 216b0ba
Merge branch 'main' into behaviortree/generate_xml
facontidavide d0e6c33
check result of get_parameter(plugin_lib_names)
facontidavide 38cdd40
fix previous commit (uncrustify)
facontidavide 148d68b
Merge branch 'ros-planning:main' into behaviortree/generate_xml
facontidavide a6325e5
revert change
facontidavide File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
// This was automativally generated by cmake | ||
namespace nav2::details | ||
{ | ||
const char* BT_BUILTIN_PLUGINS = "@plugin_libs@"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) 2024 Davide Faconti | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. Reserved. | ||
|
||
#include <vector> | ||
#include <string> | ||
#include <fstream> | ||
#include <boost/algorithm/string.hpp> | ||
|
||
#include "behaviortree_cpp_v3/behavior_tree.h" | ||
#include "behaviortree_cpp_v3/bt_factory.h" | ||
#include "behaviortree_cpp_v3/utils/shared_library.h" | ||
#include "behaviortree_cpp_v3/xml_parsing.h" | ||
|
||
#include "plugins_list.hpp" | ||
|
||
int main() | ||
{ | ||
BT::BehaviorTreeFactory factory; | ||
|
||
std::vector<std::string> plugins_list; | ||
boost::split(plugins_list, nav2::details::BT_BUILTIN_PLUGINS, boost::is_any_of(";")); | ||
|
||
for (const auto & plugin : plugins_list) { | ||
std::cout << "Loading: " << plugin << "\n"; | ||
factory.registerFromPlugin(BT::SharedLibrary::getOSName(plugin)); | ||
} | ||
std::cout << "\nGenerating file: nav2_tree_nodes.xml\n" | ||
<< "\nCompare it with the one in the git repo and update the latter if necessary.\n"; | ||
|
||
std::ofstream xml_file; | ||
xml_file.open("nav2_tree_nodes.xml"); | ||
xml_file << BT::writeTreeNodesModelXML(factory) << std::endl; | ||
xml_file.close(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is automatically executed on build? The quick look at
configure_file
doesn't make me think i does, but I assume it does or else this workflow would add extra stepsI think this filename is misleading, its not generating the XML but just storing the index of default Nav2-included BT nodes. How about
generate_nav2_node_list.cpp
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is literally creating an XML with
std::ofstream
... but I can change the name, of course.No, it is not. The developer modifying a BT Node should run it and overwrite the previous XML with the new one.
But right now it is even worse, because we are asking to write the XML by hand and there is no guaranty of consistency (as a demonstration, right now it is WRONG in the main branch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That step ("double check if nav2_tree_node.xml is still valid") is there, but people just forget to do it.
This approach lowers the effort.
Maybe I can find a way to run it automatically, I don't know...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, then this should be removed. You cannot expect the CI system or users to run some script just to get their systems working or unit tests compiling. This doesn't work for CI nor a reasonable developer workflow.
If this was autogenerated, then I love it! But it has to be executed somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, there is a misunderstanding from my side and maybe I answered something wrong
CI, user code and unit test will work just fine!!!
The file that is autogenerated is
plugin_list.hpp
. That is everything you need.What I am talking about is the file nav2_tree_node.xml , that only Groot2 requires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok. So this does generate the index that the
plugins_list
needs for the BT test + BT navigator. Cool then this works.Now you got confused by this utility's name 😉 Rename suggestion to
generate_nav2_node_list.cpp
FTW