Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 942ac93

Browse files
authored
Merge pull request #78 from SEAME-pt/76-task-deploy-workflow-for-raspberry-pi-repo
76 task deploy workflow for raspberry pi repo
2 parents fc725b1 + f496e69 commit 942ac93

163 files changed

Lines changed: 1051 additions & 12972 deletions

File tree

Some content is hidden

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

.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PROJECT_DIR=RaspberryPi
2+
PI_USERNAME=team02
3+
PI_IP_ADDRESS=100.68.239.7
4+
PI_PATH_BIN=/opt/vehicle/bin
5+
PI_PATH_ETC=/opt/vehicle/etc/zenoh
6+
PI_PATH_FONTS=/opt/vehicle/etc/fonts
7+
PI_PASSWORD=seameteam2

.github/workflows/deploy.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build and Deploy for Raspberry Pi
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
10+
jobs:
11+
build-and-deploy:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: false
19+
20+
- name: Set up QEMU
21+
uses: docker/setup-qemu-action@v2
22+
with:
23+
platforms: linux/arm64
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Build Docker image for ARM64
29+
run: |
30+
docker buildx build \
31+
-f ./RaspberryPi/deploy/dockerfiles/DockerfileDeployRasp \
32+
--platform linux/arm64 --load \
33+
--build-arg projectDir=$PWD/$PROJECT_DIR \
34+
-t final-app .
35+
36+
- name: Extract built binaries
37+
run: |
38+
mkdir -p artifacts/bin
39+
mkdir -p artifacts/config
40+
mkdir -p artifacts/fonts
41+
42+
docker create --name tmpapp final-app
43+
44+
docker cp tmpapp:/home/$PROJECT_DIR/InstrumentClusterApp ./artifacts/bin/
45+
docker cp tmpapp:/home/$PROJECT_DIR/MiddleWareApp ./artifacts/bin/
46+
47+
cp ./$PROJECT_DIR/ZenohConfig/InstrumentClusterConfig.json ./artifacts/config/
48+
cp ./$PROJECT_DIR/ZenohConfig/MiddleWareConfig.json ./artifacts/config/
49+
50+
cp -r ./RaspberryPi/deploy/fonts/* ./artifacts/fonts/
51+
52+
git archive --format=zip HEAD -o ./artifacts/source-code.zip
53+
54+
cd artifacts
55+
zip -r ../release-package.zip *
56+
cd ..
57+
58+
docker rm tmpapp
59+
60+
- name: Get latest tag and increment
61+
id: tag
62+
run: |
63+
git fetch --tags --force
64+
git fetch origin
65+
latest_tag=$(git tag --sort=-v:refname | head -n 1)
66+
if [ -z "$latest_tag" ]; then
67+
latest_tag="v1.0.0"
68+
fi
69+
major=$(echo $latest_tag | cut -d. -f1 | tr -d 'v')
70+
minor=$(echo $latest_tag | cut -d. -f2)
71+
patch=$(echo $latest_tag | cut -d. -f3)
72+
new_tag="v$major.$minor.$((patch + 1))"
73+
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
74+
75+
- name: Create GitHub Release
76+
uses: softprops/action-gh-release@v1
77+
with:
78+
tag_name: ${{ steps.tag.outputs.new_tag }}
79+
name: Release ${{ steps.tag.outputs.new_tag }}
80+
body: |
81+
## Raspberry Pi Release
82+
83+
**Includes:**
84+
- Compiled apps (`InstrumentClusterApp`, `MiddleWareApp`)
85+
- Zenoh config files
86+
- Fonts
87+
- Full source code zip
88+
89+
**Instructions:**
90+
- Copy `InstrumentClusterApp` and `MiddleWareApp` to `$PI_PATH_BIN`
91+
- Copy configs to `$PI_PATH_ETC`
92+
- Copy fonts to `$PI_PATH_FONTS`
93+
files: |
94+
release-package.zip
95+
artifacts/source-code.zip
96+
artifacts/bin/*
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.PAT_LUIS }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,10 @@ CMakeLists.txt.user*
7272
*.dll
7373
*.exe
7474

75+
# Build folders
76+
tests/build/
77+
deploy/build/
78+
deploy/.qt/
79+
deploy/deployLocal/build/
80+
81+

CMakeLists.txt

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,15 @@ find_package(Qt6 COMPONENTS Core Quick DBus REQUIRED)
1111
find_package(zenohc REQUIRED)
1212
find_package(zenohcxx REQUIRED)
1313

14-
# Enable Qt's Automatic MOC, UIC, and RCC
1514
set(CMAKE_AUTOMOC ON)
1615
set(CMAKE_AUTOUIC ON)
1716
set(CMAKE_AUTORCC ON)
1817

19-
# include_directories(Clusters/include)
2018
include_directories(Clusters/HandCluster/include)
21-
# Add Resource File (QML and Other Resources)
22-
# qt_add_resources(QT_RESOURCES_ICA ./Clusters/InstrumentCluster/ui/resources.qrc)
2319
qt_add_resources(QT_RESOURCES_HCA ./Clusters/HandCluster/ui/resources.qrc)
2420

25-
# Define Executable Target
26-
# add_executable(InstrumentClusterApp
27-
# ${QT_RESOURCES_ICA}
28-
# ./Clusters/InstrumentCluster/src/main.cpp
29-
# ./Clusters/InstrumentCluster/src/InstrumentCluster.cpp
30-
# ./Clusters/InstrumentCluster/include/InstrumentCluster.hpp
31-
# )
3221

33-
add_executable(HandClusterB
22+
add_executable(InstrumentClusterApp
3423
${QT_RESOURCES_HCA}
3524
./Clusters/HandCluster/src/main.cpp
3625
./Clusters/HandCluster/src/InstrumentCluster.cpp
@@ -41,8 +30,5 @@ add_executable(MiddleWareApp
4130
./MiddleWare/src/main.cpp
4231
)
4332

44-
# target_link_libraries(InstrumentClusterApp zenohcxx::zenohc -lm -ldl Qt6::Core Qt6::DBus Qt6::Quick)
45-
46-
target_link_libraries(HandClusterB zenohcxx::zenohc -lm -ldl Qt6::Core Qt6::DBus Qt6::Quick)
47-
target_link_libraries(MiddleWareApp PRIVATE zenohcxx::zenohc)
48-
target_compile_definitions(HandClusterTests PRIVATE UNIT_TEST)
33+
target_link_libraries(InstrumentClusterApp zenohcxx::zenohc -lm -ldl Qt6::Core Qt6::DBus Qt6::Quick)
34+
target_link_libraries(MiddleWareApp PRIVATE zenohcxx::zenohc)
15.6 KB
Loading

Clusters/HandCluster/include/InstrumentCluster.hpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class InstrumentCluster : public QObject
4545
Q_PROPERTY(QVariantMap rightLaneCoefs READ getRightLaneCoefs WRITE setRightLaneCoefs NOTIFY rightLaneChanged)
4646
Q_PROPERTY(QVariantList detectedObjects READ getDetectedObjects NOTIFY detectedObjectsUpdated)
4747
Q_PROPERTY(int warningCode READ getWarningCode WRITE setWarningCode NOTIFY warningCodeChanged)
48-
48+
Q_PROPERTY(bool laneDeparture READ getLaneDeparture WRITE setLaneDeparture NOTIFY laneDepartureChanged)
49+
Q_PROPERTY(int autonomyLevel READ getAutonomyLevel WRITE setAutonomyLevel NOTIFY autonomyLevelChanged)
4950

5051
private:
5152
int m_speed;
@@ -57,10 +58,12 @@ class InstrumentCluster : public QObject
5758
bool rearFogLight{false};
5859
bool hazardLight{false};
5960
bool parkingLight{false};
61+
bool laneDeparture{false};
6062
int percentage;
6163
int autonomy;
6264
int gear;
6365
int warningCode;
66+
int autonomyLevel;
6467

6568
QVariantMap m_leftLaneCoefs;
6669
QVariantMap m_rightLaneCoefs;
@@ -89,8 +92,12 @@ class InstrumentCluster : public QObject
8992
std::optional<zenoh::Subscriber<void>> leftLane_subscriber;
9093
std::optional<zenoh::Subscriber<void>> rightLane_subscriber;
9194
std::optional<zenoh::Subscriber<void>> object_subscriber;
92-
std::optional<zenoh::Subscriber<void>> warningCode_subscriber;
93-
95+
std::optional<zenoh::Subscriber<void>> laneDeparture_subscriber;
96+
std::optional<zenoh::Subscriber<void>> obstacleWarning_subscriber;
97+
std::optional<zenoh::Subscriber<void>> sae0_subscriber;
98+
std::optional<zenoh::Subscriber<void>> sae1_subscriber;
99+
std::optional<zenoh::Subscriber<void>> sae5_subscriber;
100+
94101
public:
95102
explicit InstrumentCluster(QObject* parent = nullptr);
96103
explicit InstrumentCluster(const std::string& configFile,
@@ -147,10 +154,16 @@ class InstrumentCluster : public QObject
147154
QVariantMap getRightLaneCoefs() const;
148155
void setRightLaneCoefs(const QVariantMap& coefs);
149156

157+
void setLaneDeparture(bool state);
158+
bool getLaneDeparture() const;
159+
150160
void parseLaneData(const std::string& laneData, const std::string& laneType);
151161
void parseObjectData(const std::string& objectData);
152162
// std::function<void(const zenoh::Sample&)> getSpeedCallback();
153163
void setupSubscriptions();
164+
165+
int getAutonomyLevel() const;
166+
void setAutonomyLevel(int level);
154167

155168
signals:
156169
void speedChanged(int speed);
@@ -170,6 +183,8 @@ class InstrumentCluster : public QObject
170183
void detectedObjectsUpdated(const QVariantList& objects);
171184
void warningCodeChanged(int code);
172185
void onSpeedSample(const zenoh::Sample& sample);
186+
void laneDepartureChanged(bool state);
187+
void autonomyLevelChanged(int level);
173188
#ifdef UNIT_TEST
174189
std::function<void(const zenoh::Sample&)> getSpeedCallback();
175190
#endif

Clusters/HandCluster/src/InstrumentCluster.cpp

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
InstrumentCluster::InstrumentCluster(QObject* parent)
88
: QObject(parent), m_speed(0), percentage(0), autonomy(0), gear(0)
99
{
10+
std::cout << "Using default configuration." << std::endl;
1011
auto config = zenoh::Config::create_default();
1112
session = std::make_unique<zenoh::Session>(
1213
zenoh::Session::open(std::move(config)));
@@ -17,8 +18,8 @@ InstrumentCluster::InstrumentCluster(const std::string& configFile,
1718
QObject* parent)
1819
: QObject(parent), m_speed(0), percentage(0), autonomy(0), gear(0)
1920
{
20-
21-
auto config = zenoh::Config::create_default();
21+
std::cout << "Using configuration file: " << configFile << std::endl;
22+
auto config = zenoh::Config::from_file(configFile);
2223
session = std::make_unique<zenoh::Session>(zenoh::Session::open(std::move(config)));
2324
this->setupSubscriptions();
2425
}
@@ -161,12 +162,42 @@ void InstrumentCluster::setupSubscriptions()
161162
parseObjectData(objectData);
162163
},
163164
zenoh::closures::none));
164-
warningCode_subscriber.emplace(session->declare_subscriber(
165-
"Vehicle/1/Scene/Warning",
165+
obstacleWarning_subscriber.emplace(session->declare_subscriber(
166+
"Vehicle/1/ADAS/ObstacleDetection/Warning",
167+
[this](const zenoh::Sample& sample) {
168+
std::cout << "Recebido obstacleWarning: " << sample.get_payload().as_string() << std::endl;
169+
setWarningCode(1);
170+
},
171+
zenoh::closures::none));
172+
laneDeparture_subscriber.emplace(session->declare_subscriber(
173+
"Vehicle/1/ADAS/LaneDeparture/Detected",
174+
[this](const zenoh::Sample& sample) {
175+
bool isDeparting = std::stoi(sample.get_payload().as_string());
176+
if (isDeparting) {
177+
setWarningCode(2);
178+
}
179+
setLaneDeparture(isDeparting);
180+
},
181+
zenoh::closures::none));
182+
sae0_subscriber.emplace(session->declare_subscriber(
183+
"Vehicle/1/ADAS/ActiveAutonomyLevel/SAE_0",
184+
[this](const zenoh::Sample& sample) {
185+
std::cout << "Recebido SAE 0" << std::endl;
186+
setAutonomyLevel(0);
187+
},
188+
zenoh::closures::none));
189+
sae1_subscriber.emplace(session->declare_subscriber(
190+
"Vehicle/1/ADAS/ActiveAutonomyLevel/SAE_1",
191+
[this](const zenoh::Sample& sample) {
192+
std::cout << "Recebido SAE 1" << std::endl;
193+
setAutonomyLevel(1);
194+
},
195+
zenoh::closures::none));
196+
sae5_subscriber.emplace(session->declare_subscriber(
197+
"Vehicle/1/ADAS/ActiveAutonomyLevel/SAE_5",
166198
[this](const zenoh::Sample& sample) {
167-
std::string warningCode = sample.get_payload().as_string();
168-
std::cout << "Recebido warningCode: " << warningCode << std::endl;
169-
setWarningCode(std::stoi(warningCode));
199+
std::cout << "Recebido SAE 5" << std::endl;
200+
setAutonomyLevel(5);
170201
},
171202
zenoh::closures::none));
172203
}
@@ -259,10 +290,20 @@ int InstrumentCluster::getWarningCode() const {
259290
void InstrumentCluster::setWarningCode(int code) {
260291
if (this->warningCode != code) {
261292
this->warningCode = code;
262-
emit warningCodeChanged(code);
263293
}
294+
emit warningCodeChanged(code);
295+
}
296+
297+
bool InstrumentCluster::getLaneDeparture() const {
298+
return this->laneDeparture;
264299
}
265300

301+
void InstrumentCluster::setLaneDeparture(bool state) {
302+
if (this->laneDeparture != state) {
303+
this->laneDeparture = state;
304+
emit laneDepartureChanged(state);
305+
}
306+
}
266307

267308
bool InstrumentCluster::getRightBlinker() const
268309
{
@@ -415,6 +456,18 @@ QVariantMap InstrumentCluster::getRightLaneCoefs() const {
415456
return m_rightLaneCoefs;
416457
}
417458

459+
int InstrumentCluster::getAutonomyLevel() const {
460+
return autonomyLevel;
461+
}
462+
463+
void InstrumentCluster::setAutonomyLevel(int level) {
464+
if (autonomyLevel != level) {
465+
autonomyLevel = level;
466+
std::cout << "Autonomy level updated: " << autonomyLevel << std::endl;
467+
emit autonomyLevelChanged(level);
468+
}
469+
}
470+
418471
void InstrumentCluster::setLeftLaneCoefs(const QVariantMap& coefs) {
419472
std::cout << "Coefficients updated: " << std::endl;
420473
if (m_leftLaneCoefs != coefs) {

0 commit comments

Comments
 (0)