| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
what I notice is that you did not remove the input port with server_name, you just add a default value. To obtain the same result, there is potentially a better "trick" template <class DerivedT> static
void RegisterRosAction(BT::BehaviorTreeFactory& factory,
const std::string& registration_ID,
ros::NodeHandle& node_handle,
const std::string& default_server_name = {} )
{
NodeBuilder builder = [&node_handle, default_server_name](const std::string& name, const NodeConfiguration& config)
{
auto name_it = config.input_ports.find("server_name");
// The server_name passed as port has priority over the default_server_name
if( !default_server_name.empty() && name_it->second.empty() )
{
auto new_config = config;
new_config.input_ports["server_name"] = default_server_name;
return std::make_unique<DerivedT>(node_handle, name, new_config );
}
else{
return std::make_unique<DerivedT>(node_handle, name, config );
}
};
TreeNodeManifest manifest;
manifest.type = getType<DerivedT>();
manifest.ports = DerivedT::providedPorts();
manifest.registration_ID = registration_ID;
const auto& basic_ports = RosActionNode< typename DerivedT::ActionType>::providedPorts();
manifest.ports.insert( basic_ports.begin(), basic_ports.end() );
factory.registerBuilder( manifest, builder );
} |
Sorry, something went wrong.
|
note as my code obtain the very same result and does not require any modification of RosAction |
Sorry, something went wrong.
|
Your solution seems very reasonable. It now does still work with server_name in the tree but I get an error when I remove the port from the tree: terminate called after throwing an instance of 'nonstd::expected_lite::bad_expected_access<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >'
what(): bad_expected_access
Aborted (core dumped) |
Sorry, something went wrong.
|
Let me investigate |
Sorry, something went wrong.
|
@facontidavide: I removed the bug and refactored the code a little bit. I tested it for all cases (with/without port, with/without default in RegisterRosX). The port is prioritized and an error is thrown if no port/default is provided. The solution is backwards compatible. From my side this is ready to merge the include files. Should we document this feature in the test_bt.cpp file? |
Sorry, something went wrong.
|
Hi @facontidavide, |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Referring to Issue #14
Open points: