Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hackathon #4

Merged
merged 101 commits into from
Jul 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
b51c4e3
Marcos Question
ct2034 Jun 12, 2024
6a6e637
Note on architecture
ct2034 Jun 14, 2024
36ab9ab
spelling, cleanup
ct2034 Jun 14, 2024
29d7858
empty files for future implementations
ct2034 Jun 14, 2024
3edcf05
adding return event to bt plugin implementation
ct2034 Jun 14, 2024
16caf95
Introduce initial scxml entries
MarcoLm993 Jun 14, 2024
b3c1ef8
Move files to correct folder and add missing entries
MarcoLm993 Jun 14, 2024
a56559c
Implement scxml param
MarcoLm993 Jun 14, 2024
9628def
Implement data and xml conversion for base scxml entries
MarcoLm993 Jun 14, 2024
911afdd
First untested version of scxml model
MarcoLm993 Jun 14, 2024
47fd779
Write system test
MarcoLm993 Jun 17, 2024
7f58f3a
Resolve cyclic dependencies using FW declaration
MarcoLm993 Jun 17, 2024
407c707
Running scxml_entries system test
MarcoLm993 Jun 17, 2024
7921177
Adapt system test for ros to plain scxml. Needs alignment
MarcoLm993 Jun 17, 2024
efad742
eof new line
ct2034 Jun 17, 2024
6cda6d7
instantiation of bt leaves
ct2034 Jun 17, 2024
b46b630
Small todo to get clarification
MarcoLm993 Jun 17, 2024
bbf997c
making plugin events unique
ct2034 Jun 17, 2024
99e25f6
first steps bt runtime
ct2034 Jun 18, 2024
151c892
Remove send targets
MarcoLm993 Jun 18, 2024
a1e5771
bt translation with events
ct2034 Jun 18, 2024
4093b4c
renaming ros-specific tags
ct2034 Jun 18, 2024
3bee6cb
Define Ros specific entries in separated file
MarcoLm993 Jun 18, 2024
ba31ff7
using ros tag in exmpl
ct2034 Jun 18, 2024
ce15acb
this is generated by the test
ct2034 Jun 18, 2024
f4a1858
asserting existence of file
ct2034 Jun 18, 2024
7c5210d
importing the ros rate timer from somewhere else
ct2034 Jun 18, 2024
eb86a3f
fixing line length
ct2034 Jun 18, 2024
50f5efc
formatting
ct2034 Jun 18, 2024
bd49f83
WIP: Implement ros entries
MarcoLm993 Jun 18, 2024
05f2f54
Rename method
MarcoLm993 Jun 18, 2024
47ce46f
adding RosTimeRate on module level
ct2034 Jun 18, 2024
15e65f3
Ros scxml continues
MarcoLm993 Jun 18, 2024
b80c789
Re-order init imports
MarcoLm993 Jun 18, 2024
a815450
reorganized all the tests
ct2034 Jun 18, 2024
6c59f4e
Handle ros declarations in scxml root
MarcoLm993 Jun 18, 2024
c36941e
moved test folder
ct2034 Jun 18, 2024
20b0112
Add missing ROS declaration
MarcoLm993 Jun 18, 2024
4dc6b69
implementing bt handling in main.xml
ct2034 Jun 18, 2024
1c575d6
Continue Ros entries
MarcoLm993 Jun 18, 2024
23ebee4
Complete implementation of ROS scxml entries
MarcoLm993 Jun 18, 2024
dfbbf2c
Add test for ROS scxml components
MarcoLm993 Jun 18, 2024
bc15a36
Linting scxml transition
MarcoLm993 Jun 19, 2024
91e7ed6
Document initial scxml to jani translation + linting some files
MarcoLm993 Jun 19, 2024
e8d9ab7
Push WIP
MarcoLm993 Jun 19, 2024
abb163b
implementation of receiving and sending event in the same transition
ct2034 Jun 19, 2024
5de8c31
fixing if / else in scxml syntax
ct2034 Jun 19, 2024
f60a34b
making sure to not use an old test product by accident
ct2034 Jun 19, 2024
32f764e
add a drawing on if handling
ct2034 Jun 26, 2024
a86daab
concept for if done
ct2034 Jun 26, 2024
f96a393
maybe solved a bug for edges without executable content
ct2034 Jun 26, 2024
1a713c2
Add symlink to graphics
MarcoLm993 Jun 26, 2024
99e5c36
WIP xml reader
MarcoLm993 Jun 26, 2024
939dad8
a workflow to test our python packages
ct2034 Jun 24, 2024
1511390
installing dev dependencies
ct2034 Jun 24, 2024
d83c927
manually setting up python
ct2034 Jun 24, 2024
bca0f7a
versions as strings
ct2034 Jun 24, 2024
3ee0f15
setting up ros
ct2034 Jun 24, 2024
c218110
we probably need the pytest-3 executable now
ct2034 Jun 24, 2024
fc603c9
installing storm
ct2034 Jun 24, 2024
77ef441
installing storm dependencies
ct2034 Jun 24, 2024
7d70e51
a test to make sure smc_storm can be called
ct2034 Jun 24, 2024
6d0f91a
installing bt_tools from source
ct2034 Jun 26, 2024
a68943f
Mörge branch 'main' into add/hackathon_240612
ct2034 Jun 26, 2024
38dc710
checking out workspace so pip doesnt complain that btlib is missing
ct2034 Jun 26, 2024
4f5a87a
always global path
ct2034 Jun 26, 2024
52bb39d
Implement parsers for datamodel and ros declarations
MarcoLm993 Jun 27, 2024
1be3385
Some polishing
MarcoLm993 Jun 27, 2024
f5e0e9d
WIP
MarcoLm993 Jun 27, 2024
b5a8450
Figure out how to access only direct children of xml element
MarcoLm993 Jun 27, 2024
48377f0
Implementing the If conversion
MarcoLm993 Jun 27, 2024
d9aaf48
Finish executable content conversion
MarcoLm993 Jun 28, 2024
f67040f
First complete implementation
MarcoLm993 Jun 28, 2024
8c6aa26
Initial debugging
MarcoLm993 Jun 28, 2024
656ac60
Fix order of ros declarations
MarcoLm993 Jun 28, 2024
8e5a8b5
Add missing parsing of ROS callbacks
MarcoLm993 Jun 28, 2024
6a89052
Try fixing test job
MarcoLm993 Jun 28, 2024
2c916f6
Fix If tag conversion
MarcoLm993 Jun 28, 2024
cfba14e
Add dependency installation for ROS pkgs
MarcoLm993 Jun 28, 2024
effde20
Do not test dependency repos
MarcoLm993 Jun 28, 2024
b4103ca
Add plain scxml check
MarcoLm993 Jul 1, 2024
1925a4e
Check ros macros validity and fix bug with empty datamodel
MarcoLm993 Jul 1, 2024
551afba
Fix msg import and add missing checks
MarcoLm993 Jul 1, 2024
8cf1f9f
Move RosDeclaration generation to separated method for reusability an…
MarcoLm993 Jul 1, 2024
07aef7d
Introduce ScxmlBase base cclass and prepare to_plain_scxml method
MarcoLm993 Jul 1, 2024
364a001
Implement basic structure of scxml de-rosification
MarcoLm993 Jul 1, 2024
3d7849c
Move utils to separate file for easier dependency tree
MarcoLm993 Jul 2, 2024
d547a1c
Finish conversion to plain scxml and replace previous one
MarcoLm993 Jul 2, 2024
da05638
Add condition for topic and rate callbacks
MarcoLm993 Jul 3, 2024
0e1a689
changing name to location in assign tag
ct2034 Jul 3, 2024
d7296da
implementing if's
ct2034 Jul 3, 2024
6bd9588
event fixes
ct2034 Jul 3, 2024
2f621b1
Make sure smc_storm terminates in the tests
MarcoLm993 Jul 4, 2024
13f63fb
First version passing the old tests
MarcoLm993 Jul 4, 2024
7b2f533
Green!
MarcoLm993 Jul 4, 2024
568c311
First complete and green version! Wohoo
MarcoLm993 Jul 4, 2024
8012a72
Re-enable timer in bt scxml and spotting more bugs
MarcoLm993 Jul 4, 2024
305f51b
correct expected output
ct2034 Jul 4, 2024
402491d
fix for if problem
ct2034 Jul 4, 2024
8db7e90
Fix GT file for in bt test and first battery drained and charged
MarcoLm993 Jul 4, 2024
56b11bf
Some more tests
MarcoLm993 Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: Implement ros entries
Signed-off-by: Marco Lampacrescia <marco.lampacrescia@de.bosch.com>
MarcoLm993 committed Jun 18, 2024
commit bd49f834dca5f6b33532015f0fd4444f665b54b8
4 changes: 1 addition & 3 deletions scxml_converter/src/scxml_converter/bt_converter.py
Original file line number Diff line number Diff line change
@@ -139,9 +139,7 @@ def bt_converter(
if target_id in leaf_node_ids:
event_name = bt_event_name(
target_id, BT_EVENT_TYPE.TICK)
transition.set_execution_body(
[ScxmlSend(event_name)]
)
transition.add_body_executable_entry(ScxmlSend(event_name))
state.add_transition(transition)
if node in ['success', 'failure', 'running']:
state.add_transition(
Original file line number Diff line number Diff line change
@@ -1,9 +1,89 @@
from scxml_converter.scxml_entries import ScxmlSend, ScxmlParam, ScxmlTransition
# 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.

"""Declaration of ROS-Specific SCXML tags extensions."""

from typing import Optional
from scxml_converter.scxml_entries import (ScxmlSend, ScxmlParam, ScxmlTransition,
ScxmlExecutionBody, valid_execution_body)
from xml.etree import ElementTree as ET


class RosTimeRate:
"""Declarative object used to define a new timer with its related tick rate."""

def __init__(self, name: str, rate_hz: float):
self._name = name
self._rate_hz = rate_hz
assert self.check_validity(), "Error: SCXML rate timer: invalid parameters."

def check_validity(self) -> bool:
valid_name = isinstance(self._name, str) and len(self._name) > 0
valid_rate = isinstance(self._rate_hz, float) and self._rate_hz > 0
if not valid_name:
print("Error: SCXML rate timer: name is not valid.")
if not valid_rate:
print("Error: SCXML rate timer: rate is not valid.")
return valid_name and valid_rate

def get_name(self) -> str:
return self._name

def get_rate(self) -> float:
return self._rate_hz

def as_xml(self) -> ET.Element:
assert self.check_validity(), "Error: SCXML rate timer: invalid parameters."
xml_time_rate = ET.Element(
"ros_time_rate", {"rate_hz": str(self._rate_hz), "name": self._name})
return xml_time_rate


class RosRateCallback(ScxmlTransition):
# TODO
pass
"""Callback that triggers each time the associated timer ticks."""

def __init__(self, timer: RosTimeRate, target: str, body: Optional[ScxmlExecutionBody] = None):
"""
Generate a new rate timer and callback.

Multiple rate callbacks can share the same timer name, but the rate must match.

:param timer_name: The name of the timer to use
:param rate_hz: The rate in Hz associated to the timer
:param target: The target state of the callback
:param body: The body of the callback
"""
self._timer_name = timer.get_name()
self._target = target
self._body = body
assert self.check_validity(), "Error: SCXML rate callback: invalid parameters."

def check_validity(self) -> bool:
valid_timer = isinstance(self._timer_name, str) and len(self._timer_name) > 0
valid_target = isinstance(self._target, str) and len(self._target) > 0
valid_body = self._body is None or valid_execution_body(self._body)
if not valid_timer:
print("Error: SCXML rate callback: timer name is not valid.")
if not valid_target:
print("Error: SCXML rate callback: target is not valid.")
if not valid_body:
print("Error: SCXML rate callback: body is not valid.")
return valid_timer and valid_target and valid_body

def as_xml(self) -> ET.Element:
pass


class RosTopicCallback(ScxmlTransition):
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ def __init__(self, id: str, *,

def get_id(self) -> str:
return self._id

def add_transition(self, transition: ScxmlTransition):
if self._body is None:
self._body = []
Original file line number Diff line number Diff line change
@@ -18,7 +18,8 @@
"""

from typing import List, Optional
from scxml_converter.scxml_entries import ScxmlExecutionBody, valid_execution_body
from scxml_converter.scxml_entries import (ScxmlExecutionBody, ScxmlExecutableEntries,
valid_execution_body)

from xml.etree import ElementTree as ET

@@ -27,7 +28,7 @@ class ScxmlTransition:
"""This class represents a single scxml state."""
def __init__(self,
target: str, events: Optional[List[str]] = None, condition: Optional[str] = None,
body: Optional[ScxmlExecutionBody] = None):
body: Optional[ScxmlExecutableEntries] = None):
"""
Generate a new transition. Currently, transitions must have a target.

@@ -53,9 +54,12 @@ def add_event(self, event: str):
self._events = []
self._events.append(event)

def set_execution_body(self, body: ScxmlExecutionBody):
assert valid_execution_body(body), "Error SCXML transition: invalid body provided."
self._body = body
def add_body_executable_entry(self, exec_entry: ScxmlExecutionBody):
if self._body is None:
self._body = []
self._body.append(exec_entry)
assert valid_execution_body(self._body), \
"Error SCXML transition: invalid body after extension."

def check_validity(self) -> bool:
valid_target = isinstance(self._target, str) and len(self._target) > 0