Skip to content

Commit

Permalink
Imported upstream version '3.8.5' of 'upstream'
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Aug 14, 2023
1 parent af1586c commit f43ad9c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
Changelog for package behaviortree_cpp
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

3.8.5 (2023-08-14)
------------------

3.8.4 (2023-06-28)
------------------
* Update ros2.yaml
Expand Down
5 changes: 5 additions & 0 deletions include/behaviortree_cpp_v3/basic_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ class PortInfo

const std::string& defaultValue() const;

bool isStronglyTyped() const
{
return _info != nullptr;
}

private:
PortDirection _type;
const std::type_info* _info;
Expand Down
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="3">
<name>behaviortree_cpp_v3</name>
<version>3.8.4</version>
<version>3.8.5</version>
<description>
This package provides the Behavior Trees core library.
</description>
Expand Down
32 changes: 19 additions & 13 deletions src/xml_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,23 +565,24 @@ TreeNode::Ptr XMLParser::Pimpl::createNodeFromXML(const XMLElement* element,
continue;
}
StringView param_value = remap_it->second;
auto param_res = TreeNode::getRemappedKey(port_name, param_value);
if (param_res)

if (auto param_res = TreeNode::getRemappedKey(port_name, param_value))
{
// port_key will contain the key to find the entry in the blackboard
const auto port_key = static_cast<std::string>(param_res.value());

auto prev_info = blackboard->portInfo(port_key);
if (!prev_info)
// if the entry already exists, check that the type is the same
if (auto prev_info = blackboard->portInfo(port_key))
{
// not found, insert for the first time.
blackboard->createEntry(port_key, port_info);
}
else
{
// found. check consistency
if (prev_info->type() &&
port_info.type() && // null type means that everything is valid
*prev_info->type() != *port_info.type())
bool const port_type_mismatch = (prev_info->isStronglyTyped() &&
port_info.isStronglyTyped() &&
*prev_info->type() != *port_info.type());

// special case related to convertFromString
bool const string_input = ( prev_info->type() &&
*prev_info->type() == typeid(std::string));

if (port_type_mismatch && !string_input)
{
blackboard->debugMessage();

Expand All @@ -591,6 +592,11 @@ TreeNode::Ptr XMLParser::Pimpl::createNodeFromXML(const XMLElement* element,
demangle(port_info.type()), "] was used somewhere else.");
}
}
else
{
// not found, insert for the first time.
blackboard->createEntry(port_key, port_info);
}
}
}

Expand Down
28 changes: 28 additions & 0 deletions tests/gtest_subtree.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <gtest/gtest.h>
#include "behaviortree_cpp_v3/bt_factory.h"
#include "../sample_nodes/dummy_nodes.h"
#include "../sample_nodes/movebase_node.h"

using namespace BT;

Expand Down Expand Up @@ -372,3 +373,30 @@ TEST(SubTree, SubtreeIssue563)
auto ret = tree.tickRoot();
ASSERT_EQ(ret, NodeStatus::SUCCESS);
}

TEST(SubTree, String_to_Pose_Issue623)
{
// clang-format off

static const char* xml_text = R"(
<root main_tree_to_execute="Test">
<BehaviorTree ID="Test">
<ReactiveSequence name="MainSequence">
<SubTreePlus name="Visit2" ID="Visit2" tl1="1;2;3"/>
</ReactiveSequence>
</BehaviorTree>
<BehaviorTree ID="Visit2">
<Sequence name="Visit2MainSequence">
<Action name="MoveBase" ID="MoveBase" goal="{tl1}"/>
</Sequence>
</BehaviorTree>
</root>
)";

// clang-format on

BehaviorTreeFactory factory;
factory.registerNodeType<MoveBaseAction>("MoveBase");
auto tree = factory.createTreeFromText(xml_text);
tree.tickRootWhileRunning();
}

0 comments on commit f43ad9c

Please sign in to comment.