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

Dev #63

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ce6a6e0
Refactor CANBusHandler and QML integration; remove unused code and im…
Rui-Pedro-Pires Jan 8, 2025
a9d9a8b
Update CMake configuration and refactor CANBusHandler for zenoh integ…
Rui-Pedro-Pires Jan 9, 2025
97ebd21
Add main application for CAN bus data publishing with zenoh integration
Rui-Pedro-Pires Jan 9, 2025
59f5cf6
qt enhance
ziliolu Jan 9, 2025
5e977cd
Format code for better readability in main.cpp; adjust spacing in pub…
Rui-Pedro-Pires Jan 9, 2025
c070967
Merge pull request #50 from SEAME-pt/31-task-study-zenon-zero-qm-vss-…
Rui-Pedro-Pires Jan 9, 2025
3119f92
Add CMake configuration files and resource updates for speedometer ap…
Rui-Pedro-Pires Jan 9, 2025
8e6920c
build error
ziliolu Jan 9, 2025
1e494a9
Merge remote-tracking branch 'origin/48-task-enhance-qt-design' into …
Rui-Pedro-Pires Jan 9, 2025
0e75080
Remove obsolete CMake files and Arduino subproject
Rui-Pedro-Pires Jan 9, 2025
8bb7c76
Add new QML components for speedometer UI and update resource file
Rui-Pedro-Pires Jan 9, 2025
9561735
Add gear indicator texts to FootbarInfo QML component
Rui-Pedro-Pires Jan 9, 2025
8ed315f
Update FootbarInfo QML to display battery percentage, mileage, and te…
Rui-Pedro-Pires Jan 9, 2025
dde7f76
Refactor CMakeLists.txt and rename FootbarInfo QML to improve project…
Rui-Pedro-Pires Jan 10, 2025
58cb90b
Add GearShiftInfo component and update UI layout in FootbarInfo and M…
Rui-Pedro-Pires Jan 10, 2025
4c73a70
Merge pull request #51 from SEAME-pt/31-task-study-zenon-zero-qm-vss-…
Rui-Pedro-Pires Jan 10, 2025
1ae2c09
Add TimeInfo component and implement splash screen with logo animatio…
Rui-Pedro-Pires Jan 13, 2025
ac1ffe6
Merge pull request #52 from SEAME-pt/31-task-study-zenon-zero-qm-vss-…
ziliolu Jan 13, 2025
ca654c9
Refactor CMakeLists.txt and remove unused main.cpp file to streamline…
Rui-Pedro-Pires Jan 13, 2025
48645d3
Refactor CANBusHandler to InstrumentCluster and update main applicati…
Rui-Pedro-Pires Jan 14, 2025
e0bee84
Refactor InstrumentCluster to emit correct signals and add handlers f…
Rui-Pedro-Pires Jan 15, 2025
8e03169
Fix gear retrieval and update parking light handler in InstrumentCluster
Rui-Pedro-Pires Jan 16, 2025
d8c389c
Update SpeedDisplay to use speed from InstrumentCluster instead of CA…
Rui-Pedro-Pires Jan 16, 2025
ba10f43
Add middleware CMake configuration and initial main application logic…
Rui-Pedro-Pires Jan 16, 2025
ab01a33
Merge pull request #62 from SEAME-pt/31-task-study-zenon-zero-qm-vss-…
Rui-Pedro-Pires Jan 16, 2025
1c9b647
Add submodule for Team02-Libs in MiddleWare directory
Rui-Pedro-Pires Jan 16, 2025
e3711e2
Remove Team02-Libs submodule from MiddleWare directory
Rui-Pedro-Pires Jan 16, 2025
1d56da1
Update submodule reference for MiddleWare/Libs
Rui-Pedro-Pires Jan 17, 2025
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "MiddleWare/Libs"]
path = MiddleWare/Libs
url = git@github.com:SEAME-pt/Team02-Libs.git
1 change: 0 additions & 1 deletion Arduino
Submodule Arduino deleted from 997966
33 changes: 18 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10)

project(HelloQt6 LANGUAGES CXX)
message("CMAKE_SYSROOT " ${CMAKE_SYSROOT})
message("CMAKE_LIBRARY_ARCHITECTURE " ${CMAKE_LIBRARY_ARCHITECTURE})
set(CMAKE_CXX_STANDARD 11)
project(Cluster LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(zenohc_DIR "/usr/local/lib/cmake/zenohc")
set(zenohcxx_DIR "/usr/local/lib/cmake/zenohcxx")

find_package(Qt6 COMPONENTS Core Quick DBus SerialBus REQUIRED)
find_package(Qt6 COMPONENTS Core Quick DBus REQUIRED)
find_package(zenohc REQUIRED)
find_package(zenohcxx REQUIRED)

set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wl,-rpath-link, ${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
# Enable automatic MOC, UIC, and RCC processing
# Enable Qt's Automatic MOC, UIC, and RCC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

qt_add_resources(QT_RESOURCES ./src/resources.qrc)
# Add Resource File (QML and Other Resources)
qt_add_resources(QT_RESOURCES ./ui/resources.qrc)

add_executable(speedometer ${QT_RESOURCES}
# Define Executable Target
add_executable(InstrumentCluster
${QT_RESOURCES}
./src/main.cpp
./src/CANBusHandler.cpp
./include/CANBusHandler.hpp
./src/InstrumentCluster.cpp
./include/InstrumentCluster.hpp
)

target_link_libraries(speedometer -lm -ldl Qt6::Core Qt6::DBus Qt6::Quick Qt6::SerialBus)

target_link_libraries(InstrumentCluster zenohcxx::zenohc -lm -ldl Qt6::Core Qt6::DBus Qt6::Quick)
17 changes: 17 additions & 0 deletions MiddleWare/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.10)

project(Middelware LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(zenohc_DIR "/usr/local/lib/cmake/zenohc")
set(zenohcxx_DIR "/usr/local/lib/cmake/zenohcxx")

find_package(zenohc REQUIRED)
find_package(zenohcxx REQUIRED)

add_executable(middleWare
./src/main.cpp
)

target_link_libraries(middleWare PRIVATE zenohcxx::zenohc)
1 change: 1 addition & 0 deletions MiddleWare/Libs
Submodule Libs added at 7f38a6
86 changes: 86 additions & 0 deletions MiddleWare/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <sys/socket.h>
#include <linux/can.h>
#include <linux/can/raw.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <arpa/inet.h>
#include "zenoh.hxx"

using namespace zenoh;

int main(int argc, char** argv)
{
struct ifreq ifr;
struct sockaddr_can addr;

int canSocket = socket(PF_CAN, SOCK_RAW, CAN_RAW);
if (canSocket < 0)
{
std::cerr << "Cannot create CAN socket!" << std::endl;
exit(-1);
}

strcpy(ifr.ifr_name, "can0");
ioctl(canSocket, SIOCGIFINDEX, &ifr);

addr.can_family = AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex;
if (bind(canSocket, (struct sockaddr*)&addr, sizeof(addr)) < 0)
{
std::cerr << "Cannot bind CAN socket!" << std::endl;
close(canSocket);
exit(1);
}

std::cout << "CAN socket bound to can0 interface successfully."
<< std::endl;

Config config = Config::create_default();
auto session = Session::open(std::move(config));

auto pubSpeed =
session.declare_publisher(KeyExpr("seame/car/1/speedSensor"));
auto pubBattery =
session.declare_publisher(KeyExpr("seame/car/1/batterySensor"));

while (1)
{
struct can_frame frame;

int nbytes = read(canSocket, &frame, sizeof(struct can_frame));
if (nbytes < 0)
{
std::cerr << "Error reading CAN frame!" << std::endl;
continue;
}
if (frame.can_id == 0x01)
{
int speed;
double wheelDiame = 0.067;

memcpy(&speed, frame.data, sizeof(int));
speed = ntohl(speed);
speed = wheelDiame * 3.14 * speed * 10 / 60;
std::string speed_str = std::to_string(speed);

printf("Publishing speed: '%d'\n", speed);
pubSpeed.put(speed_str.c_str());
}
else if (frame.can_id == 0x02)
{
int battery;
memcpy(&battery, frame.data, sizeof(int));
battery = ntohl(battery);
std::string battery_str = std::to_string(battery);

printf("Publishing battery: '%d\n", battery);
pubBattery.put(battery_str.c_str());
}
usleep(10);
}
return 0;
}
Binary file added assets/icons/back_fog_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/battery-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/battery-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/battery-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/battery-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/battery-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/front_fog_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/green-battery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/high_beam_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/low_beam_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/parking_lights_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/seame-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/turn_left_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/turn_right_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 0 additions & 35 deletions include/CANBusHandler.hpp

This file was deleted.

97 changes: 97 additions & 0 deletions include/InstrumentCluster.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#ifndef INSTRUMENTCLUSTER_HPP
#define INSTRUMENTCLUSTER_HPP

#include <QObject>
#include <iostream>
#include "zenoh.hxx"

using namespace zenoh;

class InstrumentCluster : public QObject
{
Q_OBJECT
Q_PROPERTY(int speed READ getSpeed NOTIFY speedChanged)
Q_PROPERTY(int battery READ getBattery NOTIFY batteryChanged)
Q_PROPERTY(
bool rightBlinker READ getRightBlinker NOTIFY rightBlinkerChanged)
Q_PROPERTY(bool leftBlinker READ getLeftBlinker NOTIFY leftBlinkerChanged)
Q_PROPERTY(bool lowBeam READ getLowBeam NOTIFY lowBeamChanged)
Q_PROPERTY(bool highBeam READ getHighBeam NOTIFY highBeamChanged)
Q_PROPERTY(
bool frontFogLight READ getFrontFogLight NOTIFY frontFogLightChanged)
Q_PROPERTY(
bool readFogLight READ getRearFogLight NOTIFY rearFogLightChanged)
Q_PROPERTY(bool hazardLight READ getHazardLight NOTIFY hazardLightChanged)
Q_PROPERTY(
bool parkingLight READ getParkingLight NOTIFY parkingLightChanged)
Q_PROPERTY(GearPosition gear READ getGear NOTIFY gearChanged)

public:
enum class GearPosition
{
PARK,
REVERSE,
NEUTRAL,
DRIVE
};

Q_ENUM(GearPosition)

private:
int m_speed;
int m_battery;
bool m_rightBlinker;
bool m_leftBlinker;
bool m_lowBeam;
bool m_highBeam;
bool m_frontFogLight;
bool m_rearFogLight;
bool m_hazardLight;
bool m_parkingLight;
GearPosition m_gear;

Session& m_session;

public:
explicit InstrumentCluster(Session& session, QObject* parent = nullptr);
~InstrumentCluster();

int getSpeed() const;
int getBattery() const;
bool getRightBlinker() const;
bool getLeftBlinker() const;
bool getLowBeam() const;
bool getHighBeam() const;
bool getFrontFogLight() const;
bool getRearFogLight() const;
bool getHazardLight() const;
bool getParkingLight() const;
GearPosition getGear() const;

void setSpeed(int speed);
void setBattery(int battery);
void setRightBlinker(bool rightBlinker);
void setLeftBlinker(bool leftBlinker);
void setLowBeam(bool lowBeam);
void setHighBeam(bool highBeam);
void setFrontFogLight(bool frontFogLight);
void setRearFogLight(bool readFogLight);
void setHazardLight(bool hazardLight);
void setParkingLight(bool parkingLight);
void setGear(GearPosition gear);

signals:
void speedChanged(int speed);
void batteryChanged(int battery);
void rightBlinkerChanged(bool rightBlinker);
void leftBlinkerChanged(bool leftBlinker);
void lowBeamChanged(bool lowBeam);
void highBeamChanged(bool highBeam);
void frontFogLightChanged(bool frontFogLight);
void rearFogLightChanged(bool readFogLight);
void hazardLightChanged(bool hazardLight);
void parkingLightChanged(bool parkingLight);
void gearChanged(GearPosition gear);
};

#endif // INSTRUMENTCLUSTER_HPP
Loading
Loading