Skip to content

Commit 3d1b117

Browse files
committed
Merge branch 'master' of github.com:BehaviorTree/BehaviorTree.CPP
2 parents 3219b6f + 01e7f59 commit 3d1b117

File tree

5 files changed

+25
-29
lines changed

5 files changed

+25
-29
lines changed

.github/workflows/pixi.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,21 @@ jobs:
1313
matrix:
1414
include:
1515
- os: windows-latest
16-
shell: "pwsh -Login {0}"
17-
pixi_install: "iwr -useb https://pixi.sh/install.ps1 | iex"
1816
build_depend: vs2022_win-64=19.*
1917
tests_command: "'PATH=\\\"$PATH;build/Release\\\" build/tests/Release/behaviortree_cpp_test.exe'"
2018
- os: ubuntu-latest
21-
shell: "bash -el {0}"
22-
pixi_install: "curl -fsSL https://pixi.sh/install.sh | bash"
2319
build_depend: "gxx=12.2.*"
2420
tests_command: "./build/tests/behaviortree_cpp_test"
2521
runs-on: ${{ matrix.os }}
26-
defaults:
27-
run:
28-
shell: ${{ matrix.shell }}
2922
steps:
3023
# Pixi is the tool used to create/manage conda environment
31-
- name: Set up pixi
32-
run: |
33-
${{ matrix.pixi_install }}
34-
- name: Setup windows path
35-
if: "startsWith(runner.os, 'windows')"
36-
run: echo "C:\Users\runneradmin\AppData\Local\pixi\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
24+
- uses: prefix-dev/[email protected]
25+
with:
26+
pixi-version: v0.7.0
27+
locked: false
28+
frozen: false
29+
run-install: false
30+
manifest-path: build-env/pixi.yaml
3731
- name: Make pixi workspace
3832
run: |
3933
pixi init build-env

examples/t04_reactive_sequence.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ int main()
6161
factory.registerNodeType<SaySomething>("SaySomething");
6262

6363
// Compare the state transitions and messages using either
64-
// xml_text_sequence and xml_text_sequence_star
64+
// xml_text_sequence and xml_text_reactive.
6565

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

7070
for (auto& xml_text : {xml_text_sequence, xml_text_reactive})
7171
{

include/behaviortree_cpp/controls/parallel_node.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class ParallelNode : public ControlNode
4747
static PortsList providedPorts()
4848
{
4949
return {InputPort<int>(THRESHOLD_SUCCESS, -1,
50-
"number of children which need to succeed to trigger a "
50+
"number of children that need to succeed to trigger a "
5151
"SUCCESS"),
5252
InputPort<int>(THRESHOLD_FAILURE, 1,
53-
"number of children which need to fail to trigger a FAILURE")};
53+
"number of children that need to fail to trigger a FAILURE")};
5454
}
5555

5656
~ParallelNode() override = default;

include/behaviortree_cpp/flatbuffers/bt_flatbuffer_helper.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,15 @@ inline void CreateFlatbuffersBehaviorTree(flatbuffers::FlatBufferBuilder& builde
8080
children_uid.push_back(child->UID());
8181
}
8282

83+
// Const cast to ensure public access to config() overload
84+
const auto& node_config = const_cast<BT::TreeNode const &>(*node).config();
8385
std::vector<flatbuffers::Offset<Serialization::PortConfig>> ports;
84-
for (const auto& it : node->config().input_ports)
86+
for (const auto& it : node_config.input_ports)
8587
{
8688
ports.push_back(Serialization::CreatePortConfigDirect(builder, it.first.c_str(),
8789
it.second.c_str()));
8890
}
89-
for (const auto& it : node->config().output_ports)
91+
for (const auto& it : node_config.output_ports)
9092
{
9193
ports.push_back(Serialization::CreatePortConfigDirect(builder, it.first.c_str(),
9294
it.second.c_str()));

src/xml_parsing.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,8 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
558558
const std::string& prefix_path,
559559
Tree& output_tree)
560560
{
561-
auto element_name = element->Name();
562-
auto element_ID = element->Attribute("ID");
561+
const auto element_name = element->Name();
562+
const auto element_ID = element->Attribute("ID");
563563

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

598598
const TreeNodeManifest* manifest = nullptr;
599599

@@ -663,13 +663,13 @@ TreeNode::Ptr XMLParser::PImpl::createNodeFromXML(const XMLElement* element,
663663
}
664664

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

762762
// add the pointer of this node to the parent
763-
if (node_parent)
763+
if (node_parent != nullptr)
764764
{
765765
if (auto control_parent = dynamic_cast<ControlNode*>(node_parent.get()))
766766
{
767767
control_parent->addChild(new_node.get());
768768
}
769-
if (auto decorator_parent = dynamic_cast<DecoratorNode*>(node_parent.get()))
769+
else if (auto decorator_parent = dynamic_cast<DecoratorNode*>(node_parent.get()))
770770
{
771771
decorator_parent->setChild(new_node.get());
772772
}

0 commit comments

Comments
 (0)