Skip to content

Commit

Permalink
Lots of updates! Moved files to local, heatmap with clear and confide…
Browse files Browse the repository at this point in the history
…nce based graphing only, center map button works. Time for testing!
  • Loading branch information
tdubsFO committed Dec 17, 2023
1 parent 6e3564f commit cc427c2
Show file tree
Hide file tree
Showing 10 changed files with 3,638 additions and 97 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added app/.DS_Store
Binary file not shown.
31 changes: 19 additions & 12 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

app = Flask(__name__, static_url_path="/static", static_folder="static")

# Global variable to control the logging thread
# Global variable to control the logging
logging_active = False
distance_url = 'http://192.168.1.52:6040/mavlink/vehicles/1/components/194/messages/DISTANCE_SENSOR'
gps_url = 'http://192.168.1.52:6040/mavlink/vehicles/1/components/1/messages/GLOBAL_POSITION_INT'
log_file = 'sensor_data.csv'
distance_url = 'http://192.168.1.59:6040/mavlink/vehicles/1/components/194/messages/DISTANCE_SENSOR'
gps_url = 'http://192.168.1.59:6040/mavlink/vehicles/1/components/1/messages/GLOBAL_POSITION_INT'
log_file = 'sensordata.csv'
log_rate = 2

data = []
row_counter = 0
# Define the feedback interval (in seconds)
feedback_interval = 5

# Initialize a counter for the number of rows added
row_counter = 0
data = []
def fetch_data():
def main():
global row_counter
global data
# Main loop for logging data
while (logging_active == True):
Expand All @@ -37,17 +37,18 @@ def fetch_data():
gps_data = gps_response.json()['message']

# Define the column labels for the log file
column_labels = ['Unix Timestamp', 'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second', 'Distance (cm)', 'Latitude', 'Longitude']
column_labels = ['Unix Timestamp', 'Year', 'Month', 'Day', 'Hour', 'Minute', 'Second', 'Distance (cm)', 'Latitude', 'Longitude', "Confidence"]

# Extract the values for each column
timestamp = int(time.time() * 1000) # Convert current time to milliseconds
dt = datetime.fromtimestamp(timestamp / 1000) # Convert timestamp to datetime object
unix_timestamp = timestamp
year, month, day, hour, minute, second = dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second
distance = distance_data['current_distance']
confidence = distance_data['signal_quality']
latitude = gps_data['lat'] / 1e7
longitude = gps_data['lon'] / 1e7
column_values = [unix_timestamp, year, month, day, hour, minute, second, distance, latitude, longitude]
column_values = [unix_timestamp, year, month, day, hour, minute, second, distance, latitude, longitude, confidence]
data = column_values
# Create or append to the log file and write the data
with open(log_file, 'a', newline='') as csvfile:
Expand Down Expand Up @@ -91,7 +92,8 @@ def start_logging():
global logging_active
if not logging_active:
logging_active = True
threading.Thread(target=fetch_data).start()# Start the logging script directly
thread = threading.Thread(target=main)
thread.start()
return 'Started'

@app.route('/stop')
Expand All @@ -102,7 +104,12 @@ def stop_logging():

@app.route('/download')
def download_file():
return send_file('sensor_data.csv', as_attachment=True)
return send_file('sensordata.csv', as_attachment=True, cache_timeout=0)

@app.route('/data')
def get_data():
global data
return jsonify(data)

if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000)
3,459 changes: 3,459 additions & 0 deletions app/sensordata.csv

Large diffs are not rendered by default.

Binary file added app/static/.DS_Store
Binary file not shown.
Binary file added app/static/BB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 37 additions & 54 deletions app/static/css/leaflet.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,14 @@
}
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container .leaflet-overlay-pane svg {
max-width: none !important;
max-height: none !important;
}
.leaflet-container .leaflet-overlay-pane svg,
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
max-width: none !important;
max-height: none !important;
width: auto;
padding: 0;
}

.leaflet-container.leaflet-touch-zoom {
Expand Down Expand Up @@ -171,6 +166,9 @@

/* zoom and fade animations */

.leaflet-fade-anim .leaflet-tile {
will-change: opacity;
}
.leaflet-fade-anim .leaflet-popup {
opacity: 0;
-webkit-transition: opacity 0.2s linear;
Expand All @@ -185,10 +183,9 @@
-ms-transform-origin: 0 0;
transform-origin: 0 0;
}
svg.leaflet-zoom-animated {
.leaflet-zoom-anim .leaflet-zoom-animated {
will-change: transform;
}

}
.leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
Expand Down Expand Up @@ -254,11 +251,14 @@ svg.leaflet-image-layer.leaflet-interactive path {

.leaflet-container {
background: #ddd;
outline-offset: 1px;
outline: 0;
}
.leaflet-container a {
color: #0078A8;
}
.leaflet-container a.leaflet-active {
outline: 2px solid orange;
}
.leaflet-zoom-box {
border: 2px dotted #38f;
background: rgba(255,255,255,0.5);
Expand All @@ -267,10 +267,7 @@ svg.leaflet-image-layer.leaflet-interactive path {

/* general typography */
.leaflet-container {
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
font-size: 12px;
font-size: 0.75rem;
line-height: 1.5;
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
}


Expand All @@ -280,7 +277,8 @@ svg.leaflet-image-layer.leaflet-interactive path {
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
border-radius: 4px;
}
.leaflet-bar a {
.leaflet-bar a,
.leaflet-bar a:hover {
background-color: #fff;
border-bottom: 1px solid #ccc;
width: 26px;
Expand All @@ -297,8 +295,7 @@ svg.leaflet-image-layer.leaflet-interactive path {
background-repeat: no-repeat;
display: block;
}
.leaflet-bar a:hover,
.leaflet-bar a:focus {
.leaflet-bar a:hover {
background-color: #f4f4f4;
}
.leaflet-bar a:first-child {
Expand Down Expand Up @@ -388,8 +385,6 @@ svg.leaflet-image-layer.leaflet-interactive path {
}
.leaflet-control-layers label {
display: block;
font-size: 13px;
font-size: 1.08333em;
}
.leaflet-control-layers-separator {
height: 0;
Expand All @@ -398,33 +393,32 @@ svg.leaflet-image-layer.leaflet-interactive path {
}

/* Default icon URLs */
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
background-image: url(/static/marker-icon.png);
.leaflet-default-icon-path {
background-image: url(images/marker-icon.png);
}


/* attribution and scale controls */

.leaflet-container .leaflet-control-attribution {
background: #fff;
background: rgba(255, 255, 255, 0.8);
background: rgba(255, 255, 255, 0.7);
margin: 0;
}
.leaflet-control-attribution,
.leaflet-control-scale-line {
padding: 0 5px;
color: #333;
line-height: 1.4;
}
.leaflet-control-attribution a {
text-decoration: none;
}
.leaflet-control-attribution a:hover,
.leaflet-control-attribution a:focus {
.leaflet-control-attribution a:hover {
text-decoration: underline;
}
.leaflet-control-attribution svg {
display: inline !important;
.leaflet-container .leaflet-control-attribution,
.leaflet-container .leaflet-control-scale {
font-size: 11px;
}
.leaflet-left .leaflet-control-scale {
margin-left: 5px;
Expand All @@ -437,6 +431,7 @@ svg.leaflet-image-layer.leaflet-interactive path {
border-top: none;
line-height: 1.1;
padding: 2px 5px 1px;
font-size: 11px;
white-space: nowrap;
overflow: hidden;
-moz-box-sizing: border-box;
Expand Down Expand Up @@ -479,22 +474,17 @@ svg.leaflet-image-layer.leaflet-interactive path {
border-radius: 12px;
}
.leaflet-popup-content {
margin: 13px 24px 13px 20px;
line-height: 1.3;
font-size: 13px;
font-size: 1.08333em;
min-height: 1px;
margin: 13px 19px;
line-height: 1.4;
}
.leaflet-popup-content p {
margin: 17px 0;
margin: 1.3em 0;
margin: 18px 0;
}
.leaflet-popup-tip-container {
width: 40px;
height: 20px;
position: absolute;
left: 50%;
margin-top: -1px;
margin-left: -20px;
overflow: hidden;
pointer-events: none;
Expand All @@ -505,7 +495,6 @@ svg.leaflet-image-layer.leaflet-interactive path {
padding: 1px;

margin: -10px auto 0;
pointer-events: auto;

-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
Expand All @@ -522,18 +511,19 @@ svg.leaflet-image-layer.leaflet-interactive path {
position: absolute;
top: 0;
right: 0;
padding: 4px 4px 0 0;
border: none;
text-align: center;
width: 24px;
height: 24px;
font: 16px/24px Tahoma, Verdana, sans-serif;
color: #757575;
width: 18px;
height: 14px;
font: 16px/14px Tahoma, Verdana, sans-serif;
color: #c3c3c3;
text-decoration: none;
font-weight: bold;
background: transparent;
}
.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus {
color: #585858;
.leaflet-container a.leaflet-popup-close-button:hover {
color: #999;
}
.leaflet-popup-scrolled {
overflow: auto;
Expand All @@ -551,6 +541,9 @@ svg.leaflet-image-layer.leaflet-interactive path {
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
}
.leaflet-oldie .leaflet-popup-tip-container {
margin-top: -1px;
}

.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
Expand Down Expand Up @@ -585,7 +578,7 @@ svg.leaflet-image-layer.leaflet-interactive path {
pointer-events: none;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.leaflet-tooltip.leaflet-interactive {
.leaflet-tooltip.leaflet-clickable {
cursor: pointer;
pointer-events: auto;
}
Expand Down Expand Up @@ -645,13 +638,3 @@ svg.leaflet-image-layer.leaflet-interactive path {
margin-left: -12px;
border-right-color: #fff;
}

/* Printing */

@media print {
/* Prevent printers from removing background-images of controls. */
.leaflet-control {
-webkit-print-color-adjust: exact;
color-adjust: exact;
}
}
Loading

0 comments on commit cc427c2

Please sign in to comment.