kopia lustrzana https://github.com/projecthorus/chasemapper
Added reading in of bearing settings from file.
rodzic
ac4eb642ea
commit
2e8b716f59
|
@ -9,7 +9,6 @@
|
||||||
# TODO:
|
# TODO:
|
||||||
# [ ] Store a rolling buffer of car positions, to enable fusing of 'old' bearings with previous car positions.
|
# [ ] Store a rolling buffer of car positions, to enable fusing of 'old' bearings with previous car positions.
|
||||||
#
|
#
|
||||||
#
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
@ -121,6 +120,7 @@ class Bearings(object):
|
||||||
{'type': 'BEARING', 'bearing_type': 'relative', 'bearing': bearing}
|
{'type': 'BEARING', 'bearing_type': 'relative', 'bearing': bearing}
|
||||||
|
|
||||||
The following optional fields can be provided:
|
The following optional fields can be provided:
|
||||||
|
'source': An identifier for the source of the bearings, i.e. 'kerberossdr', 'yagi-1'
|
||||||
'timestamp': A timestamp of the bearing provided by the source.
|
'timestamp': A timestamp of the bearing provided by the source.
|
||||||
'confidence': A confidence value for the bearing, from 0 to [MAX VALUE ??]
|
'confidence': A confidence value for the bearing, from 0 to [MAX VALUE ??]
|
||||||
|
|
||||||
|
@ -146,6 +146,11 @@ class Bearings(object):
|
||||||
else:
|
else:
|
||||||
_confidence = 100.0
|
_confidence = 100.0
|
||||||
|
|
||||||
|
if 'source' in bearing:
|
||||||
|
_source = bearing['source']
|
||||||
|
else:
|
||||||
|
_source = 'unknown'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if bearing['bearing_type'] == 'relative':
|
if bearing['bearing_type'] == 'relative':
|
||||||
# Relative bearing - we need to fuse this with the current car position.
|
# Relative bearing - we need to fuse this with the current car position.
|
||||||
|
@ -160,7 +165,8 @@ class Bearings(object):
|
||||||
'heading_valid': _current_car_pos['heading_valid'],
|
'heading_valid': _current_car_pos['heading_valid'],
|
||||||
'raw_bearing': bearing['bearing'],
|
'raw_bearing': bearing['bearing'],
|
||||||
'true_bearing': (bearing['bearing'] + _current_car_pos['heading']) % 360.0,
|
'true_bearing': (bearing['bearing'] + _current_car_pos['heading']) % 360.0,
|
||||||
'confidence': _confidence
|
'confidence': _confidence,
|
||||||
|
'source': _source
|
||||||
}
|
}
|
||||||
|
|
||||||
elif bearing['bearing_type'] == 'absolute':
|
elif bearing['bearing_type'] == 'absolute':
|
||||||
|
@ -176,7 +182,8 @@ class Bearings(object):
|
||||||
'heading_valid': True,
|
'heading_valid': True,
|
||||||
'raw_bearing': bearing['bearing'],
|
'raw_bearing': bearing['bearing'],
|
||||||
'true_bearing': bearing['bearing'],
|
'true_bearing': bearing['bearing'],
|
||||||
'confidence': _confidence
|
'confidence': _confidence,
|
||||||
|
'source': _source
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ default_config = {
|
||||||
|
|
||||||
# Bearing processing
|
# Bearing processing
|
||||||
'max_bearings': 300,
|
'max_bearings': 300,
|
||||||
'max_bearing_age': 30,
|
'max_bearing_age': 30*60,
|
||||||
'car_speed_gate': 10,
|
'car_speed_gate': 10,
|
||||||
'bearing_length': 10,
|
'bearing_length': 10,
|
||||||
'bearing_weight': 1.0,
|
'bearing_weight': 1.0,
|
||||||
|
|
|
@ -174,7 +174,7 @@ range_ring_custom_color = #FF0000
|
||||||
max_bearings = 300
|
max_bearings = 300
|
||||||
|
|
||||||
# Maximum age of bearings, in *minutes*.
|
# Maximum age of bearings, in *minutes*.
|
||||||
max_bearing_age = 30
|
max_bearing_age = 10
|
||||||
|
|
||||||
# Car heading speed gate
|
# Car heading speed gate
|
||||||
# Only consider car headings to be valid if the car speed is greater than this value in *kph*
|
# Only consider car headings to be valid if the car speed is greater than this value in *kph*
|
||||||
|
@ -186,7 +186,7 @@ car_speed_gate = 10
|
||||||
bearing_length = 10
|
bearing_length = 10
|
||||||
|
|
||||||
# Weight of the bearing lines, in pixels.
|
# Weight of the bearing lines, in pixels.
|
||||||
bearing_weight = 1.0
|
bearing_weight = 0.5
|
||||||
|
|
||||||
# Color of the bearings.
|
# Color of the bearings.
|
||||||
# Valid options are: red, black, blue, green, custom
|
# Valid options are: red, black, blue, green, custom
|
||||||
|
|
|
@ -4,6 +4,14 @@
|
||||||
// Copyright (C) 2019 Mark Jessop <vk5qi@rfhead.net>
|
// Copyright (C) 2019 Mark Jessop <vk5qi@rfhead.net>
|
||||||
// Released under GNU GPL v3 or later
|
// Released under GNU GPL v3 or later
|
||||||
//
|
//
|
||||||
|
//
|
||||||
|
// TODO:
|
||||||
|
// [x] Update bearing settings on change of fields
|
||||||
|
// [ ] Check what's up with the opacity scaling (make it properly linear)
|
||||||
|
// [ ] Load in default values from config file on startup
|
||||||
|
// [ ] Add compass widget to map to show latest bearing data.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
var bearing_store = {};
|
var bearing_store = {};
|
||||||
|
|
||||||
|
@ -58,6 +66,25 @@ function destroyAllBearings(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function bearingValid(bearing){
|
||||||
|
// Decide if a bearing should be plotted on the map, based on user options.
|
||||||
|
var _show_bearing = false;
|
||||||
|
|
||||||
|
// Filter out bearings below our confidence threshold.
|
||||||
|
if (bearing.confidence > bearing_confidence_threshold){
|
||||||
|
|
||||||
|
if (bearing.heading_valid == false) {
|
||||||
|
// Only show bearings which have an invalid associated hearing if the user wants them.
|
||||||
|
_show_bearing = document.getElementById("showStationaryBearings").checked;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_show_bearing = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _show_bearing;
|
||||||
|
}
|
||||||
|
|
||||||
function addBearing(timestamp, bearing){
|
function addBearing(timestamp, bearing){
|
||||||
|
|
||||||
bearing_store[timestamp] = bearing;
|
bearing_store[timestamp] = bearing;
|
||||||
|
@ -75,7 +102,8 @@ function addBearing(timestamp, bearing){
|
||||||
opacity: _opacity
|
opacity: _opacity
|
||||||
});
|
});
|
||||||
|
|
||||||
if (bearing_store[timestamp].confidence > bearing_confidence_threshold){
|
|
||||||
|
if (bearingValid(bearing_store[timestamp]) == true){
|
||||||
bearing_store[timestamp].line.addTo(map);
|
bearing_store[timestamp].line.addTo(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +154,6 @@ function redrawBearings(){
|
||||||
var _end = calculateDestination(L.latLng([bearing_store[key].lat, bearing_store[key].lon]), bearing_store[key].true_bearing, bearing_length);
|
var _end = calculateDestination(L.latLng([bearing_store[key].lat, bearing_store[key].lon]), bearing_store[key].true_bearing, bearing_length);
|
||||||
var _opacity = calculateBearingOpacity(key);
|
var _opacity = calculateBearingOpacity(key);
|
||||||
|
|
||||||
console.log(_opacity);
|
|
||||||
|
|
||||||
// Create the PolyLine
|
// Create the PolyLine
|
||||||
bearing_store[key].line = L.polyline(
|
bearing_store[key].line = L.polyline(
|
||||||
|
@ -136,7 +163,7 @@ function redrawBearings(){
|
||||||
opacity: _opacity
|
opacity: _opacity
|
||||||
});
|
});
|
||||||
|
|
||||||
if (bearing_store[key].confidence > bearing_confidence_threshold){
|
if (bearingValid(bearing_store[key]) == true){
|
||||||
bearing_store[key].line.addTo(map);
|
bearing_store[key].line.addTo(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ function createRangeRings(position){
|
||||||
|
|
||||||
function recenterRangeRings(position){
|
function recenterRangeRings(position){
|
||||||
|
|
||||||
if (document.getElementById("rangeRingsEnabled").checked && (range_rings_on == false)){
|
if ((document.getElementById("rangeRingsEnabled").checked == true) && (range_rings_on == false)){
|
||||||
// We have rings enabled, but haven't been able to create them yet.
|
// We have rings enabled, but haven't been able to create them yet.
|
||||||
// Create them.
|
// Create them.
|
||||||
updateRangeRings();
|
updateRangeRings();
|
||||||
|
|
|
@ -56,6 +56,14 @@ function serverSettingsUpdate(data){
|
||||||
$('#ringCustomColor').val(chase_config.range_ring_custom_color);
|
$('#ringCustomColor').val(chase_config.range_ring_custom_color);
|
||||||
$('#rangeRingsEnabled').prop('checked', chase_config.range_rings_enabled);
|
$('#rangeRingsEnabled').prop('checked', chase_config.range_rings_enabled);
|
||||||
|
|
||||||
|
// Bearing settings
|
||||||
|
$('#bearingLength').val(chase_config.bearing_length.toFixed(0));
|
||||||
|
$('#bearingWeight').val(chase_config.bearing_weight.toFixed(1));
|
||||||
|
$('#bearingColorSelect').val(chase_config.bearing_color);
|
||||||
|
$('#bearingCustomColor').val(chase_config.bearing_custom_color);
|
||||||
|
$('#bearingMaximumAge').val((chase_config.max_bearing_age/60.0).toFixed(0));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Clear and populate the profile selection.
|
// Clear and populate the profile selection.
|
||||||
$('#profileSelect').children('option:not(:first)').remove();
|
$('#profileSelect').children('option:not(:first)').remove();
|
||||||
|
|
|
@ -157,6 +157,31 @@
|
||||||
updateRangeRings();
|
updateRangeRings();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handlers for bearing settings
|
||||||
|
$("#bearingWeight").change(function(){
|
||||||
|
updateBearingSettings();
|
||||||
|
});
|
||||||
|
$("#bearingLength").change(function(){
|
||||||
|
updateBearingSettings();
|
||||||
|
});
|
||||||
|
$("#bearingConfidenceThreshold").change(function(){
|
||||||
|
updateBearingSettings();
|
||||||
|
});
|
||||||
|
$("#bearingMaximumAge").change(function(){
|
||||||
|
updateBearingSettings();
|
||||||
|
});
|
||||||
|
$("#bearingMinOpacity").change(function(){
|
||||||
|
updateBearingSettings();
|
||||||
|
});
|
||||||
|
$("#bearingMaxOpacity").change(function(){
|
||||||
|
updateBearingSettings();
|
||||||
|
});
|
||||||
|
$("#bearingColorSelect").change(function(){
|
||||||
|
updateBearingSettings();
|
||||||
|
});
|
||||||
|
$("#bearingCustomColor").change(function(){
|
||||||
|
updateBearingSettings();
|
||||||
|
});
|
||||||
|
|
||||||
// Changes to the telemetry source profile selection works a bit differently, as we
|
// Changes to the telemetry source profile selection works a bit differently, as we
|
||||||
// need to do a fair bit of work on the server when these occur. These have a dedicated
|
// need to do a fair bit of work on the server when these occur. These have a dedicated
|
||||||
|
@ -507,6 +532,7 @@
|
||||||
|
|
||||||
|
|
||||||
window.setInterval(function(){
|
window.setInterval(function(){
|
||||||
|
if(Object.keys(bearing_store).length > 0){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/server_time",
|
url: "/server_time",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
@ -516,6 +542,7 @@
|
||||||
restyleBearings();
|
restyleBearings();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},10000);
|
},10000);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Ładowanie…
Reference in New Issue