Skip to content

Commit 6038b4c

Browse files
author
Davide Faconti
committed
run clangformat
1 parent d4aa3d1 commit 6038b4c

File tree

82 files changed

+1603
-1609
lines changed

Some content is hidden

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

82 files changed

+1603
-1609
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BreakBeforeBinaryOperators: false
1515
BreakBeforeTernaryOperators: false
1616
BreakConstructorInitializersBeforeComma: true
1717
BinPackParameters: true
18-
ColumnLimit: 120
18+
ColumnLimit: 100
1919
ConstructorInitializerAllOnOneLineOrOnePerLine: true
2020
DerivePointerBinding: false
2121
PointerBindsToType: true

examples/broken_sequence.cpp

+8-14
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using namespace BT;
66

7-
87
NodeStatus SayHello()
98
{
109
printf("hello\n");
@@ -14,8 +13,9 @@ NodeStatus SayHello()
1413
class ActionTestNode : public ActionNode
1514
{
1615
public:
17-
ActionTestNode(const std::string& name): ActionNode(name)
18-
{ }
16+
ActionTestNode(const std::string& name) : ActionNode(name)
17+
{
18+
}
1919

2020
NodeStatus tick() override
2121
{
@@ -35,7 +35,6 @@ class ActionTestNode : public ActionNode
3535
setStatus(NodeStatus::IDLE);
3636
}
3737

38-
3938
private:
4039
int time_;
4140
std::atomic_bool stop_loop_;
@@ -44,7 +43,7 @@ class ActionTestNode : public ActionNode
4443
int main()
4544
{
4645
BT::SequenceNode root("root");
47-
BT::SimpleActionNode action1("say_hello", std::bind(SayHello) );
46+
BT::SimpleActionNode action1("say_hello", std::bind(SayHello));
4847
ActionTestNode action2("async_action");
4948

5049
root.addChild(&action1);
@@ -54,16 +53,14 @@ int main()
5453

5554
NodeStatus status = NodeStatus::RUNNING;
5655

57-
while( status == NodeStatus::RUNNING)
56+
while (status == NodeStatus::RUNNING)
5857
{
5958
status = root.executeTick();
6059

61-
std::cout << count++ << " : " <<
62-
root.status() << " / " <<
63-
action1.status() << " / " <<
64-
action2.status() << std::endl;
60+
std::cout << count++ << " : " << root.status() << " / " << action1.status() << " / "
61+
<< action2.status() << std::endl;
6562

66-
std::this_thread::sleep_for( std::chrono::milliseconds(100));
63+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
6764
}
6865

6966
haltAllActions(&root);
@@ -87,6 +84,3 @@ hello
8784
5 : SUCCESS / IDLE / IDLE
8885
8986
*/
90-
91-
92-

examples/t01_programmatic_tree.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ int main()
2121

2222
// Function pointers can be wrapped inside ActionNodeBase
2323
// using the SimpleActionNode
24-
SimpleActionNode say_hello("action_hello", std::bind(SayHello) );
24+
SimpleActionNode say_hello("action_hello", std::bind(SayHello));
2525

2626
// SimpleActionNode works also with class methods, using std::bind
27-
SimpleActionNode open_gripper("open_gripper", std::bind( &GripperInterface::open, &gripper) );
28-
SimpleActionNode close_gripper("close_gripper", std::bind( &GripperInterface::close, &gripper) );
27+
SimpleActionNode open_gripper("open_gripper", std::bind(&GripperInterface::open, &gripper));
28+
SimpleActionNode close_gripper("close_gripper", std::bind(&GripperInterface::close, &gripper));
2929

3030
// To be able to use ALL the functionalities of a TreeNode,
3131
// your should create a class that inherits from either:

examples/t02_factory_tree.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ int main()
4848

4949
using namespace DummyNodes;
5050

51-
factory.registerSimpleAction("SayHello", std::bind(SayHello) );
52-
factory.registerSimpleCondition("CheckBattery", std::bind(CheckBattery) );
53-
factory.registerSimpleCondition("CheckTemperature", std::bind(CheckTemperature) );
51+
factory.registerSimpleAction("SayHello", std::bind(SayHello));
52+
factory.registerSimpleCondition("CheckBattery", std::bind(CheckBattery));
53+
factory.registerSimpleCondition("CheckTemperature", std::bind(CheckTemperature));
5454

5555
GripperInterface gripper;
56-
factory.registerSimpleAction("OpenGripper", std::bind( &GripperInterface::open, &gripper));
57-
factory.registerSimpleAction("CloseGripper", std::bind( &GripperInterface::close, &gripper));
56+
factory.registerSimpleAction("OpenGripper", std::bind(&GripperInterface::open, &gripper));
57+
factory.registerSimpleAction("CloseGripper", std::bind(&GripperInterface::close, &gripper));
5858

5959
factory.registerNodeType<ApproachObject>("ApproachObject");
6060

examples/t03_sequence_star.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ using namespace BT;
1313
* its own thread).
1414
*/
1515

16-
1716
// clang-format off
1817

1918
const std::string xml_text_sequence = R"(
@@ -54,16 +53,17 @@ const std::string xml_text_sequence_star = R"(
5453

5554
void Assert(bool condition)
5655
{
57-
if( !condition ) throw std::runtime_error("this is not what I expected");
56+
if (!condition)
57+
throw std::runtime_error("this is not what I expected");
5858
}
5959

6060
int main()
6161
{
6262
using namespace DummyNodes;
6363

6464
BehaviorTreeFactory factory;
65-
factory.registerSimpleCondition("TemperatureOK", std::bind( CheckBattery ));
66-
factory.registerSimpleCondition("BatteryOK", std::bind( CheckTemperature ));
65+
factory.registerSimpleCondition("TemperatureOK", std::bind(CheckBattery));
66+
factory.registerSimpleCondition("BatteryOK", std::bind(CheckTemperature));
6767
factory.registerNodeType<MoveBaseAction>("MoveBase");
6868
factory.registerNodeType<SaySomething>("SaySomething");
6969

@@ -74,7 +74,7 @@ int main()
7474
// 1) When Sequence is used, BatteryOK and TempearaturOK is executed at each tick()
7575
// 2) When SequenceStar is used, those ConditionNodes are executed only once.
7676

77-
for(auto& xml_text: {xml_text_sequence, xml_text_sequence_star})
77+
for (auto& xml_text : {xml_text_sequence, xml_text_sequence_star})
7878
{
7979
std::cout << "\n------------ BUILDING A NEW TREE ------------" << std::endl;
8080

@@ -84,17 +84,17 @@ int main()
8484

8585
std::cout << "\n--- 1st executeTick() ---" << std::endl;
8686
status = tree.root_node->executeTick();
87-
Assert( status == NodeStatus::RUNNING);
87+
Assert(status == NodeStatus::RUNNING);
8888

8989
SleepMS(150);
9090
std::cout << "\n--- 2nd executeTick() ---" << std::endl;
9191
status = tree.root_node->executeTick();
92-
Assert( status == NodeStatus::RUNNING);
92+
Assert(status == NodeStatus::RUNNING);
9393

9494
SleepMS(150);
9595
std::cout << "\n--- 3rd executeTick() ---" << std::endl;
9696
status = tree.root_node->executeTick();
97-
Assert( status == NodeStatus::SUCCESS);
97+
Assert(status == NodeStatus::SUCCESS);
9898

9999
std::cout << std::endl;
100100
}
@@ -138,4 +138,3 @@ Robot says: "mission started..."
138138
Robot says: "mission completed!"
139139
140140
*/
141-

examples/t04_blackboard.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ const std::string xml_text = R"(
4141
// Use this function to create a SimpleActionNode that can access the blackboard
4242
NodeStatus CalculateGoalPose(TreeNode& self)
4343
{
44-
const Pose2D mygoal = { 1, 2, M_PI};
44+
const Pose2D mygoal = {1, 2, M_PI};
4545

4646
// RECOMMENDED: check if the blackboard is nullptr first
47-
if( self.blackboard() )
47+
if (self.blackboard())
4848
{
4949
// store it in the blackboard
5050
self.blackboard()->set("GoalPose", mygoal);
5151
return NodeStatus::SUCCESS;
5252
}
53-
else{
53+
else
54+
{
5455
return NodeStatus::FAILURE;
5556
}
5657
}
@@ -70,10 +71,10 @@ int main()
7071
auto tree = buildTreeFromText(factory, xml_text, blackboard);
7172

7273
NodeStatus status = NodeStatus::RUNNING;
73-
while( status == NodeStatus::RUNNING )
74+
while (status == NodeStatus::RUNNING)
7475
{
7576
status = tree.root_node->executeTick();
76-
SleepMS(1); // optional sleep to avoid "busy loops"
77+
SleepMS(1); // optional sleep to avoid "busy loops"
7778
}
7879
return 0;
7980
}

examples/t05_crossdoor.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,19 @@ int main()
6060
auto tree = buildTreeFromText(factory, xml_text, blackboard);
6161

6262
// Create some loggers
63-
StdCoutLogger logger_cout(tree.root_node);
63+
StdCoutLogger logger_cout(tree.root_node);
6464
MinitraceLogger logger_minitrace(tree.root_node, "bt_trace.json");
65-
FileLogger logger_file(tree.root_node, "bt_trace.fbl");
65+
FileLogger logger_file(tree.root_node, "bt_trace.fbl");
6666
#ifdef ZMQ_FOUND
67-
PublisherZMQ publisher_zmq(tree.root_node);
67+
PublisherZMQ publisher_zmq(tree.root_node);
6868
#endif
69-
69+
7070
// Keep on ticking until you get either a SUCCESS or FAILURE state
7171
NodeStatus status = NodeStatus::RUNNING;
72-
while( status == NodeStatus::RUNNING )
72+
while (status == NodeStatus::RUNNING)
7373
{
7474
status = tree.root_node->executeTick();
75-
CrossDoor::SleepMS(1); // optional sleep to avoid "busy loops"
75+
CrossDoor::SleepMS(1); // optional sleep to avoid "busy loops"
7676
}
7777
return 0;
7878
}

gtest/gtest_decorator.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@
1717

1818
using BT::NodeStatus;
1919

20-
2120
struct DeadlineTest : testing::Test
2221
{
2322
BT::TimeoutNode root;
2423
BT::AsyncActionTest action;
2524

26-
DeadlineTest()
27-
: root("deadline", 250)
28-
, action("action")
25+
DeadlineTest() : root("deadline", 250), action("action")
2926
{
3027
root.setChild(&action);
3128
}
@@ -35,7 +32,6 @@ struct DeadlineTest : testing::Test
3532
}
3633
};
3734

38-
3935
/****************TESTS START HERE***************************/
4036

4137
TEST_F(DeadlineTest, DeadlineTriggeredTest)
@@ -67,4 +63,3 @@ TEST_F(DeadlineTest, DeadlineNotTriggeredTest)
6763
ASSERT_EQ(NodeStatus::IDLE, action.status());
6864
ASSERT_EQ(NodeStatus::SUCCESS, state);
6965
}
70-

gtest/gtest_factory.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ TEST(BehaviorTreeFactory, Subtree)
155155

156156
std::vector<BT::TreeNode::Ptr> nodes;
157157

158-
BT::TreeNode::Ptr root_node = parser.instantiateTree( nodes);
158+
BT::TreeNode::Ptr root_node = parser.instantiateTree(nodes);
159159
BT::printTreeRecursively(root_node.get());
160160

161161
ASSERT_EQ(root_node->name(), "root_selector");

gtest/gtest_fallback.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
using BT::NodeStatus;
1919

20-
2120
struct SimpleFallbackTest : testing::Test
2221
{
2322
BT::FallbackNode root;
@@ -64,7 +63,6 @@ struct ComplexFallbackTest : testing::Test
6463
}
6564
};
6665

67-
6866
struct SimpleFallbackWithMemoryTest : testing::Test
6967
{
7068
BT::FallbackStarNode root;
@@ -197,7 +195,6 @@ TEST_F(ComplexFallbackTest, Condition2ToTrue)
197195
ASSERT_EQ(NodeStatus::IDLE, action_1.status());
198196
}
199197

200-
201198
TEST_F(SimpleFallbackWithMemoryTest, ConditionFalse)
202199
{
203200
condition.setBoolean(false);
@@ -324,5 +321,3 @@ TEST_F(ComplexFallbackWithMemoryTest, Action1Failed)
324321
ASSERT_EQ(NodeStatus::FAILURE, action_1.status());
325322
ASSERT_EQ(NodeStatus::RUNNING, action_2.status());
326323
}
327-
328-

gtest/gtest_parallel.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
using BT::NodeStatus;
1919

20-
2120
struct SimpleParallelTest : testing::Test
2221
{
2322
BT::ParallelNode root;
@@ -172,7 +171,8 @@ TEST_F(ComplexParallelTest, Condition3FalseAction1Done)
172171
ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
173172
ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
174173
ASSERT_EQ(NodeStatus::IDLE, condition_3.status());
175-
ASSERT_EQ(NodeStatus::SUCCESS, action_1.status()); // success not read yet by the node parallel_1
174+
ASSERT_EQ(NodeStatus::SUCCESS,
175+
action_1.status()); // success not read yet by the node parallel_1
176176
ASSERT_EQ(NodeStatus::RUNNING,
177177
parallel_1.status()); // parallel_1 hasn't realize (yet) that action_1 has succeeded
178178

@@ -196,4 +196,3 @@ TEST_F(ComplexParallelTest, Condition3FalseAction1Done)
196196
ASSERT_EQ(NodeStatus::IDLE, parallel_2.status());
197197
ASSERT_EQ(NodeStatus::SUCCESS, state);
198198
}
199-

gtest/gtest_sequence.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ struct SequenceTripleActionTest : testing::Test
6868
BT::SequenceNode root;
6969
BT::ConditionTestNode condition;
7070
BT::AsyncActionTest action_1;
71-
BT::SyncActionTest action_2;
71+
BT::SyncActionTest action_2;
7272
BT::AsyncActionTest action_3;
7373

74-
SequenceTripleActionTest() : root("root_sequence"), condition("condition"),
75-
action_1("action_1"), action_2("action_2"), action_3("action_3")
74+
SequenceTripleActionTest()
75+
: root("root_sequence")
76+
, condition("condition")
77+
, action_1("action_1")
78+
, action_2("action_2")
79+
, action_3("action_3")
7680
{
7781
root.addChild(&condition);
7882
root.addChild(&action_1);
@@ -122,8 +126,6 @@ struct ComplexSequence2ActionsTest : testing::Test
122126
}
123127
};
124128

125-
126-
127129
struct SimpleSequenceWithMemoryTest : testing::Test
128130
{
129131
BT::SequenceStarNode root;
@@ -207,7 +209,6 @@ struct SimpleParallelTest : testing::Test
207209
}
208210
};
209211

210-
211212
/****************TESTS START HERE***************************/
212213

213214
TEST_F(SimpleSequenceTest, ConditionTrue)
@@ -323,7 +324,6 @@ TEST_F(ComplexSequenceTest, ComplexSequenceConditions1ToFalse)
323324
ASSERT_EQ(NodeStatus::IDLE, condition_1.status());
324325
ASSERT_EQ(NodeStatus::IDLE, condition_2.status());
325326
ASSERT_EQ(NodeStatus::IDLE, action_1.status());
326-
327327
}
328328

329329
TEST_F(ComplexSequenceTest, ComplexSequenceConditions2ToFalse)

gtest/gtest_tree.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
using BT::NodeStatus;
1919

20-
2120
struct BehaviorTreeTest : testing::Test
2221
{
2322
BT::SequenceNode root;
@@ -47,10 +46,8 @@ struct BehaviorTreeTest : testing::Test
4746
}
4847
};
4948

50-
5149
/****************TESTS START HERE***************************/
5250

53-
5451
TEST_F(BehaviorTreeTest, Condition1ToFalseCondition2True)
5552
{
5653
condition_1.setBoolean(false);

0 commit comments

Comments
 (0)