Skip to content

Commit

Permalink
Merge branch 'master' of github.com:BehaviorTree/BehaviorTree.CPP
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Nov 21, 2023
2 parents 3219b6f + 01e7f59 commit 3d1b117
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 29 deletions.
20 changes: 7 additions & 13 deletions .github/workflows/pixi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,21 @@ jobs:
matrix:
include:
- os: windows-latest
shell: "pwsh -Login {0}"
pixi_install: "iwr -useb https://pixi.sh/install.ps1 | iex"
build_depend: vs2022_win-64=19.*
tests_command: "'PATH=\\\"$PATH;build/Release\\\" build/tests/Release/behaviortree_cpp_test.exe'"
- os: ubuntu-latest
shell: "bash -el {0}"
pixi_install: "curl -fsSL https://pixi.sh/install.sh | bash"
build_depend: "gxx=12.2.*"
tests_command: "./build/tests/behaviortree_cpp_test"
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.shell }}
steps:
# Pixi is the tool used to create/manage conda environment
- name: Set up pixi
run: |
${{ matrix.pixi_install }}
- name: Setup windows path
if: "startsWith(runner.os, 'windows')"
run: echo "C:\Users\runneradmin\AppData\Local\pixi\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- uses: prefix-dev/[email protected]
with:
pixi-version: v0.7.0
locked: false
frozen: false
run-install: false
manifest-path: build-env/pixi.yaml
- name: Make pixi workspace
run: |
pixi init build-env
Expand Down
6 changes: 3 additions & 3 deletions examples/t04_reactive_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ int main()
factory.registerNodeType<SaySomething>("SaySomething");

// Compare the state transitions and messages using either
// xml_text_sequence and xml_text_sequence_star
// xml_text_sequence and xml_text_reactive.

// The main difference that you should notice is:
// 1) When Sequence is used, BatteryOK is executed at __each__ tick()
// 2) When SequenceStar is used, those ConditionNodes are executed only __once__.
// 1) When Sequence is used, the ConditionNode is executed only __once__ because it returns SUCCESS.
// 2) When ReaciveSequence is used, BatteryOK is executed at __each__ tick()

for (auto& xml_text : {xml_text_sequence, xml_text_reactive})
{
Expand Down
4 changes: 2 additions & 2 deletions include/behaviortree_cpp/controls/parallel_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class ParallelNode : public ControlNode
static PortsList providedPorts()
{
return {InputPort<int>(THRESHOLD_SUCCESS, -1,
"number of children which need to succeed to trigger a "
"number of children that need to succeed to trigger a "
"SUCCESS"),
InputPort<int>(THRESHOLD_FAILURE, 1,
"number of children which need to fail to trigger a FAILURE")};
"number of children that need to fail to trigger a FAILURE")};
}

~ParallelNode() override = default;
Expand Down
6 changes: 4 additions & 2 deletions include/behaviortree_cpp/flatbuffers/bt_flatbuffer_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ inline void CreateFlatbuffersBehaviorTree(flatbuffers::FlatBufferBuilder& builde
children_uid.push_back(child->UID());
}

// Const cast to ensure public access to config() overload
const auto& node_config = const_cast<BT::TreeNode const &>(*node).config();
std::vector<flatbuffers::Offset<Serialization::PortConfig>> ports;
for (const auto& it : node->config().input_ports)
for (const auto& it : node_config.input_ports)
{
ports.push_back(Serialization::CreatePortConfigDirect(builder, it.first.c_str(),
it.second.c_str()));
}
for (const auto& it : node->config().output_ports)
for (const auto& it : node_config.output_ports)
{
ports.push_back(Serialization::CreatePortConfigDirect(builder, it.first.c_str(),
it.second.c_str()));
Expand Down
18 changes: 9 additions & 9 deletions src/xml_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
const std::string& prefix_path,
Tree& output_tree)
{
auto element_name = element->Name();
auto element_ID = element->Attribute("ID");
const auto element_name = element->Name();
const auto element_ID = element->Attribute("ID");

auto node_type = convertFromString<NodeType>(element_name);
// name used by the factory
Expand Down Expand Up @@ -593,7 +593,7 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
// By default, the instance name is equal to ID, unless the
// attribute [name] is present.
const char* attr_name = element->Attribute("name");
std::string instance_name = attr_name ? attr_name : type_ID;
const std::string instance_name = (attr_name != nullptr) ? attr_name : type_ID;

const TreeNodeManifest* manifest = nullptr;

Expand Down Expand Up @@ -663,13 +663,13 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
}

//Check that name in remapping can be found in the manifest
for (const auto& remap_it : port_remap)
for (const auto& [name_in_subtree, _] : port_remap)
{
if (manifest->ports.count(remap_it.first) == 0)
if (manifest->ports.count(name_in_subtree) == 0)
{
throw RuntimeError("Possible typo? In the XML, you tried to remap port \"",
remap_it.first, "\" in node [", type_ID, " / ", instance_name,
"], but the manifest of this node does not contain a port "
name_in_subtree, "\" in node [", config.path, "(type ", type_ID,
")], but the manifest of this node does not contain a port "
"with this name.");
}
}
Expand Down Expand Up @@ -760,13 +760,13 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
}

// add the pointer of this node to the parent
if (node_parent)
if (node_parent != nullptr)
{
if (auto control_parent = dynamic_cast<ControlNode*>(node_parent.get()))
{
control_parent->addChild(new_node.get());
}
if (auto decorator_parent = dynamic_cast<DecoratorNode*>(node_parent.get()))
else if (auto decorator_parent = dynamic_cast<DecoratorNode*>(node_parent.get()))
{
decorator_parent->setChild(new_node.get());
}
Expand Down

0 comments on commit 3d1b117

Please sign in to comment.