kopia lustrzana https://github.com/cyoung/stratux
better distance estimation, altitude filter, web output
rodzic
23398c7c54
commit
a4cfb2bc6f
|
@ -190,6 +190,12 @@ func sendTrafficUpdates() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currAlt float32
|
||||||
|
currAlt = mySituation.BaroPressureAltitude
|
||||||
|
if currAlt == 99999 { // no valid BaroAlt, take GPS instead, better than nothing
|
||||||
|
currAlt = mySituation.GPSAltitudeMSL
|
||||||
|
}
|
||||||
|
|
||||||
msgs := make([][]byte, 1)
|
msgs := make([][]byte, 1)
|
||||||
msgFLARM := ""
|
msgFLARM := ""
|
||||||
msgFlarmCount := 0
|
msgFlarmCount := 0
|
||||||
|
@ -212,10 +218,12 @@ func sendTrafficUpdates() {
|
||||||
ti.Bearing = 0
|
ti.Bearing = 0
|
||||||
ti.BearingDist_valid = false
|
ti.BearingDist_valid = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: also filter by altitude. +- >2000ft is not relevant
|
// TODO: also filter by altitude. +- >2000ft is not relevant
|
||||||
if !ti.Position_valid && (bestEstimate.DistanceEstimated == 0 || ti.DistanceEstimated < bestEstimate.DistanceEstimated) {
|
if !ti.Position_valid && (bestEstimate.DistanceEstimated == 0 || ti.DistanceEstimated < bestEstimate.DistanceEstimated) {
|
||||||
bestEstimate = ti
|
if bestEstimate.Alt > 0 && math.Abs(bestEstimate.Alt - currAlt) < 2000 {
|
||||||
|
bestEstimate = ti
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ti.Age = stratuxClock.Since(ti.Last_seen).Seconds()
|
ti.Age = stratuxClock.Since(ti.Last_seen).Seconds()
|
||||||
|
@ -235,11 +243,6 @@ func sendTrafficUpdates() {
|
||||||
//log.Printf("Traffic age of %X is %f seconds\n",icao,ti.Age)
|
//log.Printf("Traffic age of %X is %f seconds\n",icao,ti.Age)
|
||||||
if ti.Age > 2 { // if nothing polls an inactive ti, it won't push to the webUI, and its Age won't update.
|
if ti.Age > 2 { // if nothing polls an inactive ti, it won't push to the webUI, and its Age won't update.
|
||||||
trafficUpdate.SendJSON(ti)
|
trafficUpdate.SendJSON(ti)
|
||||||
var currAlt float32
|
|
||||||
currAlt = mySituation.BaroPressureAltitude
|
|
||||||
if currAlt == 99999 { // no valid BaroAlt, take GPS instead, better than nothing
|
|
||||||
currAlt = mySituation.GPSAltitudeMSL
|
|
||||||
}
|
|
||||||
if float32(ti.Alt) <= currAlt + float32(globalSettings.RadarLimits) * 1.3 { //take 30% more to see moving outs
|
if float32(ti.Alt) <= currAlt + float32(globalSettings.RadarLimits) * 1.3 { //take 30% more to see moving outs
|
||||||
// altitude lower than upper boundary
|
// altitude lower than upper boundary
|
||||||
if float32(ti.Alt) >= currAlt - float32(globalSettings.RadarLimits) * 1.3 {
|
if float32(ti.Alt) >= currAlt - float32(globalSettings.RadarLimits) * 1.3 {
|
||||||
|
@ -312,9 +315,9 @@ func sendTrafficUpdates() {
|
||||||
|
|
||||||
// Used to tune to our radios. We compare our estimate to real values for ADS-B Traffic.
|
// Used to tune to our radios. We compare our estimate to real values for ADS-B Traffic.
|
||||||
// If we tend to estimate too high, we reduce this value, otherwise we increase it
|
// If we tend to estimate too high, we reduce this value, otherwise we increase it
|
||||||
var estimatedDistFactor = 100.0
|
var estimatedDistFactor = 3000.0
|
||||||
func estimateDistance(ti *TrafficInfo) {
|
func estimateDistance(ti *TrafficInfo) {
|
||||||
dist := (-ti.SignalLevel - 6) * (-ti.SignalLevel - 6) * estimatedDistFactor; //distance approx. in nm, 6dB for double distance
|
dist := math.Pow(2.0, -ti.SignalLevel / 6.0) * estimatedDistFactor; // distance approx. in meters, 6dB for double distance
|
||||||
|
|
||||||
lambda := 0.2;
|
lambda := 0.2;
|
||||||
timeDiff := ti.Timestamp.Sub(ti.DistanceEstimatedLastTs).Seconds() * 1000
|
timeDiff := ti.Timestamp.Sub(ti.DistanceEstimatedLastTs).Seconds() * 1000
|
||||||
|
|
|
@ -83,6 +83,7 @@ function TrafficCtrl($rootScope, $scope, $state, $http, $interval) {
|
||||||
new_traffic.src = obj.Last_source; // 1=ES, 2=UAT
|
new_traffic.src = obj.Last_source; // 1=ES, 2=UAT
|
||||||
new_traffic.bearing = Math.round(obj.Bearing); // degrees true
|
new_traffic.bearing = Math.round(obj.Bearing); // degrees true
|
||||||
new_traffic.dist = (obj.Distance/1852); // nautical miles
|
new_traffic.dist = (obj.Distance/1852); // nautical miles
|
||||||
|
new_traffic.distEst = obj.DistanceEstimated / 1852;
|
||||||
// return new_aircraft;
|
// return new_aircraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<span class="col-xs-2" ng-hide="showSquawk"><strong>Code</strong></span>
|
<span class="col-xs-2" ng-hide="showSquawk"><strong>Code</strong></span>
|
||||||
<span class="col-xs-2" ng-show="showSquawk"><strong>Squawk</strong></span>
|
<span class="col-xs-2" ng-show="showSquawk"><strong>Squawk</strong></span>
|
||||||
<span class="col-xs-5 text-right" ng-hide="GPS_connected && RelDist"><strong>Location</strong></span>
|
<span class="col-xs-5 text-right" ng-hide="GPS_connected && RelDist"><strong>Location</strong></span>
|
||||||
<span class="col-xs-3 text-right" ng-show="GPS_connected && RelDist"><strong>Dist</strong></span>
|
<span class="col-xs-3 text-right" ng-show="GPS_connected && RelDist"><strong>Dist (estimated)</strong></span>
|
||||||
<span class="col-xs-2 text-right" ng-show="GPS_connected && RelDist"><strong>Bearing</strong></span>
|
<span class="col-xs-2 text-right" ng-show="GPS_connected && RelDist"><strong>Bearing</strong></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
<span ng-show="showSquawk"><span ng-show="aircraft.squawk < 1000">0</span><span ng-show="aircraft.squawk < 100">0</span><span ng-show="aircraft.squawk < 10">0</span>{{aircraft.squawk}}</span>
|
<span ng-show="showSquawk"><span ng-show="aircraft.squawk < 1000">0</span><span ng-show="aircraft.squawk < 100">0</span><span ng-show="aircraft.squawk < 10">0</span>{{aircraft.squawk}}</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="col-xs-5 text-right" ng-hide="GPS_connected && RelDist">{{aircraft.lat}} {{aircraft.lon}}</span>
|
<span class="col-xs-5 text-right" ng-hide="GPS_connected && RelDist">{{aircraft.lat}} {{aircraft.lon}}</span>
|
||||||
<span class="col-xs-3 text-right" ng-show="GPS_connected && RelDist">{{aircraft.dist.toFixed(1)}}<span style="font-size:50%">NM</span></span>
|
<span class="col-xs-3 text-right" ng-show="GPS_connected && RelDist">{{aircraft.dist.toFixed(1)}} ({{aircraft.distEst.toFixed(1)}})<span style="font-size:50%">NM</span></span>
|
||||||
<span class="col-xs-2 text-right" ng-show="GPS_connected && RelDist">{{aircraft.bearing}}°</span>
|
<span class="col-xs-2 text-right" ng-show="GPS_connected && RelDist">{{aircraft.bearing}}°</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -99,8 +99,9 @@
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<span class="col-xs-4" ng-hide="showReg"><strong>Callsign</strong></span>
|
<span class="col-xs-4" ng-hide="showReg"><strong>Callsign</strong></span>
|
||||||
<span class="col-xs-4" ng-show="showReg"><strong>Tail Num</strong></span>
|
<span class="col-xs-4" ng-show="showReg"><strong>Tail Num</strong></span>
|
||||||
<span class="col-xs-3"><strong>Code</strong></span>
|
<span class="col-xs-2"><strong>Code</strong></span>
|
||||||
<span class="col-xs-3"><strong>Squawk</strong></span>
|
<span class="col-xs-2"><strong>Squawk</strong></span>
|
||||||
|
<span class="col-xs-2"><strong>Dist est.</strong></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
@ -123,8 +124,9 @@
|
||||||
<span ng-show="aircraft.reg" ng-class="'label traffic-style'+aircraft.src+aircraft.targettype">{{aircraft.addr_symb}}<strong> {{aircraft.reg}}</strong></span>
|
<span ng-show="aircraft.reg" ng-class="'label traffic-style'+aircraft.src+aircraft.targettype">{{aircraft.addr_symb}}<strong> {{aircraft.reg}}</strong></span>
|
||||||
<span ng-hide="aircraft.reg" ng-class="'label traffic-style'+aircraft.src+aircraft.targettype">{{aircraft.addr_symb}}<strong> [--N/A--]</strong></span>
|
<span ng-hide="aircraft.reg" ng-class="'label traffic-style'+aircraft.src+aircraft.targettype">{{aircraft.addr_symb}}<strong> [--N/A--]</strong></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="col-xs-3" style="font-size:80%">{{aircraft.icao}}<span style="font-size:50%">{{aircraft.addr_type == 3 ? " (TFID)" : ""}}</span></span>
|
<span class="col-xs-2" style="font-size:80%">{{aircraft.icao}}<span style="font-size:50%">{{aircraft.addr_type == 3 ? " (TFID)" : ""}}</span></span>
|
||||||
<span class="col-xs-3"><span ng-show="aircraft.squawk < 1000">0</span><span ng-show="aircraft.squawk < 100">0</span><span ng-show="aircraft.squawk < 10">0</span>{{aircraft.squawk}}</span>
|
<span class="col-xs-2"><span ng-show="aircraft.squawk < 1000">0</span><span ng-show="aircraft.squawk < 100">0</span><span ng-show="aircraft.squawk < 10">0</span>{{aircraft.squawk}}</span>
|
||||||
|
<span class="col-xs-2">{{aircraft.distEst.toFixed(1)}}<span style="font-size:50%">NM</span></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
|
Ładowanie…
Reference in New Issue