Add display of raw DOA data.

bearings
Mark Jessop 2019-08-17 22:56:55 +09:30
rodzic 223bf03ac5
commit ea94f7634b
7 zmienionych plików z 1627 dodań i 5 usunięć

Wyświetl plik

@ -186,6 +186,7 @@ class Bearings(object):
'raw_bearing': bearing['bearing'],
'true_bearing': (bearing['bearing'] + _current_car_pos['heading']) % 360.0,
'confidence': _confidence,
'power': _power,
'source': _source
}
@ -204,6 +205,7 @@ class Bearings(object):
'raw_bearing': bearing['bearing'],
'true_bearing': bearing['bearing'],
'confidence': _confidence,
'power': _power,
'source': _source
}
@ -255,6 +257,12 @@ class Bearings(object):
self.bearing_lock.release()
# Add in any raw DOA data we may have been given.
if 'raw_bearing_angles' in bearing:
_new_bearing['raw_bearing_angles'] = bearing['raw_bearing_angles']
_new_bearing['raw_doa'] = bearing['raw_doa']
# Now we need to update the web clients on what has changed.
_client_update = {
'add': _new_bearing,

Wyświetl plik

@ -14,7 +14,7 @@ from threading import Thread
from dateutil.parser import parse
from datetime import datetime, timedelta
MAX_JSON_LEN = 2048
MAX_JSON_LEN = 32768
def fix_datetime(datetime_str, local_dt_str = None):

Wyświetl plik

@ -87,6 +87,19 @@ function bearingValid(bearing){
function addBearing(timestamp, bearing, live){
// Handle any raw data, if we have been passed it.
var _raw_bearing_angles = [];
var _raw_doa = [];
if(bearing.hasOwnProperty('raw_bearing_angles')){
// If we have raw data provided, extract it, then delete it from the bearing object,
// as we don't want to store this persistently.
_raw_bearing_angles = bearing.raw_bearing_angles;
_raw_doa = bearing.raw_doa;
delete bearing.raw_bearing_angles;
delete bearing.raw_doa;
}
bearing_store[timestamp] = bearing;
// Calculate the end position.
@ -108,8 +121,13 @@ function addBearing(timestamp, bearing, live){
}
if ( (live == true) && (document.getElementById("bearingsEnabled").checked == true) ){
$("#bearing_table").tabulator("setData", [{id:1, bearing: bearing_store[timestamp].raw_bearing.toFixed(0), confidence: bearing_store[timestamp].confidence.toFixed(0)}]);
$("#bearing_table").show();
if(_raw_bearing_angles.length > 0){
$("#bearing_table").tabulator("setData", [{id:1, bearing: bearing_store[timestamp].raw_bearing.toFixed(0), confidence: bearing_store[timestamp].confidence.toFixed(0), power: bearing_store[timestamp].power.toFixed(0)}]);
$("#bearing_table").show();
bearingPlotRender(_raw_bearing_angles, _raw_doa);
$('#bearing_plot').show();
}
}
}
@ -227,7 +245,7 @@ function toggleBearingsEnabled(){
redrawBearings();
// Hide the bearing table
$("#bearing_table").hide();
$("#bearing_plot").hide();
bearings_on = false;
@ -275,6 +293,47 @@ function flushBearings(){
}
}
function bearingPlotRender(angles, doa){
var _config = {
"data": [{
"t": angles,// [0,45,90,135,180,215,270,315], // theta values (x axis)
"r": doa,//[-4,-3,-2,-1,0,-1,-2,-3,-4], // radial values (y axis)
"name": "DOA", // name for the legend
"visible": true,
"color": "blue", // color of data element
"opacity": 0.8,
"strokeColor": "blue",
"strokeDash": "solid", // solid, dot, dash (default)
"strokeSize": 2,
"visibleInLegend": false,
"geometry": "LinePlot" // AreaChart, BarChart, DotPlot, LinePlot (default)
}],
"layout": {
"height": 250, // (default: 450)
"width": 250,
"orientation":-90,
"showlegend": false,
"backgroundColor": "ghostwhite",
"radialAxis": {
"domain": µ.DATAEXTENT,
"visible": true
},
"margin": {
"top": 20,
"right": 20,
"bottom": 20,
"left": 20
},
}};
micropolar.Axis() // instantiate a new axis
.config(_config) // configure it
.render(d3.select('#bearing_plot'));
}
/**
Returns the point that is a distance and heading away from
the given origin point.

5
static/js/d3.v3.min.js vendored 100644

File diff suppressed because one or more lines are too long

Plik diff jest za duży Load Diff

Wyświetl plik

@ -159,7 +159,8 @@ function initTables(){
//selectable:1, // TODO...
columns:[ //Define Table Columns
{title:"Bearing", field:"bearing", headerSort:false},
{title:"Score", field:'confidence', headerSort:false}
{title:"Score", field:'confidence', headerSort:false},
{title:"Power", field:'power', headerSort:false}
],
data:[{id: 1, bearing:0.0, confidence:0.0}]
});

Wyświetl plik

@ -32,6 +32,9 @@
<script src="{{ url_for('static', filename='js/tabulator.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/d3.v3.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/micropolar-v0.2.2.js') }}"></script>
<!-- Custom scripts -->
<script src="{{ url_for('static', filename='js/habitat.js') }}"></script>
<script src="{{ url_for('static', filename='js/utils.js') }}"></script>
@ -338,6 +341,21 @@
})
.addTo(map);
L.control.custom({
position: 'bottomright',
content : "<div id='bearing_plot'></div>",
classes : 'btn-group-vertical btn-group-sm',
id: 'bearing_plot_control',
style :
{
margin: '5px',
padding: '0px 0 0 0',
cursor: 'pointer',
}
})
.addTo(map);
// Follow buttons - these just set the radio buttons on the settings pane.
// TODO: Figure out how to centre the icons under iOS's Safari browser.