2
2
3
3
#include " behaviortree_cpp/scripting/operators.hpp"
4
4
#include " behaviortree_cpp/bt_factory.h"
5
+ #include " ../sample_nodes/dummy_nodes.h"
6
+
5
7
#include < lexy/input/string_input.hpp>
6
8
7
9
TEST (ParserTest, AnyTypes)
@@ -254,7 +256,11 @@ enum DeviceType { BATT=1, CONTROLLER=2 };
254
256
BT::NodeStatus checkLevel (BT::TreeNode &self)
255
257
{
256
258
double percent = self.getInput <double >(" percentage" ).value ();
257
- DeviceType devType = self.getInput <DeviceType>(" deviceType" ).value ();
259
+ DeviceType devType;
260
+ auto res = self.getInput (" deviceType" , devType);
261
+ if (!res) {
262
+ throw std::runtime_error (res.error ());
263
+ }
258
264
259
265
if (devType == DeviceType::BATT)
260
266
{
@@ -271,13 +277,19 @@ TEST(ParserTest, Enums_Issue_523)
271
277
const std::string xml_text = R"(
272
278
<root BTCPP_format="4" >
273
279
<BehaviorTree ID="PowerManagerT">
274
- <Sequence>
275
- <Script code=" deviceA:=BATT; deviceB:=CONTROLLER; LOW_BATT:=20 "/>
276
- <CheckLevel deviceType="{deviceA}" percentage="{LOW_BATT}" isLowBattery="{isLowBattery}"/>
277
- </Sequence>
280
+ <ReactiveSequence>
281
+ <Script code=" deviceA:=BATT; deviceB:=CONTROLLER; battery_level:=30 "/>
282
+ <CheckLevel deviceType="{deviceA}" percentage="{battery_level}" isLowBattery="{isLowBattery}"/>
283
+ <SaySomething message="FIRST low batteries!" _skipIf="!isLowBattery" />
284
+
285
+ <Script code=" battery_level:=20 "/>
286
+ <CheckLevel deviceType="{deviceA}" percentage="{battery_level}" isLowBattery="{isLowBattery}"/>
287
+ <SaySomething message="SECOND low batteries!" _skipIf="!isLowBattery" />
288
+ </ReactiveSequence>
278
289
</BehaviorTree>
279
290
</root> )" ;
280
291
292
+ factory.registerNodeType <DummyNodes::SaySomething>(" SaySomething" );
281
293
factory.registerSimpleCondition (" CheckLevel" , std::bind (checkLevel, std::placeholders::_1),
282
294
{ BT::InputPort (" percentage" ),
283
295
BT::InputPort (" deviceType" ),
0 commit comments