diff --git a/Cluster/ui/Main.qml b/Cluster/ui/Main.qml index 8204aa5..17965f0 100644 --- a/Cluster/ui/Main.qml +++ b/Cluster/ui/Main.qml @@ -11,8 +11,8 @@ ApplicationWindow { flags: Qt.Window | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint // flags: Qt.Window | Qt.WindowStaysOnTopHint - // visibility: Window.FullScreen - visibility: Window.Windowed + visibility: Window.FullScreen + // visibility: Window.Windowed property int iconWidth: 65 property int iconHeight: 65 diff --git a/Cluster/ui/SignDetector.qml b/Cluster/ui/SignDetector.qml index 301d67d..911378d 100644 --- a/Cluster/ui/SignDetector.qml +++ b/Cluster/ui/SignDetector.qml @@ -73,7 +73,7 @@ Item { } if (value === 0 || path === "") { - speedSigns.clear() + // speedSigns.clear() trafficLights.clear() stopSignSource = "" yieldSignSource = "" diff --git a/Cluster/ui/SpeedDisplay.qml b/Cluster/ui/SpeedDisplay.qml index 0c2e325..0245c2b 100644 --- a/Cluster/ui/SpeedDisplay.qml +++ b/Cluster/ui/SpeedDisplay.qml @@ -75,7 +75,7 @@ Rectangle { Text { font.family: fontFamily - text: "KM/H" + text: "M/MIN" font.pixelSize: app.letterSize color: "gray" anchors.horizontalCenter: parent.horizontalCenter diff --git a/MiddleWare/src/main.cpp b/MiddleWare/src/main.cpp index b8fe608..f52d208 100644 --- a/MiddleWare/src/main.cpp +++ b/MiddleWare/src/main.cpp @@ -162,10 +162,10 @@ int main(int argc, char** argv) if (rpm >= -1000 && rpm <= 1000) { double wheel_circumference = wheelDiameter * M_PI; - double speed_kmh = rpm * wheel_circumference * 60.0 / 1000.0; + double speed_m_per_min = rpm * wheel_circumference; - std::string speed_str = std::to_string(speed_kmh); - std::cout << "Publishing speed: " << speed_str << " km/h" << std::endl; + std::string speed_str = std::to_string(speed_m_per_min); + std::cout << "Publishing speed: " << speed_str << " m/min" << std::endl; speed_pub.put(speed_str.c_str()); } } diff --git a/README.md b/README.md index 8f85af7..d007874 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,13 @@ -# Team02 RaspberryPi - Car Dashboard System +

Instrument Cluster

-This repository contains a car dashboard system that runs on a Raspberry Pi, displaying real-time vehicle information on a dashboard screen. +

A real-time vehicle speed and data display.

+ +![Cluster GIF](https://github.com/SEAME-pt/Team02-RaspberryPi/blob/readme/assets/instrumentCluster.gif) ## Overview +This repository contains a car dashboard system that runs on a Raspberry Pi, displaying real-time vehicle information on a dashboard screen. + The system consists of two main applications: - **Instrument Cluster** - A QML-based dashboard display - **MiddleWare** - CAN bus communication handler @@ -30,6 +34,8 @@ The Jetson Nano sends vehicle data over CAN bus to the Raspberry Pi, which proce - Publishes vehicle data using Zenoh messaging - Handles various vehicle systems (lights, battery, speed, ADAS) +๐Ÿ—‚๏ธ [Check here](https://github.com/SEAME-pt/Team02-RaspberryPi/blob/readme/MiddleWare/src/can-id-reference-table.md) the CAN ID Reference Table in middleware + ## Vehicle Data Supported - Vehicle speed and gear @@ -46,3 +52,87 @@ The Jetson Nano sends vehicle data over CAN bus to the Raspberry Pi, which proce - Qt6 with QML support - Zenoh messaging library - CAN utilities + + +### Usage + + +Once the application is up and running, the instrument cluster will display `real-time speed data` and the `vehicle's battery status` on an LCD screen. The data is continuously updated as it is received **via the CAN bus**. + +This project's UI can be deployed and tested in two main environments (in a raspberry pi 4 and locally in you computer). Check the deploy manual [here](https://github.com/SEAME-pt/Team02-RaspberryPi/tree/readme/deploy). + +## Testing + + + + + +We use **LCOV** for test coverage analysis to ensure the reliability and quality of the codebase. Follow the steps below to run the tests: + + + + + +1. Navigate to the `RaspberryPi/tests` directory: + + + ```bash + + + cd RaspberryPi/tests + + + ``` + + + + + +2. After the tests are executed, a coverage report will be generated. Run the test script: + + + ```bash + + + ./test.sh + + + ``` + + +Make sure all tests pass and the coverage meets the project's standards before submitting any changes. + +## Acknowledgments + +- **Qt Framework:** [Qt](https://www.qt.io/) โ€“ A cross-platform framework for GUI applications. + + +- **Raspberry Pi Foundation:** [Raspberry Pi](https://www.raspberrypi.org/) โ€“ The small, powerful computer that powers the display side of the project. + + +- **Arduino:** [Arduino](https://www.arduino.cc/) โ€“ A versatile open-source electronics platform used for sensor data collection. + + +- **CAN Bus Protocol:** [CAN Protocol](https://www.kvaser.com/can/) โ€“ The communication protocol used to connect different ECUs in the vehicle. + + +## The Team ๐Ÿค + + +> Together, we've collaborated to bring this project to life, combining our knowledge, skills, and experience every step of the way. It has been a great journey of learning and growing as a team. + + + - Rui Pires + + + - Luiza Zilio + + + - Luis Filipe Carvalho + + + - Jorge Cruz + + + + diff --git a/README2.md b/README2.md new file mode 100644 index 0000000..01b1b89 --- /dev/null +++ b/README2.md @@ -0,0 +1,430 @@ + + +

Instrument Cluster

+ +

A real-time vehicle speed and data display.

+ +## Demo + +![Cluster GIF](https://github.com/SEAME-pt/Team02-RaspberryPi/blob/readme/assets/instrumentCluster.gif) + + +## Table of Contents + + +The **Instrument Cluster** is designed to provide real-time speed data from a PiRacer car on a graphical interface (GUI). The application is split across two devices: the **Jetson Nano** handles all the processing tasks, while the **Raspberry Pi** is used solely for rendering the Qt-based display. Both devices receive speed data simultaneously from the sensor via the Controller Area Network (CAN) protocol. The Jetson Nano processes the data for any necessary computations (such as filtering, calculations, etc.), and the Raspberry Pi renders the GUI with the processed speed data. + + + +This architecture allows for improved performance by offloading processing to the Jetson Nano while simplifying the display connection on the Raspberry Pi. Check it out the pheripherals Readme to better understand about the project architecture. + + + + + +This project offers hands-on experience with software engineering, embedded systems, and automotive communication protocols, with a focus on performance optimization through a modular system design. + + + + +### Project Goals: + + +- **Design and implement** a Qt-based graphical user interface (GUI) for displaying speed data on the Raspberry Pi. + + +- **Use the Jetson Nano** for handling all processing tasks related to speed data and mathematical calculations. + + +- **Integrate** a Raspberry Pi with an Arduino-based speed sensor using the CAN protocol. + + +- **Display real-time speed** data on the instrument cluster. + + +- **Test the application** in realistic driving scenarios. + + +- **Document** the entire project, including system architecture, software design, and implementation details. + + + + +**BONUS:** Display battery level on the instrument cluster. + + + + + + + + +### Architecture Overview + + + + + + + + +- **Jetson Nano:** Handles all the computational tasks and mathematical processing for the instrument cluster. It processes speed sensor data and other inputs before sending them to the Raspberry Pi. + + +- **Raspberry Pi:** Dedicated to rendering the GUI with Qt, displaying the processed data received from the Jetson Nano over CAN bus. + + + + +--- + + + + + + + + + + +### Built With + + + + +This section lists the major frameworks, libraries, and tools used in this project. + + + + + +#### Technologies and Frameworks + + + + + +- [![Qt](https://img.shields.io/badge/Qt-41CD52?style=for-the-badge&logo=qt&logoColor=white)](https://www.qt.io/) + + +- [![Python](https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/) + + +- [![C++](https://img.shields.io/badge/C++-00599C?style=for-the-badge&logo=c%2B%2B&logoColor=white)](https://isocpp.org/) + + + + + +#### Communication Protocols + + + + + +- [![SPI](https://img.shields.io/badge/SPI-Protocol-000000?style=for-the-badge)](https://en.wikipedia.org/wiki/Serial_Peripheral_Interface) + + +- [![I2C](https://img.shields.io/badge/I2C-Protocol-000000?style=for-the-badge)](https://en.wikipedia.org/wiki/I%2F2C) + + +- [![CAN Bus](https://img.shields.io/badge/CAN%20Bus-Protocol-000000?style=for-the-badge)](https://www.kvaser.com/can/) + + + + + +๐Ÿ—‚๏ธ [Check here](https://github.com/SEAME-pt/Team02-RaspberryPi/blob/80-task-object-detection-in-cluster/MiddleWare/src/can-id-reference-table.md) the CAN ID Reference Table + + + + + +#### Hardware + + + + + +- [![Jetson Nano](https://img.shields.io/badge/Jetson%20Nano-Developer%20Kit-76B900?style=for-the-badge&logo=nvidia&logoColor=white)](https://developer.nvidia.com/embedded/jetson-nano) + + +- [![Raspberry Pi](https://img.shields.io/badge/Raspberry%20Pi-C51A4A?style=for-the-badge&logo=raspberry-pi&logoColor=white)](https://www.raspberrypi.org/) + + +- [![Arduino](https://img.shields.io/badge/Arduino-00979D?style=for-the-badge&logo=arduino&logoColor=white)](https://www.arduino.cc/) + + + + + +--- + + + + + +### Usage + + +Once the application is up and running, the instrument cluster will display `real-time speed data` and the `vehicle's battery status` on an LCD screen. The data is continuously updated as it is received **via the CAN bus**. + + + + + +This project can be deployed and tested in two main environments: + + + + + +### โœ… Option 1: Deploy on Raspberry Pi LCD + + + + + +To deploy the interface on a Raspberry Pi with an attached LCD display: + + + + + +1. Make sure you're in the **root directory** of the repository. + + +2. Update the `.env` file located in the root directory: + + + - Change the `PI_IP_ADDRESS` to the IP address of your Raspberry Pi. + + + - Update the `CREDENTIALS` with the username (`PI_USERNAME`) and password (`PI_PASSWORD`) for your Raspberry Pi. + + + + + +2. Run the deployment script from the root repository: + + + + + + ```bash + + + ./RaspberryPi/deploy/scripts/deployToRasp.sh + + + ``` + + + + + +4. Restart the application to apply the changes. The executables will be placed in `PI_PATH_BIN` in your Raspberry Pi, make sure to change that if necessary. + + + + + +### โœ… Option 2: Simulate on a Local Machine + + + + + +For testing purposes, you can simulate the application on your local machine: + + + + + +1. Install the required dependencies as listed in the `requirements.txt` file. + + +2. Run the application locally using: + + + + + + ```bash + + + ./RaspberryPi/deploy/deployLocal/deployLocal.sh + + + ``` + + + + + +3. Ensure the CAN bus data is being simulated or fed into the application for testing. + + + + + +--- + + + + + +## Testing + + + + + +We use **LCOV** for test coverage analysis to ensure the reliability and quality of the codebase. Follow the steps below to run the tests: + + + + + +1. Navigate to the `RaspberryPi/tests` directory: + + + ```bash + + + cd RaspberryPi/tests + + + ``` + + + + + +2. After the tests are executed, a coverage report will be generated. Run the test script: + + + ```bash + + + ./test.sh + + + ``` + + + + + +Make sure all tests pass and the coverage meets the project's standards before submitting any changes. + + + + + +## The Team ๐Ÿค + + +> Together, we've collaborated to bring this project to life, combining our knowledge, skills, and experience every step of the way. It has been a great journey of learning and growing as a team. + + + + + + - Rui Pires + + + - Luiza Zilio + + + - Luis Filipe Carvalho + + + - Jorge Cruz + + + + + +## Contributing + + + + + +Contributions are what make the open source community such an amazing place to learn, inspire, and create. **Any contributions you make are greatly appreciated.** + + + + + +If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again! + + + + + +1. Fork the repository + + +2. Create a new branch for your feature (`git checkout -b feature-name`) + + +3. Commit your changes (`git commit -am 'Add feature'`) + + +4. Push to the branch (`git push origin feature-name`) + + +5. Open a pull request + + + + + +--- + + + + + +## License + + + + + +Distributed under the MIT License. See `LICENSE` for more information. + + + + + +--- + + + + + +## Acknowledgments + +- **Qt Framework:** [Qt](https://www.qt.io/) โ€“ A cross-platform framework for GUI applications. + + +- **Raspberry Pi Foundation:** [Raspberry Pi](https://www.raspberrypi.org/) โ€“ The small, powerful computer that powers the display side of the project. + + +- **Arduino:** [Arduino](https://www.arduino.cc/) โ€“ A versatile open-source electronics platform used for sensor data collection. + + +- **CAN Bus Protocol:** [CAN Protocol](https://www.kvaser.com/can/) โ€“ The communication protocol used to connect different ECUs in the vehicle. \ No newline at end of file diff --git a/assets/instrumentCluster.gif b/assets/instrumentCluster.gif new file mode 100644 index 0000000..8517a52 Binary files /dev/null and b/assets/instrumentCluster.gif differ diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 0000000..a78532d --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,86 @@ + +### โœ… Option 1: Deploy on Raspberry Pi LCD + + + + + +To deploy the interface on a Raspberry Pi with an attached LCD display: + + + + + +1. Make sure you're in the **root directory** of the repository. + + +2. Update the `.env` file located in the root directory: + + + - Change the `PI_IP_ADDRESS` to the IP address of your Raspberry Pi. + + + - Update the `CREDENTIALS` with the username (`PI_USERNAME`) and password (`PI_PASSWORD`) for your Raspberry Pi. + + + + + +2. Run the deployment script from the root repository: + + + + + + ```bash + + + ./RaspberryPi/deploy/scripts/deployToRasp.sh + + + ``` + + + + + +4. Restart the application to apply the changes. The executables will be placed in `PI_PATH_BIN` in your Raspberry Pi, make sure to change that if necessary. + + + + + +### โœ… Option 2: Simulate on a Local Machine + + + + + +For testing purposes, you can simulate the application on your local machine: + + + + + +1. Install the required dependencies as listed in the `requirements.txt` file. + + +2. Run the application locally using: + + + + + + ```bash + + + ./RaspberryPi/deploy/deployLocal/deployLocal.sh + + + ``` + + + + + +3. Ensure the CAN bus data is being simulated or fed into the application for testing. diff --git a/deploy/deployLocal/CMakeLists.txt b/deploy/deployLocal/CMakeLists.txt index 1bfa5a2..26df5c7 100644 --- a/deploy/deployLocal/CMakeLists.txt +++ b/deploy/deployLocal/CMakeLists.txt @@ -27,14 +27,14 @@ include_directories(/usr/local/include) link_directories(/usr/local/lib) # Recursos Qt -qt_add_resources(QT_RESOURCES_HCA ../../Clusters/HandCluster/ui/resources.qrc) +qt_add_resources(QT_RESOURCES_HCA ../../Cluster/ui/resources.qrc) # Executรกvel principal add_executable(InstrumentClusterLocalInstance ${QT_RESOURCES_HCA} - ../../Clusters/HandCluster/src/main.cpp - ../../Clusters/HandCluster/src/InstrumentCluster.cpp - ../../Clusters/HandCluster/include/InstrumentCluster.hpp + ../../Cluster/src/main.cpp + ../../Cluster/src/InstrumentCluster.cpp + ../../Cluster/include/InstrumentCluster.hpp ) # Linka bibliotecas