Skip to content

Commit bd9f9b7

Browse files
committed
features
1 parent 68ef3fe commit bd9f9b7

File tree

80 files changed

+5351
-0
lines changed

Some content is hidden

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

80 files changed

+5351
-0
lines changed

apps/example_app/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ghcr.io/eclipse-sdv-hackathon-chapter-two/shift2sdv/ecal_base:5.12
2+
3+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4+
# && apt-get -y install \
5+
# # add your packages here
6+
# # Cleanup
7+
# && rm -rf /var/lib/apt/lists/*
8+
9+
WORKDIR /usr/src/app
10+
11+
COPY ecal.ini /etc/ecal/
12+
13+
COPY requirements.txt ./
14+
RUN pip install --break-system-packages --no-cache-dir -r requirements.txt
15+
16+
COPY example_app.py ./
17+
18+
CMD [ "python3", "-u", "./example_app.py" ]

apps/example_app/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Example Application
2+
3+
The Example App show how data from the vehicle can be received by an application running in the vehicle.
4+
5+
## Build
6+
7+
When running `restart-shift2sdv`, or explicitly the `build-apps` script, the Example App will be build and containerized automatically as `ghcr.io/eclipse-sdv-hackathon-chapter-two/shift2sdv/example_app:latest`.
8+
9+
Of course, you are free to build manually if needed by calling the following command from the example_app folder:
10+
11+
```shell
12+
podman build -t example_app:latest .
13+
```
14+
15+
**Note:** Inside the test-vehicle the Example App will run on ARM-Platform. Test the build by running the command above and ask the hack coaches to build your image for ARM to run it inside the test vehicle.
16+
17+
## Running
18+
19+
The Example App is automatically started by Ankaios as there is an entry for it in the [shift2sdv_manifest.yaml](shift2sdv_manifest.yaml).
20+
21+
In the test vehicle the Example App container image will be started and managed by Eclipse Ankaios.
22+
23+
Talk to the hack coaches to build a multi-platform or ARM image before trying to run the app in the vehicle.
24+
25+
## Development
26+
27+
### Run
28+
29+
Start the app inside the devcontainer for local development:
30+
31+
```shell
32+
python3 example_app.py
33+
```
34+
35+
### Testing with mock data
36+
37+
Ask the hack coaches for an eCAL recording to play back a recorded driving scenario with eCAL and to receive the vehicle dynamics data in the Example App for development.
38+
39+
Place the downloaded eCAL recording in a `measurements/` folder next to the current file.
40+
41+
Start the eCAL recording within the devcontainer, replace `<recording_folder>` with the recording folder you received from the hack coaches:
42+
43+
```shell
44+
ecal_play -m measurements/<recording_folder>
45+
```
46+
47+
Start the Example App inside the devcontainer as shown above.
48+
49+
You should see logs of the JSON data received, and in the web browser the tachometer should show some speed values.
50+
51+
For debugging reasons you can start the eCAL Monitor terminal UI in a separate terminal window by running:
52+
53+
```shell
54+
ecal_mon_tui
55+
```
56+
57+
This lists all eCAL topics with their contents and meta information the host or container can see.

apps/example_app/ecal.ini

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
; --------------------------------------------------
2+
; NETWORK SETTINGS
3+
; --------------------------------------------------
4+
; network_enabled = true / false true = all eCAL components communicate over network boundaries
5+
; false = local host only communication
6+
;
7+
; multicast_config_version = v1 / v2 UDP configuration version (Since eCAL 5.12.)
8+
; v1: default behavior
9+
; v2: new behavior, comes with a bit more intuitive handling regarding masking of the groups
10+
; multicast_group = 239.0.0.1 UDP multicast group base
11+
; All registration and logging is sent on this address
12+
; multicast_mask = 0.0.0.1-0.0.0.255 v1: Mask maximum number of dynamic multicast group
13+
; 255.0.0.0-255.255.255.255 v2: masks are now considered like routes masking
14+
;
15+
; multicast_port = 14000 + x UDP multicast port number (eCAL will use at least the 2 following port
16+
; numbers too, so please modify in steps of 10 (e.g. 1010, 1020 ...)
17+
;
18+
; multicast_ttl = 0 + x UDP ttl value, also known as hop limit, is used in determining
19+
; the intermediate routers being traversed towards the destination
20+
;
21+
; multicast_sndbuf = 1024 * x UDP send buffer in bytes
22+
;
23+
; multicast_rcvbuf = 1024 * x UDP receive buffer in bytes
24+
;
25+
; multicast_join_all_if = false Linux specific setting to enable joining multicast groups on all network interfacs
26+
; independent of their link state. Enabling this makes sure that eCAL processes
27+
; receive data if they are started before network devices are up and running.
28+
;
29+
; bandwidth_max_udp = -1 UDP bandwidth limit for eCAL udp layer (-1 == unlimited)
30+
;
31+
; inproc_rec_enabled = true Enable to receive on eCAL inner process layer
32+
; shm_rec_enabled = true Enable to receive on eCAL shared memory layer
33+
; udp_mc_rec_enabled = true Enable to receive on eCAL udp multicast layer
34+
;
35+
; npcap_enabled = false Enable to receive UDP traffic with the Npcap based receiver
36+
;
37+
; tcp_pubsub_num_executor_reader = 4 Tcp_pubsub reader amount of threads that shall execute workload
38+
; tcp_pubsub_num_executor_writer = 4 Tcp_pubsub writer amount of threads that shall execute workload
39+
; tcp_pubsub_max_reconnections = 5 Tcp_pubsub reconnection attemps the session will try to reconnect in
40+
; case of an issue (a negative value means infinite reconnection attemps)
41+
;
42+
; host_group_name = Common host group name that enables interprocess mechanisms across
43+
; (virtual) host borders (e.g, Docker); by default equivalent to local host name
44+
; --------------------------------------------------
45+
46+
[network]
47+
network_enabled = true
48+
multicast_config_version = v1
49+
multicast_group = 239.0.0.1
50+
multicast_mask = 0.0.0.15
51+
multicast_port = 14000
52+
multicast_ttl = 2
53+
multicast_sndbuf = 5242880
54+
multicast_rcvbuf = 5242880
55+
56+
multicast_join_all_if = false
57+
58+
bandwidth_max_udp = -1
59+
60+
inproc_rec_enabled = true
61+
shm_rec_enabled = true
62+
tcp_rec_enabled = true
63+
udp_mc_rec_enabled = true
64+
65+
npcap_enabled = false
66+
67+
tcp_pubsub_num_executor_reader = 4
68+
tcp_pubsub_num_executor_writer = 4
69+
tcp_pubsub_max_reconnections = 5
70+
71+
host_group_name =
72+
73+
; --------------------------------------------------
74+
; COMMON SETTINGS
75+
; --------------------------------------------------
76+
; registration_timeout = 60000 Timeout for topic registration in ms (internal)
77+
; registration_refresh = 1000 Topic registration refresh cylce (has to be smaller then registration timeout !)
78+
79+
; --------------------------------------------------
80+
[common]
81+
registration_timeout = 60000
82+
registration_refresh = 1000
83+
84+
; --------------------------------------------------
85+
; TIME SETTINGS
86+
; --------------------------------------------------
87+
; timesync_module_rt = "ecaltime-localtime" Time synchronisation interface name (dynamic library)
88+
; The name will be extended with platform suffix (32|64), debug suffix (d) and platform extension (.dll|.so)
89+
;
90+
; Available modules are:
91+
; - ecaltime-localtime local system time without synchronization
92+
; - ecaltime-linuxptp For PTP / gPTP synchronization over ethernet on Linux
93+
; (device configuration in ecaltime.ini)
94+
; - ecaltime-simtime Simulation time as published by the eCAL Player.
95+
; --------------------------------------------------
96+
[time]
97+
timesync_module_rt = "ecaltime-localtime"
98+
99+
; ---------------------------------------------
100+
; PROCESS SETTINGS
101+
; ---------------------------------------------
102+
;
103+
; terminal_emulator = /usr/bin/x-terminal-emulator -e command for starting applications with an external terminal emulator. If empty, the command will be ignored. Ignored on Windows.
104+
; e.g. /usr/bin/x-terminal-emulator -e
105+
; /usr/bin/gnome-terminal -x
106+
; /usr/bin/xterm -e
107+
;
108+
; ---------------------------------------------
109+
[process]
110+
terminal_emulator =
111+
112+
; --------------------------------------------------
113+
; PUBLISHER SETTINGS
114+
; --------------------------------------------------
115+
; use_inproc = 0, 1, 2 Use inner process transport layer (0 = off, 1 = on, 2 = auto, default = 0)
116+
; use_shm = 0, 1, 2 Use shared memory transport layer (0 = off, 1 = on, 2 = auto, default = 2)
117+
; use_tcp = 0, 1, 2 Use tcp transport layer (0 = off, 1 = on, 2 = auto, default = 0)
118+
; use_udp_mc = 0, 1, 2 Use udp multicast transport layer (0 = off, 1 = on, 2 = auto, default = 2)
119+
;
120+
; memfile_minsize = x * 4096 kB Default memory file size for new publisher
121+
;
122+
; memfile_reserve = 50 .. x % Dynamic file size reserve before recreating memory file if topic size changes
123+
;
124+
; memfile_ack_timeout = 0 .. x ms Publisher timeout for ack event from subscriber that memory file content is processed
125+
;
126+
; memfile_buffer_count = 1 .. x Number of parallel used memory file buffers for 1:n publish/subscribe ipc connections (default = 1)
127+
; memfile_zero_copy = 0, 1 Allow matching subscriber to access memory file without copying its content in advance (blocking mode)
128+
;
129+
; share_ttype = 0, 1 Share topic type via registration layer
130+
; share_tdesc = 0, 1 Share topic description via registration layer (switch off to disable reflection)
131+
; --------------------------------------------------
132+
[publisher]
133+
use_inproc = 0
134+
use_shm = 2
135+
use_tcp = 0
136+
use_udp_mc = 2
137+
138+
memfile_minsize = 4096
139+
memfile_reserve = 50
140+
memfile_ack_timeout = 0
141+
memfile_buffer_count = 1
142+
memfile_zero_copy = 0
143+
144+
share_ttype = 1
145+
share_tdesc = 1
146+
147+
; --------------------------------------------------
148+
; MONITORING SETTINGS
149+
; --------------------------------------------------
150+
; timeout = 1000 + (x * 1000) Timeout for topic monitoring in ms
151+
; filter_excl = __.* Topics blacklist as regular expression (will not be monitored)
152+
; filter_incl = Topics whitelist as regular expression (will be monitored only)
153+
; filter_log_con = warning, error Log messages logged to console (all, info, warning, error, fatal, debug1, debug2, debug3, debug4)
154+
; filter_log_file = Log messages to logged into file system
155+
; filter_log_udp = warning, error, fatal Log messages logged via udp network
156+
; --------------------------------------------------
157+
[monitoring]
158+
timeout = 5000
159+
filter_excl = __.*
160+
filter_incl =
161+
filter_log_con = error, fatal, warning
162+
filter_log_file =
163+
filter_log_udp = info, warning, error, fatal
164+
165+
; --------------------------------------------------
166+
; SYS SETTINGS
167+
; --------------------------------------------------
168+
; filter_excl = App1,App2 Apps blacklist to be excluded when importing tasks from cloud
169+
; --------------------------------------------------
170+
[sys]
171+
filter_excl = ^eCALSysClient$|^eCALSysGUI$|^eCALSys$
172+
173+
; --------------------------------------------------
174+
; EXPERIMENTAL SETTINGS
175+
; --------------------------------------------------
176+
; shm_monitoring_enabled = false Enable distribution of monitoring/registration information via shared memory
177+
; shm_monitoring_domain = ecal_monitoring Domain name for shared memory based monitoring/registration
178+
; shm_monitoring_queue_size = 1024 Queue size of monitoring/registration events
179+
; network_monitoring_disabled = false Disable distribution of monitoring/registration information via network
180+
;
181+
; drop_out_of_order_messages = false Enable dropping of payload messages that arrive out of order
182+
; --------------------------------------------------
183+
[experimental]
184+
shm_monitoring_enabled = false
185+
shm_monitoring_domain = ecal_mon
186+
shm_monitoring_queue_size = 1024
187+
network_monitoring_disabled = false
188+
189+
drop_out_of_order_messages = false

apps/example_app/example_app.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright (c) 2024 Elektrobit Automotive GmbH and others
2+
3+
# This program and the accompanying materials are made available under the
4+
# terms of the Apache License, Version 2.0 which is available at
5+
# https://www.apache.org/licenses/LICENSE-2.0.
6+
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
# SPDX-License-Identifier: Apache-2.0
14+
15+
import sys, time, json, logging
16+
17+
import ecal.core.core as ecal_core
18+
from ecal.core.subscriber import StringSubscriber
19+
20+
logger = logging.getLogger("example_app")
21+
stdout = logging.StreamHandler(stream=sys.stdout)
22+
stdout.setLevel(logging.INFO)
23+
logger.addHandler(stdout)
24+
logger.setLevel(logging.INFO)
25+
26+
# Callback for receiving messages
27+
def callback(topic_name, msg, time):
28+
try:
29+
json_msg = json.loads(msg)
30+
print(f"Received: {msg}")
31+
except json.JSONDecodeError:
32+
logger.error(f"Error: Could not decode message: '{msg}'")
33+
except Exception as e:
34+
logger.error(f"Error: {e}")
35+
36+
if __name__ == "__main__":
37+
logger.info("Starting example app...")
38+
39+
# Initialize eCAL
40+
ecal_core.initialize(sys.argv, "Example App")
41+
42+
# Create a subscriber that listens on the "traffic_sign_detection"
43+
sub = StringSubscriber("vehicle_dynamics")
44+
45+
# Set the Callback
46+
sub.set_callback(callback)
47+
48+
# Just don't exit
49+
while ecal_core.ok():
50+
time.sleep(0.5)
51+
52+
# finalize eCAL API
53+
ecal_core.finalize()

apps/example_app/requirements.txt

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM ghcr.io/eclipse-sdv-hackathon-chapter-two/shift2sdv/ecal_base:5.12
2+
3+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4+
# && apt-get -y install \
5+
# # add your packages here
6+
# # Cleanup
7+
# && rm -rf /var/lib/apt/lists/*
8+
9+
WORKDIR /usr/src/app
10+
11+
COPY ecal.ini /etc/ecal/
12+
13+
COPY requirements.txt ./
14+
RUN pip install --break-system-packages --no-cache-dir -r requirements.txt
15+
16+
COPY main.py ./
17+
18+
CMD [ "python3", "-u", "./main.py" ]

0 commit comments

Comments
 (0)