Skip to content

Commit 0655c67

Browse files
Fixes for seat-adjuster example (#85)
1 parent 4191bb9 commit 0655c67

File tree

6 files changed

+55
-17
lines changed

6 files changed

+55
-17
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ The `Vehicle App SDK` reduces the effort required to implement Vehicle Apps by u
1010

1111
This includes the following packages:
1212

13+
* [sdv.vehicle_app](./sdv/vehicle_app.py) - Vehicle App abstraction
1314
* [sdv.model](./sdv/model.py) - Vehicle Model ontology
15+
* [sdv.config](./sdv/config.py) - Vehicle App configuration
16+
* [sdv.base](./sdv/base.py) - Base classes for middleware abstraction
1417
* [sdv.dapr](./sdv/dapr) - Dapr middleware integration
15-
* [sdv.conf](./sdv/config.py) - Vehicle App configuration
16-
* [sdv.vehicle_app](./sdv/vehicle_app.py) - Vehicle App abstraction
18+
* [sdv.native](./sdv/native) - Native middleware definition
1719
* [sdv.vdb](./sdv/vdb) - Vehicle Data Broker integration
1820
* [sdv.test](./sdv/test) - Integration test support
1921
* [sdv.util](./sdv/util) - Logging and other utilities
@@ -52,7 +54,7 @@ These examples demonstrate how to use the Python Vehicle App SDK:
5254
| [Dynamic Rule](./examples/dynamic-rule/) | Create a Vehicle Data Broker rule with the fluent query methods.
5355
| [Static Rule](./examples/static-rule/) | Create a Vehicle Data Broker rule with the subscribe_to_data_point annotation.
5456
| [VDB Queries](./examples/vdb-queries/) | Demonstrates various aspects of creating Vehicle Data Broker queries.
55-
| [Seat Adjuster](./examples/seat-adjuster/) | Seat-Adjuster App that demonstrates MQTT communication and seat control via actuator data points.<br>(i) This example can only be run from the [Vehicle App Template](https://github.com/eclipse-velocitas/vehicle-app-python-template).
57+
| [Seat Adjuster](./examples/seat-adjuster/) | Seat-Adjuster App that demonstrates MQTT communication and seat control via actuator data points.<br>:point_right: This example can only be run from the [Vehicle App Template](https://github.com/eclipse-velocitas/vehicle-app-python-template). :point_left:
5658

5759
All examples (except the Seat Adjuster) can be run via
5860
```bash

examples/seat-adjuster/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ FROM --platform=$TARGETPLATFORM python:3.10-slim-bullseye@sha256:1ee6094f44c6778
2020
RUN apt-get update && apt-get install -y binutils
2121

2222
COPY ./app /app
23+
COPY ./gen/vehicle_model /vehicle_model
2324

2425
# Remove this installation for Arm64 once staticx has a prebuilt wheel for Arm64
2526
RUN /bin/bash -c 'set -ex && \
@@ -31,11 +32,12 @@ RUN /bin/bash -c 'set -ex && \
3132
fi'
3233

3334
RUN apt-get install -y git
34-
RUN pip3 install --no-cache-dir pyinstaller \
35+
RUN pip3 install --no-cache-dir pyinstaller==5.9.0 \
3536
&& pip3 install --no-cache-dir patchelf==0.17.0.0 \
3637
&& pip3 install --no-cache-dir staticx \
3738
&& pip3 install --no-cache-dir -r ./app/requirements.txt \
38-
&& pip3 install --no-cache-dir -r ./app/requirements-links.txt
39+
&& pip3 install --no-cache-dir -r ./app/requirements-links.txt \
40+
&& pip3 install --no-cache-dir /vehicle_model
3941

4042
WORKDIR /app
4143

examples/seat-adjuster/README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,48 @@
11
# Seat-adjuster example
22

3+
:warning: This example is currently not executable from within the vehicle-app-pytthon-sdk's devContainer. Please use the "import example" feature of the related [vehicle-app-python-template repository](https://github.com/eclipse-velocitas/vehicle-app-python-template). Also, building the docker container for this example needs to be done after the import within the Python template's devContainer.
34

4-
## Launch the seat-adjuster example
55

6-
```bash
7-
cd examples/seat-adjuster/src
6+
## Run this example from your Python app development repo
87

9-
dapr run --app-id seatadjuster --app-protocol grpc --app-port 50008 --config ../../.dapr/config.yaml --resources-path ../../.dapr/components python3 main.py
8+
It is possible to import and run this example from your app development repository, which you already have created or could create from our [vehicle-app-python-template repository](https://github.com/eclipse-velocitas/vehicle-app-python-template).
9+
10+
1. Importing the example
11+
12+
Use the VS Code task `Import example app from SDK` (to get there press `Ctrl+Shift+P` and select `Tasks: Run Task`) and choose `seat-adjuster` from the list.
13+
14+
:warning: Make sure you have commited or stash all your possible changes within the `app` folder, because the files of that folder will be overwritten by the files of this example.
15+
16+
2. Running this example with Dapr middleware
17+
18+
Use the VS Code tasks `Local Runtime - Up` and `Local Runtime - Run VehicleApp` to start the necessary runtime components and this app itself.
19+
20+
Alternatively, the app can also be deployed in a k3d runtime - use task `K3D Runtime - Deploy VehicleApp`.
21+
22+
23+
## Executing with "native" middleware (without Dapr runtime)
24+
25+
If you like to run this example without using Dapr as middleware, you may need to provide some environment variables to the seat-adjuster process, which define the middleware type being _native_ and where to find the required runtime components:
26+
27+
| Variable name | Default value | Description
28+
|---------------------------------|----------------------------|-------------
29+
| `SDV_MIDDLEWARE_TYPE` | `"dapr"` | Defines the middleware type -> set to `"native"`
30+
| `SDV_MQTT_ADDRESS` | `"mqtt://localhost:1883"` | Address (and port) of the MQTT broker
31+
| `SDV_VEHICLEDATABROKER_ADDRESS` | `"grpc://localhost:55555"` | Address (and port) of the KUKSA Data Broker
32+
33+
34+
## Building a Docker image
35+
36+
This example app provides a Dockerfile to enable creating a Docker container image to run it.
37+
The image must be build passing the repositories root folder as build context, e.g.:
38+
39+
``` bash
40+
docker build -f app/Dockerfile .
41+
```
42+
43+
:warning: If your build environment works behind (corporate) **proxy**, please remember telling docker your proxy configuration.
44+
If you've set the respective environment variables, this might work:
45+
46+
``` bash
47+
docker build -f app/Dockerfile . --build-arg http_proxy --build-arg HTTP_PROXY --build-arg https_proxy --build-arg HTTPS_PROXY --build-arg no_proxy --build-arg NO_PROXY
1048
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
git+https://github.com/eclipse-velocitas/[email protected].0
1+
git+https://github.com/eclipse-velocitas/[email protected].1

examples/seat-adjuster/src/main.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(self, vehicle_client: Vehicle):
5353

5454
async def on_start(self):
5555
"""Run when the vehicle app starts"""
56-
await self.Vehicle.Cabin.Seat.Row(1).Pos(1).Position.subscribe(
56+
await self.Vehicle.Cabin.Seat.Row1.Pos1.Position.subscribe(
5757
self.on_seat_position_changed
5858
)
5959

@@ -62,11 +62,7 @@ async def on_seat_position_changed(self, data: DataPointReply):
6262
await self.publish_event(
6363
response_topic,
6464
json.dumps(
65-
{
66-
"position": data.get(
67-
self.Vehicle.Cabin.Seat.Row(1).Pos(1).Position
68-
).value
69-
}
65+
{"position": data.get(self.Vehicle.Cabin.Seat.Row1.Pos1.Position).value}
7066
),
7167
)
7268

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
setup(
7272
name="sdv",
73-
version="0.9.0",
73+
version="0.9.1",
7474
description="A Python SDK for Vehicle app",
7575
long_description=long_description,
7676
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)