Skip to content

Commit 594e24c

Browse files
Merge branch 'master' into feature/polymorphic-ports-abi-compatible
2 parents d29dc42 + ffab835 commit 594e24c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+328
-245
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ repos:
5151
entry: ./run_clang_tidy_hook.sh
5252
language: script
5353
files: \.(cpp|hpp|h)$
54-
exclude: ^3rdparty/|^include/behaviortree_cpp/contrib/|^include/behaviortree_cpp/scripting/
54+
exclude: ^3rdparty/|^include/behaviortree_cpp/contrib/|^include/behaviortree_cpp/scripting/|^include/behaviortree_cpp/flatbuffers/|^examples/|^tools/|^fuzzing/|^tests/gtest_async_action_node\.cpp$|^tests/gtest_logger_zmq\.cpp$|^tests/include/environment\.h$|^tests/gtest_groot2_publisher\.cpp$
5555

5656
# Spell check
5757
- repo: https://github.com/codespell-project/codespell

examples/ex01_wrap_legacy.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Point3D convertFromString(StringView key)
3939
}
4040
else
4141
{
42-
Point3D output;
42+
Point3D output{};
4343
output.x = convertFromString<double>(parts[0]);
4444
output.y = convertFromString<double>(parts[1]);
4545
output.z = convertFromString<double>(parts[2]);
@@ -49,7 +49,11 @@ Point3D convertFromString(StringView key)
4949
} // namespace BT
5050

5151
// clang-format off
52-
static const char* xml_text = R"(
52+
53+
namespace
54+
{
55+
56+
const char* xml_text = R"(
5357
5458
<root BTCPP_format="4">
5559
<BehaviorTree>
@@ -58,6 +62,8 @@ static const char* xml_text = R"(
5862
</root>
5963
)";
6064

65+
} // namespace
66+
6167
// clang-format on
6268

6369
int main()
@@ -68,7 +74,7 @@ int main()
6874

6975
// Here we use a lambda that captures the reference of move_to
7076
auto MoveToWrapperWithLambda = [&move_to](TreeNode& parent_node) -> NodeStatus {
71-
Point3D goal;
77+
Point3D goal{};
7278
// thanks to paren_node, you can access easily the input and output ports.
7379
parent_node.getInput("goal", goal);
7480

examples/t04_reactive_sequence.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ using namespace BT;
1414

1515
// clang-format off
1616

17-
static const char* xml_text_sequence = R"(
17+
namespace
18+
{
19+
20+
const char* xml_text_sequence = R"(
1821
1922
<root BTCPP_format="4" >
2023
@@ -30,7 +33,7 @@ static const char* xml_text_sequence = R"(
3033
</root>
3134
)";
3235

33-
static const char* xml_text_reactive = R"(
36+
const char* xml_text_reactive = R"(
3437
3538
<root BTCPP_format="4" >
3639
@@ -48,6 +51,8 @@ static const char* xml_text_reactive = R"(
4851
</root>
4952
)";
5053

54+
} // namespace
55+
5156
// clang-format on
5257

5358
using namespace DummyNodes;

examples/t07_load_multiple_xml.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010
// clang-format off
1111

12-
static const char* xml_text_main = R"(
12+
namespace
13+
{
14+
15+
const char* xml_text_main = R"(
1316
<root BTCPP_format="4">
1417
<BehaviorTree ID="MainTree">
1518
<Sequence>
@@ -20,20 +23,22 @@ static const char* xml_text_main = R"(
2023
</BehaviorTree>
2124
</root> )";
2225

23-
static const char* xml_text_subA = R"(
26+
const char* xml_text_subA = R"(
2427
<root BTCPP_format="4">
2528
<BehaviorTree ID="SubA">
2629
<SaySomething message="Executing SubA" />
2730
</BehaviorTree>
2831
</root> )";
2932

30-
static const char* xml_text_subB = R"(
33+
const char* xml_text_subB = R"(
3134
<root BTCPP_format="4">
3235
<BehaviorTree ID="SubB">
3336
<SaySomething message="Executing SubB" />
3437
</BehaviorTree>
3538
</root> )";
3639

40+
} // namespace
41+
3742
// clang-format on
3843

3944
using namespace BT;

examples/t09_scripting.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
using namespace BT;
66

77
// clang-format off
8-
static const char* xml_text = R"(
8+
9+
namespace
10+
{
11+
12+
const char* xml_text = R"(
913
<root BTCPP_format="4">
1014
<BehaviorTree>
1115
<Sequence>
@@ -24,6 +28,8 @@ static const char* xml_text = R"(
2428
</root>
2529
)";
2630

31+
} // namespace
32+
2733
// clang-format on
2834

2935
int main()

examples/t11_groot_howto.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct Position2D
2626
// the object to/from JSON.
2727
// You still need to call BT::RegisterJsonDefinition<Position2D>()
2828
// in main()
29+
// NOLINTNEXTLINE(misc-use-internal-linkage)
2930
BT_JSON_CONVERTER(Position2D, pos)
3031
{
3132
add_field("x", &pos.x);
@@ -39,6 +40,7 @@ struct Waypoint
3940
double speed = 1.0;
4041
};
4142

43+
// NOLINTNEXTLINE(misc-use-internal-linkage)
4244
BT_JSON_CONVERTER(Waypoint, wp)
4345
{
4446
add_field("name", &wp.name);
@@ -70,6 +72,7 @@ class UpdatePosition : public BT::SyncActionNode
7072

7173
// Helper to generate random offset [-range, +range]
7274
auto randOffset = [](double range) {
75+
// NOLINTNEXTLINE(cert-msc30-c,cert-msc50-cpp,concurrency-mt-unsafe)
7376
return (static_cast<double>(std::rand()) / RAND_MAX - 0.5) * 2.0 * range;
7477
};
7578

@@ -120,8 +123,9 @@ class UpdatePosition : public BT::SyncActionNode
120123
};
121124

122125
// clang-format off
123-
124-
static const char* xml_text = R"(
126+
namespace
127+
{
128+
const char* xml_text = R"(
125129
<root BTCPP_format="4">
126130
127131
<BehaviorTree ID="MainTree">
@@ -150,7 +154,7 @@ static const char* xml_text = R"(
150154
151155
</root>
152156
)";
153-
157+
} // namespace
154158
// clang-format on
155159

156160
int main()
@@ -165,7 +169,7 @@ int main()
165169
// Groot2 editor requires a model of your registered Nodes.
166170
// You don't need to write that by hand, it can be automatically
167171
// generated using the following command.
168-
const std::string xml_models = BT::writeTreeNodesModelXML(factory);
172+
[[maybe_unused]] const std::string xml_models = BT::writeTreeNodesModelXML(factory);
169173

170174
factory.registerBehaviorTreeFromText(xml_text);
171175

@@ -191,7 +195,7 @@ int main()
191195
BT::FileLogger2 logger2(tree, "t11_groot_howto.btlog");
192196
BT::MinitraceLogger minilog(tree, "minitrace.json");
193197

194-
while(1)
198+
while(true)
195199
{
196200
std::cout << "Start" << std::endl;
197201
cross_door.reset();

examples/t14_subtree_model.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ using namespace BT;
2222
*/
2323

2424
// clang-format off
25-
static const char* xml_subtree = R"(
25+
namespace
26+
{
27+
const char* xml_subtree = R"(
2628
<root BTCPP_format="4">
2729
2830
<TreeNodesModel>
@@ -48,7 +50,7 @@ static const char* xml_subtree = R"(
4850
* remapped. We will use the default values for the other two.
4951
*/
5052

51-
static const char* xml_maintree = R"(
53+
const char* xml_maintree = R"(
5254
<root BTCPP_format="4">
5355
5456
<BehaviorTree ID="MainTree">
@@ -62,6 +64,7 @@ static const char* xml_maintree = R"(
6264
6365
</root>
6466
)";
67+
} // namespace
6568

6669
// clang-format on
6770

examples/t15_nodes_mocking.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
#include "behaviortree_cpp/bt_factory.h"
44

55
// clang-format off
6-
7-
static const char* xml_text = R"(
6+
namespace
7+
{
8+
const char* xml_text = R"(
89
<root BTCPP_format="4">
910
1011
<BehaviorTree ID="MainTree">
@@ -33,7 +34,7 @@ static const char* xml_text = R"(
3334
3435
</root>
3536
)";
36-
37+
} // namespace
3738
// clang-format on
3839

3940
/**
@@ -44,7 +45,7 @@ static const char* xml_text = R"(
4445
* @return
4546
*/
4647

47-
int main(int argc, char** argv)
48+
int main(int /*argc*/, char** /*argv*/)
4849
{
4950
using namespace DummyNodes;
5051
BT::BehaviorTreeFactory factory;

examples/t16_global_blackboard.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ using namespace BT;
2525
*/
2626

2727
// clang-format off
28-
static const char* xml_main = R"(
28+
namespace
29+
{
30+
const char* xml_main = R"(
2931
<root BTCPP_format="4">
3032
3133
<BehaviorTree ID="MainTree">
@@ -43,7 +45,7 @@ static const char* xml_main = R"(
4345
</BehaviorTree>
4446
</root>
4547
)";
46-
48+
} // namespace
4749
// clang-format on
4850

4951
class PrintNumber : public BT::SyncActionNode

examples/t18_waypoints.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class PrintNumber : public SyncActionNode
5252

5353
NodeStatus tick() override
5454
{
55-
double value;
55+
double value = 0.0;
5656
if(getInput("value", value))
5757
{
5858
std::cout << "PrintNumber: " << value << "\n";
@@ -81,7 +81,7 @@ class UseWaypoint : public ThreadedAction
8181

8282
NodeStatus tick() override
8383
{
84-
Pose2D wp;
84+
Pose2D wp{};
8585
if(getInput("waypoint", wp))
8686
{
8787
std::this_thread::sleep_for(std::chrono::milliseconds(100));
@@ -101,7 +101,11 @@ class UseWaypoint : public ThreadedAction
101101
};
102102

103103
// clang-format off
104-
static const char* xml_tree = R"(
104+
105+
namespace
106+
{
107+
108+
const char* xml_tree = R"(
105109
<root BTCPP_format="4" >
106110
<BehaviorTree ID="TreeA">
107111
<Sequence>
@@ -118,6 +122,8 @@ static const char* xml_tree = R"(
118122
</root>
119123
)";
120124

125+
} // namespace
126+
121127
// clang-format on
122128

123129
int main()

0 commit comments

Comments
 (0)