-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bugs converting conditional transitions to jani (#60)
* Solve bug causing conditional transition guards to be always false in some cases * Add test for correct import of properties in jani * Update installation instructions --------- Signed-off-by: Marco Lampacrescia <[email protected]>
- Loading branch information
1 parent
f8cc7d2
commit e92c7d4
Showing
12 changed files
with
196 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,4 @@ API | |
:template: custom-module-template.rst | ||
:recursive: | ||
|
||
as2fm_common | ||
jani_generator | ||
scxml_converter | ||
as2fm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/jani_generator/_test_data/conditional_transitions/counter.scxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scxml | ||
initial="increase" | ||
version="1.0" | ||
name="Counter" | ||
model_src="" | ||
xmlns="http://www.w3.org/2005/07/scxml"> | ||
|
||
<datamodel> | ||
<data id="counter" expr="0" type="int16" /> | ||
</datamodel> | ||
|
||
<state id="increase"> | ||
<onentry> | ||
<send event="counter"> | ||
<param name="data" expr="counter" /> | ||
</send> | ||
</onentry> | ||
<transition target="increase"> | ||
<assign location="counter" expr="counter + 1" /> | ||
</transition> | ||
</state> | ||
</scxml> |
14 changes: 14 additions & 0 deletions
14
test/jani_generator/_test_data/conditional_transitions/main.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<convince_mc_tc> | ||
<mc_parameters> | ||
<max_time value="100" unit="s" /> | ||
</mc_parameters> | ||
|
||
<node_models> | ||
<input type="ros-scxml" src="./counter.scxml" /> | ||
<input type="ros-scxml" src="./receiver.scxml" /> | ||
</node_models> | ||
|
||
<properties> | ||
<input type="jani" src="./properties.jani" /> | ||
</properties> | ||
</convince_mc_tc> |
42 changes: 42 additions & 0 deletions
42
test/jani_generator/_test_data/conditional_transitions/properties.jani
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"properties": [ | ||
{ | ||
"name": "destination_reached", | ||
"expression": { | ||
"op": "filter", | ||
"fun": "values", | ||
"values": { | ||
"op": "Pmin", | ||
"exp": { | ||
"op": "U", | ||
"left": { | ||
"op": "⇒", | ||
"left": { | ||
"op": ">", | ||
"left": 0, | ||
"right": 0 | ||
}, | ||
"right": { | ||
"op": ">", | ||
"left": 0, | ||
"right": 0 | ||
} | ||
}, | ||
"right": { | ||
"op": "∧", | ||
"left": { | ||
"op": ">", | ||
"left": "counter.data", | ||
"right": 9 | ||
}, | ||
"right": "success.valid" | ||
} | ||
} | ||
}, | ||
"states": { | ||
"op": "initial" | ||
} | ||
} | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
test/jani_generator/_test_data/conditional_transitions/receiver.scxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<scxml | ||
initial="check_counter" | ||
version="1.0" | ||
name="Receiver" | ||
model_src="" | ||
xmlns="http://www.w3.org/2005/07/scxml"> | ||
|
||
<state id="check_counter"> | ||
<transition event="counter" target="check_counter" cond="_event.data < 10" /> | ||
<transition event="counter" target="done" cond="_event.data >= 10"> | ||
<send event="success" /> | ||
</transition> | ||
</state> | ||
|
||
<state id="done" /> | ||
</scxml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2024 - for information on the respective copyright owner | ||
# see the NOTICE file | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
Some test utils | ||
""" | ||
|
||
import json | ||
import os | ||
|
||
|
||
def json_jani_properties_match(path1: str, path2: str) -> bool: | ||
"""Compare the property definition from 2 json files. Return true if they match.""" | ||
assert os.path.exists(path1), f"Error: Path {path1} does not exist." | ||
assert os.path.exists(path2), f"Error: Path {path2} does not exist." | ||
with open(path1, "r", encoding="utf-8") as file: | ||
property1 = json.load(file)["properties"] | ||
with open(path2, "r", encoding="utf-8") as file: | ||
property2 = json.load(file)["properties"] | ||
return property1 == property2 |