Skip to content

Commit d06687c

Browse files
11 implement osi validation check against a set of rules (#12)
* Add test generating output trace files Signed-off-by: ClemensLinnhoff <[email protected]> * Workaroung for crashing pipeline during esmini checkout Signed-off-by: ClemensLinnhoff <[email protected]> * Enable multiple trace files Signed-off-by: ClemensLinnhoff <[email protected]> * Put multiple trace files in zip to add as artifact Signed-off-by: ClemensLinnhoff <[email protected]> * Build osi-validation in pipeline Signed-off-by: ClemensLinnhoff <[email protected]> * Check every filename with default rules Signed-off-by: ClemensLinnhoff <[email protected]> * Fix if condition on osi-validation job Signed-off-by: ClemensLinnhoff <[email protected]> * Fix osi-validation caching Signed-off-by: ClemensLinnhoff <[email protected]> * Add branch of osi-validation Signed-off-by: ClemensLinnhoff <[email protected]> * Add rules Signed-off-by: ClemensLinnhoff <[email protected]> * Fix rules folder in pipeline Signed-off-by: ClemensLinnhoff <[email protected]> * Add input rules Signed-off-by: ClemensLinnhoff <[email protected]> * Add optional and required attributes to interface message description in readme Signed-off-by: ClemensLinnhoff <[email protected]> * Add input trace file checks Signed-off-by: ClemensLinnhoff <[email protected]> * Use osi-validation develop branch Signed-off-by: ClemensLinnhoff <[email protected]> * Replace input trace file in integration test 001 Signed-off-by: ClemensLinnhoff <[email protected]> * Remove field checker from pipeline Signed-off-by: ClemensLinnhoff <[email protected]> * Add velocity to input trace file Signed-off-by: ClemensLinnhoff <[email protected]> * Add orientation Signed-off-by: ClemensLinnhoff <[email protected]> * Remove checking out osi-validation develop branch. Signed-off-by: ClemensLinnhoff <[email protected]> * Update OSI submodule Signed-off-by: ClemensLinnhoff <[email protected]> --------- Signed-off-by: ClemensLinnhoff <[email protected]>
1 parent 3697293 commit d06687c

File tree

143 files changed

+6941
-114
lines changed

Some content is hidden

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

143 files changed

+6941
-114
lines changed
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build osi-validation
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build_esmini:
8+
name: Build osi-validation
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Cache osi-validation
13+
id: cache-osi-validation
14+
uses: actions/cache@v3
15+
with:
16+
path: /tmp/osi-validation
17+
key: ${{ runner.os }}-osi-validation
18+
19+
- name: Get osi-validation
20+
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
21+
working-directory: /tmp
22+
env:
23+
GIT_CLONE_PROTECTION_ACTIVE: false
24+
run: git clone https://github.com/OpenSimulationInterface/osi-validation.git
25+
26+
- name: Update Submodules
27+
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
28+
working-directory: /tmp/osi-validation
29+
run: git submodule update --init
30+
31+
- name: Build osi-validation
32+
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
33+
working-directory: /tmp/osi-validation
34+
run: |
35+
python3 -m venv .venv
36+
source .venv/bin/activate
37+
python3 -m pip install --upgrade pip
38+
python3 -m pip install -r requirements_develop.txt
39+
cd open-simulation-interface && python3 -m pip install . && cd ..
40+
python3 -m pip install -r requirements.txt
41+
python3 rules2yml.py -d rules
42+
python3 -m pip install .
43+
44+
- name: Generate default rules
45+
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
46+
working-directory: /tmp/osi-validation
47+
run: |
48+
source .venv/bin/activate
49+
python3 rules2yml.py
50+
51+
- name: Add Commit ID to Cache
52+
if: steps.cache-osi-validation.outputs.cache-hit != 'true'
53+
working-directory: /tmp/osi-validation
54+
run: |
55+
git rev-parse --short HEAD > commit-id.txt

.github/workflows/build_osi_field_checker.yml

-79
This file was deleted.

.github/workflows/cl2.yml

+69-17
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
name: Build esmini FMU
1717
uses: ./.github/workflows/build_esmini.yml
1818

19-
build_osi_field_checker_fmu:
20-
name: Build OSI Field Checker FMU
21-
uses: ./.github/workflows/build_osi_field_checker.yml
19+
build_osi-validation:
20+
name: Build osi-validation
21+
uses: ./.github/workflows/build_osi-validation.yml
2222

2323
build_openmcx:
2424
name: Build OpenMCx
@@ -39,7 +39,7 @@ jobs:
3939
matrix: ${{ steps.set-matrix.outputs.matrix }}
4040

4141
run_integration_test:
42-
needs: [build_tracefile_player, build_tracefile_writer, build_openmcx, build_osi_field_checker_fmu, build_esmini, generate_integration_test_paths]
42+
needs: [build_tracefile_player, build_tracefile_writer, build_openmcx, build_esmini, generate_integration_test_paths]
4343
name: Integration Test
4444
runs-on: ubuntu-latest
4545
strategy:
@@ -91,12 +91,12 @@ jobs:
9191
path: /tmp/esmini_fmu
9292
key: ${{ runner.os }}-esmini-fmu
9393

94-
- name: Cache OSI Field Checker
95-
id: cache-osi-field-checker
94+
- name: Cache osi-validation
95+
id: cache-osi-validation
9696
uses: actions/cache@v3
9797
with:
98-
path: /tmp/osi-field-checker
99-
key: ${{ runner.os }}-osi-field-checker
98+
path: /tmp/osi-validation
99+
key: ${{ runner.os }}-osi-validation
100100

101101
- name: Cache OpenMCx
102102
id: cache-openmcx
@@ -121,6 +121,35 @@ jobs:
121121
- name: Install dependencies
122122
run: sudo apt install -y libxml2-dev zlib1g-dev libzip-dev
123123

124+
- name: Check For Input Trace Files
125+
id: check-for-input-trace-files
126+
working-directory: ./test/integration/${{ matrix.path }}
127+
run: |
128+
( count=`ls -1 *.osi 2>/dev/null | wc -l`
129+
if [ $count == 0 ]; then
130+
echo No trace file found.
131+
echo "found_trace=0" >> $GITHUB_OUTPUT
132+
elif [ $count == 1 ]; then
133+
echo One trace file found.
134+
echo "found_trace=1" >> $GITHUB_OUTPUT
135+
filename=$(ls -1 *.osi)
136+
else
137+
echo More than one trace file.
138+
echo "found_trace=1" >> $GITHUB_OUTPUT
139+
fi
140+
)
141+
142+
- name: Check Input Trace Files with osi-validation and model output rules
143+
if: steps.check-for-input-trace-files.outputs.found_trace == 1
144+
run: |
145+
if [ -d "./rules/input_rules" ]; then
146+
source /tmp/osi-validation/.venv/bin/activate
147+
for filename in ./test/integration/${{ matrix.path }}/*.osi; do
148+
osivalidator --rules ./rules/input_rules --data ${filename}
149+
done
150+
else echo "No custom input rules found in ./rules/input_rules";
151+
fi
152+
124153
- name: Create Output Folder
125154
working-directory: ./test/integration/${{ matrix.path }}
126155
run: mkdir output
@@ -129,31 +158,54 @@ jobs:
129158
id: cosimulation
130159
run: ./openmcx/install/openmcx ./test/integration/${{ matrix.path }}/SystemStructure.ssd
131160

132-
- name: Check For Trace Files
133-
id: check-for-trace-files
161+
- name: Check For Output Trace Files
162+
id: check-for-output-trace-files
134163
working-directory: ./test/integration/${{ matrix.path }}/output
135164
run: |
136165
( count=`ls -1 *.osi 2>/dev/null | wc -l`
137166
if [ $count == 0 ]; then
138167
echo No trace file found.
139168
echo "found_trace=0" >> $GITHUB_OUTPUT
140169
elif [ $count == 1 ]; then
170+
echo One trace file found.
141171
echo "found_trace=1" >> $GITHUB_OUTPUT
142172
filename=$(ls -1 *.osi)
143173
echo "trace_file_name=${filename}" >> $GITHUB_OUTPUT
144174
else
145175
echo More than one trace file.
146-
echo "found_trace=0" >> $GITHUB_OUTPUT
176+
echo "found_trace=1" >> $GITHUB_OUTPUT
177+
zip ${{ matrix.path }}.zip *.osi
178+
echo "trace_file_name=${{ matrix.path }}.zip" >> $GITHUB_OUTPUT
147179
fi
148180
)
149181
150-
- name: Archive Trace File
151-
if: steps.check-for-trace-files.outputs.found_trace == 1
182+
- name: Archive Output Trace Files
183+
if: steps.check-for-output-trace-files.outputs.found_trace == 1
152184
uses: actions/upload-artifact@v3
153185
with:
154-
name: ${{ steps.check-for-trace-files.outputs.trace_file_name }}
155-
path: ./test/integration/${{ matrix.path }}/output/${{ steps.check-for-trace-files.outputs.trace_file_name }}
156-
186+
name: ${{ steps.check-for-output-trace-files.outputs.trace_file_name }}
187+
path: ./test/integration/${{ matrix.path }}/output/${{ steps.check-for-output-trace-files.outputs.trace_file_name }}
188+
189+
- name: Check Output Trace Files with osi-validation and default rules
190+
if: steps.check-for-output-trace-files.outputs.found_trace == 1
191+
working-directory: ./test/integration/${{ matrix.path }}/output
192+
run: |
193+
source /tmp/osi-validation/.venv/bin/activate
194+
for filename in ./*.osi; do
195+
osivalidator --rules /tmp/osi-validation/rules/ --data ${filename}
196+
done
197+
198+
- name: Check Output Trace Files with osi-validation and model output rules
199+
if: steps.check-for-output-trace-files.outputs.found_trace == 1
200+
run: |
201+
if [ -d "./rules/output_rules" ]; then
202+
source /tmp/osi-validation/.venv/bin/activate
203+
for filename in ./test/integration/${{ matrix.path }}/output/*.osi; do
204+
osivalidator --rules ./rules/output_rules --data ${filename}
205+
done
206+
else echo "No custom output rules found in ./rules/output_rules";
207+
fi
208+
157209
- name: Check For Python Scripts
158210
id: check-for-python-scripts
159211
working-directory: ./test/integration/${{ matrix.path }}
@@ -186,7 +238,7 @@ jobs:
186238
- name: Run Trace File Analysis
187239
if: steps.check-for-python-scripts.outputs.found_script == 1
188240
working-directory: ./test/integration/${{ matrix.path }}
189-
run: python3 ${{ steps.check-for-python-scripts.outputs.python_file_name }} output/${{ steps.check-for-trace-files.outputs.trace_file_name }}
241+
run: python3 ${{ steps.check-for-python-scripts.outputs.python_file_name }} output/${{ steps.check-for-output-trace-files.outputs.trace_file_name }}
190242

191243
- name: Failed?
192244
if: steps.cosimulation.outputs.failed == 1

README.md

+21-17
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,33 @@ Each parameter should have a short description as shown in the following example
3737
## Interface
3838

3939
What interfaces are used as model input and model output?
40-
All required field of the interface shall be named in a list as shown in the following example.
40+
All required and optional messages of the interface shall be named in a list as shown in the following example.
4141

4242
### Input: Required Fields in osi3::SensorView and/or osi3::TrafficCommand
4343

44-
* `sensor_view.global_ground_truth.timestamp`
45-
* `sensor_view.global_ground_truth.host_vehicle_id`
46-
* `sensor_view.global_ground_truth.moving_object.id`
47-
* `sensor_view.global_ground_truth.moving_object.base.position`
48-
* `sensor_view.global_ground_truth.moving_object.base.orientation`
49-
* `sensor_view.global_ground_truth.moving_object.base.velocity`
50-
* `traffic_command.traffic_participant_id`
51-
* `traffic_command.action`
44+
| OSI Message | Required / Optional |
45+
|------------------------------------------------------------------|---------------------|
46+
| `sensor_view.global_ground_truth.timestamp` | required |
47+
| `sensor_view.global_ground_truth.host_vehicle_id` | required |
48+
| `sensor_view.global_ground_truth.moving_object.id` | required |
49+
| `sensor_view.global_ground_truth.moving_object.base.position` | required |
50+
| `sensor_view.global_ground_truth.moving_object.base.orientation` | required |
51+
| `sensor_view.global_ground_truth.moving_object.base.velocity` | required |
52+
| `traffic_command.traffic_participant_id` | required |
53+
| `traffic_command.action` | optional |
5254

5355
### Output: Fields in osi3::TrafficUpdate and/or osi3::TrafficCommandUpdate filled by the Model
5456

55-
* `traffic_update.version`
56-
* `traffic_update.timestamp`
57-
* `traffic_update.update.base.position`
58-
* `traffic_update.update.base.orientation`
59-
* `traffic_update.update.base.velocity`
60-
* `traffic_command_update.version`
61-
* `traffic_command_update.timestamp`
62-
* `traffic_command_update.dismissed_action`
57+
| OSI Message | Required / Optional |
58+
|-------------------------------------------|---------------------|
59+
| `traffic_update.version` | required |
60+
| `traffic_update.timestamp` | required |
61+
| `traffic_update.update.base.position` | required |
62+
| `traffic_update.update.base.orientation` | required |
63+
| `traffic_update.update.base.velocity` | required |
64+
| `traffic_command_update.version` | required |
65+
| `traffic_command_update.timestamp` | required |
66+
| `traffic_command_update.dismissed_action` | optional |
6367

6468
## Build Instructions
6569

lib/open-simulation-interface

0 commit comments

Comments
 (0)