diff --git a/main/sensors.go b/main/sensors.go index 163d6cd1..3b07a952 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -294,7 +294,7 @@ func sensorAttitudeSender() { } } -func makeSensorRotationMatrix(g [3]float64) *[3][3]float64 { +func makeSensorRotationMatrix(g [3]float64) (rotmat *[3][3]float64) { f := globalSettings.IMUMapping if globalSettings.IMUMapping[0] == 0 { // if unset, default to some standard orientation globalSettings.IMUMapping[0] = -1 // +2 for RY836AI @@ -302,44 +302,19 @@ func makeSensorRotationMatrix(g [3]float64) *[3][3]float64 { saveSettings() } - var x, y, z [3]float64 - // This is the "forward direction" chosen during the orientation process. + var x *[3]float64 = new([3]float64) if f[0] < 0 { x[-f[0]-1] = -1 } else { x[+f[0]-1] = +1 } - // This is the "up direction" chosen during the orientation process. - if f[1] < 0 { - z[-f[1]-1] = -1 - } else { - z[+f[1]-1] = +1 - } - if math.Abs(z[0]*g[0]+z[1]*g[1]+z[2]*g[2]-1) > 0.1 { - log.Println("AHRS Warning: sensor is not nearly level with chosen up direction") - } - z = g - // Normalize the gravity vector to be 1 G. - gg := math.Sqrt(z[0]*z[0] + z[1]*z[1] + z[2]*z[2]) - z[0] /= gg - z[1] /= gg - z[2] /= gg + z, _ := ahrs.MakeUnitVector(g) - // Remove the projection on the measured gravity vector from x so it's orthogonal to z. - dp := x[0]*z[0] + x[1]*z[1] + x[2]*z[2] - x[0] = x[0] - dp*z[0] - x[1] = x[1] - dp*z[1] - x[2] = x[2] - dp*z[2] - - // Specify the "left wing" direction for a right-handed coordinate system using the cross product. - y[0] = z[1]*x[2] - z[2]*x[1] - y[1] = z[2]*x[0] - z[0]*x[2] - y[2] = z[0]*x[1] - z[1]*x[0] - - return &[3][3]float64{x, y, z} + rotmat, _ = ahrs.MakeHardSoftRotationMatrix(*z, *x, [3]float64{0, 0, 1}, [3]float64{1, 0, 0}) + return rotmat } // This is used in the orientation process where the user specifies the forward and up directions. diff --git a/web/plates/gps.html b/web/plates/gps.html index 063504d0..5315db07 100644 --- a/web/plates/gps.html +++ b/web/plates/gps.html @@ -20,7 +20,8 @@ Track:
- {{gps_lat}}, {{gps_lon}} ± {{gps_accuracy}} m
{{gps_alt}} ± {{gps_vert_accuracy}} ft @ {{gps_vert_speed}} ft/min
+ {{gps_lat}}, {{gps_lon}} ± {{gps_horizontal_accuracy}} m
+ {{gps_alt}} ± {{gps_vertical_accuracy}} ft @ {{gps_vert_speed}} ft/min
{{gps_track}}° @ {{gps_speed}} KTS
diff --git a/web/plates/js/gps.js b/web/plates/js/gps.js index 23439444..5a1d2eef 100644 --- a/web/plates/js/gps.js +++ b/web/plates/js/gps.js @@ -138,26 +138,26 @@ function GPSCtrl($rootScope, $scope, $state, $http, $interval) { $scope.press_time = Date.parse(situation.BaroLastMeasurementTime); $scope.gps_time = Date.parse(situation.GPSLastGPSTimeStratuxTime); if ($scope.gps_time - $scope.press_time < 1000) { - $scope.ahrs_alt = Math.round(situation.BaroPressureAltitude); + $scope.ahrs_alt = Math.round(situation.BaroPressureAltitude.toFixed(0)); } else { $scope.ahrs_alt = "---"; } - $scope.ahrs_heading = Math.round(situation.AHRSGyroHeading); + $scope.ahrs_heading = Math.round(situation.AHRSGyroHeading.toFixed(0)); // pitch and roll are in degrees - $scope.ahrs_pitch = Math.round(situation.AHRSPitch*10)/10; - $scope.ahrs_roll = Math.round(situation.AHRSRoll*10)/10; - $scope.ahrs_slip_skid = Math.round(situation.AHRSSlipSkid*10)/10; - ahrs.update($scope.ahrs_pitch, $scope.ahrs_roll, $scope.ahrs_heading, $scope.ahrs_slip_skid); + $scope.ahrs_pitch = situation.AHRSPitch.toFixed(1); + $scope.ahrs_roll = situation.AHRSRoll.toFixed(1); + $scope.ahrs_slip_skid = situation.AHRSSlipSkid.toFixed(1); + ahrs.update(situation.AHRSPitch, situation.AHRSRoll, situation.AHRSGyroHeading, situation.AHRSSlipSkid); - $scope.ahrs_heading_mag = Math.round(situation.AHRSMagHeading); - $scope.ahrs_gload = Math.round(situation.AHRSGLoad*100)/100; - gMeter.update($scope.ahrs_gload); + $scope.ahrs_heading_mag = situation.AHRSMagHeading.toFixed(0); + $scope.ahrs_gload = situation.AHRSGLoad.toFixed(2); + gMeter.update(situation.AHRSGLoad); - if (situation.AHRSTurnRate> 0.25) { - $scope.ahrs_turn_rate = Math.round(360/situation.AHRSTurnRate/60*10)/10; // minutes/turn + if (situation.AHRSTurnRate> 0.6031) { + $scope.ahrs_turn_rate = (6/situation.AHRSTurnRate).toFixed(1); // minutes/turn } else { - $scope.ahrs_turn_rate = '---' + $scope.ahrs_turn_rate = '\u221e'; } if (situation.AHRSStatus & 0x01) { statusGPS.classList.remove("off");