Skip to content

Commit e9ad044

Browse files
committed
fix breakoff condition
1 parent f35f58c commit e9ad044

File tree

3 files changed

+61
-12
lines changed

3 files changed

+61
-12
lines changed

advanced/include/mbf_advanced/mbf_cpp_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct MBFClient
5353
{
5454
if (at_end())
5555
{
56-
throw std::runtime_error("Reached end! No more next poses");
56+
throw std::runtime_error("Reached end! No more next poses. Exiting BT.");
5757
}
5858

5959
auto result = log_move(*it_);

advanced/src/mbf_behavior_tree.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,7 @@ class AttemptNext : public BT::SyncActionNode
2828
if (mbfclient_)
2929
{
3030
ROS_INFO_STREAM("BT: " << this->name());
31-
32-
try
33-
{
34-
auto status = mbfclient_->next_move() ? BT::NodeStatus::SUCCESS : BT::NodeStatus::FAILURE;
35-
return status;
36-
}
37-
catch (const std::runtime_error& e)
38-
{
39-
ROS_INFO_STREAM("Reached end of circle poses: " << e.what() << ". Returning BT::NodeStatus::Failure to break our of BT.");
40-
return BT::NodeStatus::FAILURE;
41-
}
31+
return mbfclient_->next_move() ? BT::NodeStatus::SUCCESS : BT::NodeStatus::FAILURE;
4232
}
4333

4434
return BT::NodeStatus::FAILURE;

advanced/src/test.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <behaviortree_cpp_v3/bt_factory.h>
2+
3+
BT::NodeStatus start()
4+
{
5+
std::cout << "start" << std::endl;
6+
return BT::NodeStatus::SUCCESS;
7+
}
8+
9+
BT::NodeStatus stop()
10+
{
11+
std::cout << "stop" << std::endl;
12+
return BT::NodeStatus::FAILURE;
13+
}
14+
15+
BT::NodeStatus final_stop()
16+
{
17+
std::cout << "final_stop" << std::endl;
18+
return BT::NodeStatus::SUCCESS;
19+
}
20+
21+
//class Repeat: BT::SimpleActionNode
22+
//{
23+
// Repeat(const std::string& name, const BT::NodeConfiguration &config)
24+
// : BT::RepeatNode(name, config)
25+
// {}
26+
//
27+
// static BT::PortsList providedPorts()
28+
// {
29+
// return { BT::InputPort<int>("n_tries")};
30+
// }
31+
//
32+
// BT::NodeStatus tick() override
33+
// {
34+
// BT::Optional<int> msg = getInput<int>("n_tries");
35+
// if (!msg)
36+
// {
37+
// throw BT::RuntimeError("missing required input [n_tries]: ",
38+
// msg.error() );
39+
// }
40+
//
41+
// // use the method value() to extract the valid message.
42+
// std::cout << "Robot says: " << msg.value() << std::endl;
43+
// return BT::NodeStatus::SUCCESS;
44+
// }
45+
//};
46+
47+
int main(int argc, char** argv)
48+
{
49+
BT::BehaviorTreeFactory factory;
50+
factory.registerSimpleCondition("start", std::bind(start));
51+
factory.registerSimpleCondition("stop", std::bind(stop));
52+
// factory.registerNodeType<Repeat>("Repeat");
53+
factory.registerSimpleCondition("final_stop", std::bind(final_stop));
54+
55+
auto tree = factory.createTreeFromFile(BT_XML_PATH);
56+
tree.tickRoot();
57+
58+
return 0;
59+
}

0 commit comments

Comments
 (0)