From 4d4409aff35518627c56c9c0e0bebf99dd27a94e Mon Sep 17 00:00:00 2001 From: Stefano Bernagozzi Date: Fri, 6 Mar 2026 17:09:43 +0100 Subject: [PATCH 1/2] removed unused variables and fixed issues, now it is working Signed-off-by: Stefano Bernagozzi --- .../bt_control_nodes/if_then_else.ascxml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/as2fm/resources/bt_control_nodes/if_then_else.ascxml b/src/as2fm/resources/bt_control_nodes/if_then_else.ascxml index b419066d..cb546b66 100644 --- a/src/as2fm/resources/bt_control_nodes/if_then_else.ascxml +++ b/src/as2fm/resources/bt_control_nodes/if_then_else.ascxml @@ -38,24 +38,24 @@ - - + + - - + + - - + + - + - - - + + + @@ -86,11 +86,11 @@ - + - + From 9d52ac6aa5114ce6165ce58394ffd302f1806e77 Mon Sep 17 00:00:00 2001 From: Christian Henkel Date: Thu, 12 Mar 2026 16:37:30 +0100 Subject: [PATCH 2/2] adding tests for ifthenelse Signed-off-by: Christian Henkel --- .../bt_test_ifthenelse_else.xml | 14 ++++ .../bt_test_ifthenelse_then.xml | 14 ++++ .../main_test_ifthenelse_else.xml | 16 ++++ .../main_test_ifthenelse_then.xml | 16 ++++ .../property_test_ifthenelse.jani | 84 +++++++++++++++++++ .../test_systemtest_behavior_tree_scxml.py | 32 +++++++ 6 files changed, 176 insertions(+) create mode 100644 test/jani_generator/_test_data/bt_test_models/bt_test_ifthenelse_else.xml create mode 100644 test/jani_generator/_test_data/bt_test_models/bt_test_ifthenelse_then.xml create mode 100644 test/jani_generator/_test_data/bt_test_models/main_test_ifthenelse_else.xml create mode 100644 test/jani_generator/_test_data/bt_test_models/main_test_ifthenelse_then.xml create mode 100644 test/jani_generator/_test_data/bt_test_models/property_test_ifthenelse.jani diff --git a/test/jani_generator/_test_data/bt_test_models/bt_test_ifthenelse_else.xml b/test/jani_generator/_test_data/bt_test_models/bt_test_ifthenelse_else.xml new file mode 100644 index 00000000..ccccf34b --- /dev/null +++ b/test/jani_generator/_test_data/bt_test_models/bt_test_ifthenelse_else.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/test/jani_generator/_test_data/bt_test_models/bt_test_ifthenelse_then.xml b/test/jani_generator/_test_data/bt_test_models/bt_test_ifthenelse_then.xml new file mode 100644 index 00000000..ad772abe --- /dev/null +++ b/test/jani_generator/_test_data/bt_test_models/bt_test_ifthenelse_then.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/test/jani_generator/_test_data/bt_test_models/main_test_ifthenelse_else.xml b/test/jani_generator/_test_data/bt_test_models/main_test_ifthenelse_else.xml new file mode 100644 index 00000000..ece28fe3 --- /dev/null +++ b/test/jani_generator/_test_data/bt_test_models/main_test_ifthenelse_else.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/test/jani_generator/_test_data/bt_test_models/main_test_ifthenelse_then.xml b/test/jani_generator/_test_data/bt_test_models/main_test_ifthenelse_then.xml new file mode 100644 index 00000000..a27aefe6 --- /dev/null +++ b/test/jani_generator/_test_data/bt_test_models/main_test_ifthenelse_then.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/test/jani_generator/_test_data/bt_test_models/property_test_ifthenelse.jani b/test/jani_generator/_test_data/bt_test_models/property_test_ifthenelse.jani new file mode 100644 index 00000000..78fdbfaa --- /dev/null +++ b/test/jani_generator/_test_data/bt_test_models/property_test_ifthenelse.jani @@ -0,0 +1,84 @@ +{ + "properties": [ + { + "expression": { + "fun": "values", + "op": "filter", + "states": { + "op": "initial" + }, + "values": { + "exp": { + "exp": { + "comment": "Bt 1000 is always the root, Values = {1: SUCCESS, 2: FAILURE, 3: RUNNING}", + "left": "bt_1000_response__status", + "op": "=", + "right": 1 + }, + "op": "F" + }, + "op": "Pmin" + } + }, + "name": "tree_success" + }, + { + "expression": { + "fun": "values", + "op": "filter", + "states": { + "op": "initial" + }, + "values": { + "exp": { + "exp": { + "comment": "10 ticks to the then branch and the else branch should have never had a message.", + "left": { + "left": "topic_tick_count_then_msg__ros_fields__data", + "op": "=", + "right": 10 + }, + "op": "∧", + "right": { + "exp": "topic_tick_count_else_msg.valid", + "op": "¬" + } + }, + "op": "F" + }, + "op": "Pmin" + } + }, + "name": "counter_then_10" + }, + { + "expression": { + "fun": "values", + "op": "filter", + "states": { + "op": "initial" + }, + "values": { + "exp": { + "exp": { + "comment": "10 ticks to the else branch and the then branch should have never had a message.", + "left": { + "left": "topic_tick_count_else_msg__ros_fields__data", + "op": "=", + "right": 10 + }, + "op": "∧", + "right": { + "exp": "topic_tick_count_then_msg.valid", + "op": "¬" + } + }, + "op": "F" + }, + "op": "Pmin" + } + }, + "name": "counter_else_10" + } + ] +} diff --git a/test/jani_generator/test_systemtest_behavior_tree_scxml.py b/test/jani_generator/test_systemtest_behavior_tree_scxml.py index 3701b2fc..bff49caa 100644 --- a/test/jani_generator/test_systemtest_behavior_tree_scxml.py +++ b/test/jani_generator/test_systemtest_behavior_tree_scxml.py @@ -112,6 +112,38 @@ def test_repeat(self): expected_result_probability=1.0, ) + def test_ifthenelse_then_tree_success(self): + """Test the ifthenelse BT plugins then branch for tree success.""" + self._test_with_main( + os.path.join("bt_test_models", "main_test_ifthenelse_then.xml"), + "tree_success", + expected_result_probability=1.0, + ) + + def test_ifthenelse_then_counter(self): + """Test the ifthenelse BT plugins then branch for correct number of ticks.""" + self._test_with_main( + os.path.join("bt_test_models", "main_test_ifthenelse_then.xml"), + "counter_then_10", + expected_result_probability=1.0, + ) + + def test_ifthenelse_else_tree_success(self): + """Test the ifthenelse BT plugins else branch for tree success.""" + self._test_with_main( + os.path.join("bt_test_models", "main_test_ifthenelse_else.xml"), + "tree_success", + expected_result_probability=1.0, + ) + + def test_ifthenelse_else_counter(self): + """Test the ifthenelse BT plugins else branch for correct number of ticks.""" + self._test_with_main( + os.path.join("bt_test_models", "main_test_ifthenelse_else.xml"), + "counter_else_10", + expected_result_probability=1.0, + ) + if __name__ == "__main__": pytest.main(["-s", "-v", __file__])