check OceanosTeam/Monaco2024
This is a repository used to visualize several parameters of Oceanos NTUA Boat, such as Motor Temperature, Rounds per Minute of the Motor, that are required in the MEBC 2024. It is hosted on web, to visit follow the link below: Oceanos Visualization Website
- Raspberry / Test-Server PC : Proceed to Visualization test
- Client PC : Just download client folder from Google Drive, and read the instructions inside the README there
useful.py
: Ctrl + F:CHANGE
: to see how to change csv that is read, reading of last line of the csvREAL_TIME
to have real time data (True) or not (False - simulate for development purposes), change significant paths. Ctrl + F :CHANGE
: setmode
to the value 'local' for Rasberry or your computer testing, 'client' for the PC running client code. In addition, modify variables so as to select if you want to send to web-host (pythonanywhere) or client (e.g. your computer running client python code) or both. (If you do not send to client, you do not need to run ngrok and client code !).- Add CSV in this Folder:
static/csv
- Javascript Files here:
static/functions
- Here you can change the visualization RELOAD PERIOD:setInterval
(2nd argument is time in ms) inevents.js
.
- You can add a new data visualization (or change sequence) by adding a data in listallData
indata.js
(check the class definition ofData
).
- You can change the display of the roundSliders indisplay.js
after you check roundSlider attributesstatic/dist/roundslider.js
- Styles
static/styles/styles.css
- Here you can change the text (font) size for visualization by changing the variable--textSize
.
- Git clone the repo
git clone https://github.com/ntua-el20069/oceanos-visualization-2024.git
cd oceanos-visualization-2024/
- (Optional) Make a virtual environment as specified here venv and activate it.
- Try installing dependencies with the below command. Try running
App.py
andserver.py
. If they run OK move to the next step. If you see import errors, pip install all reported dependencies (continue until you do not have import errors). Alternatively, you can install dependencies (requirements.txt
) as specified in the venv link above (if anything throws error try removing it fromrequirements.txt
, some dependencies are unnecessary).
pip install flask pandas requests
- Run
App.py
for the visualization - Run in a terminal the command
ngrok start oceanos
(after you follow the instructions for ngrok) - Run in a terminal the
server.py
python file for the ngrok server (it is actually the code that will run in raspberry and send data to client) - Run
client.py
(maybe in another PC) to receive data as client PC - (Optional) If you want to run the program as a startup application (exactly after boot) you should copy the files:
virtualization.desktop
andfirefox.desktop
andsend.desktop
andngrok.desktop
which are in thedesktop
folder and paste them inside directory~/.config/autostart
(in Raspberry Pi) (and check that these files have execution permission). Important! change the comments to use the correctExec
configuration in.desktop
files.
(The visualization App.py
can work without running ngrok and server)
- Use
restart
files in theExec
configuration of the.desktop
files (firefox.desktop
) - Repeat the steps for the Raspberry Pi that will run in MEBC (
xterm
may not be installed there) - Change code in
useful.py
(makeREAL_TIME = True
) so as to get real time data - read the last line of the CSV in whichgps_with_temp.py
writes.
- In pythonanywhere account, delete the folder
/home/oceanosntua/oceanos-visualization-2024
- Write in bash console in Python
cd /home/oceanosntua/
- Git clone the repo:
git clone https://github.com/ntua-el20069/oceanos-visualization-2024.git
- Enter the repo directory:
cd oceanos-visualization-2024/
- In pythonanywhere file
/home/oceanosntua/oceanos-visualization-2024/useful.py
: setmode
to the value 'web' instead of 'local' - Reload the website from pythonanywhere reload button.
- Run the local
server.py
. - Refresh the web page and you will see that data change in the Normal mode visualization!
- (Optional) Before each of seatrials / MEBC race, download
/home/oceanosntua/hostdata.csv
in order to save it locally (and rename it!) and remove it from host folder because we want the next hostdata to refer to another race.
Bash commands for 1-5 in pythonanywhere bash console.
rm -r /home/oceanosntua/oceanos-visualization-2024
cd /home/oceanosntua/
git clone https://github.com/ntua-el20069/oceanos-visualization-2024.git
cd oceanos-visualization-2024/
vim useful.py
server.py
: code (that will run in raspberry) that sends messages to HOST or/and client (PC that runs client code)helpers
: in this foldersendWEB.py
is used to send the current json data to the HOST (web site) by HTTP POST request at endpoint/send-data
(This is probably similar to the way that we will send data to MEBC API). Host receives the request json data and writes them as the last line of a CSV filehostdata.csv
.client.py
: code (that we will run in our client PC) to receive data as client PC.
App.py
: builds a flask application that runs the backend code and sends response on requests to each specified routetemplates/telemetry.html
: the basic HTML template of the visualizationstatic/functions
: includes JavaScript files that are executing to build the basic body of the visualization and execute reload functions to reload shown data.static/styles
: includes CSS files that define the style of the visualizationstatic/dist
: includes roundSlider, a free jQuery plugin