From e0faa71b3f73bd84b8cc7ece7027b502258d50ee Mon Sep 17 00:00:00 2001 From: Eric Westphal Date: Thu, 6 Jul 2017 19:45:01 -0400 Subject: [PATCH] Remove 'up' section from orientation procedure. --- main/gen_gdl90.go | 2 +- main/managementinterface.go | 31 +++++----------------- main/sensors.go | 1 - web/plates/js/settings.js | 9 +------ web/plates/settings.html | 53 +++++-------------------------------- 5 files changed, 15 insertions(+), 81 deletions(-) diff --git a/main/gen_gdl90.go b/main/gen_gdl90.go index 06d2c67e..6cc1a5b8 100644 --- a/main/gen_gdl90.go +++ b/main/gen_gdl90.go @@ -1132,7 +1132,7 @@ func defaultSettings() { globalSettings.DisplayTrafficSource = false globalSettings.ReplayLog = false //TODO: 'true' for debug builds. globalSettings.AHRSLog = false - globalSettings.IMUMapping = [2]int{-1, -3} // OpenFlightBox AHRS normal mapping + globalSettings.IMUMapping = [2]int{-1, 0} globalSettings.OwnshipModeS = "F00000" globalSettings.DeveloperMode = false globalSettings.StaticIps = make([]string, 0) diff --git a/main/managementinterface.go b/main/managementinterface.go index 9996518d..95910031 100644 --- a/main/managementinterface.go +++ b/main/managementinterface.go @@ -429,8 +429,6 @@ func handleRebootRequest(w http.ResponseWriter, r *http.Request) { go delayReboot() } -var f int // We need this to be global to handle successive calls to handleOrientAHRS. - func handleOrientAHRS(w http.ResponseWriter, r *http.Request) { // define header in support of cross-domain AJAX setNoCache(w) @@ -444,7 +442,6 @@ func handleOrientAHRS(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" { var ( action []byte = make([]byte, 1) - u int err error ) @@ -455,37 +452,21 @@ func handleOrientAHRS(w http.ResponseWriter, r *http.Request) { switch action[0] { case 'f': // Set sensor "forward" direction (toward nose of airplane). - if f, err = getMinAccelDirection(); err != nil { + f, err := getMinAccelDirection() + if err != nil { log.Printf("AHRS Error: sensor orientation: couldn't read accelerometer: %s\n", err) http.Error(w, fmt.Sprintf("couldn't read accelerometer: %s\n", err), http.StatusBadRequest) return } - log.Printf("AHRS Info: sensor orientation: received forward direction %d\n", f) - case 'u': // Set sensor "up" direction (toward top of airplane). - if u, err = getMinAccelDirection(); err != nil { - log.Printf("AHRS Error: sensor orientation: couldn't read accelerometer: %s\n", err) - http.Error(w, fmt.Sprintf("couldn't read accelerometer: %s\n", err), http.StatusBadRequest) - return - } - log.Printf("AHRS Info: sensor orientation: received up direction %d\n", u) - - if f == u || f == -u { - log.Printf("AHRS Error: sensor orientation: up (%d) and forward (%d) axes cannot be the same\n", u, f) - http.Error(w, fmt.Sprintf("up (%d) and forward (%d) axes cannot be the same", u, f), - http.StatusBadRequest) - return - } - - globalSettings.IMUMapping = [2]int{f, u} + log.Printf("AHRS Info: sensor orientation success! forward axis is %d\n", f) + globalSettings.IMUMapping = [2]int{f, 0} + case 'd': // Set sensor "up" direction (toward top of airplane). globalSettings.SensorQuaternion = [4]float64{0, 0, 0, 0} saveSettings() myIMUReader.Close() globalStatus.IMUConnected = false // restart the processes depending on the orientation ResetAHRSGLoad() - log.Printf("AHRS Info: sensor orientation success! forward: %d; up: %d\n", f, u) - default: // Cancel the sensor calibration. - f = 0 - log.Println("AHRS Info: sensor orientation: canceled") + time.Sleep(2000 * time.Millisecond) } } } diff --git a/main/sensors.go b/main/sensors.go index 9652bcb6..b8d84465 100644 --- a/main/sensors.go +++ b/main/sensors.go @@ -330,7 +330,6 @@ func updateExtraLogging() { func makeOrientationQuaternion(g [3]float64) (f *[4]float64) { if globalSettings.IMUMapping[0] == 0 { // if unset, default to some standard orientation globalSettings.IMUMapping[0] = -1 // +2 for RY836AI - globalSettings.IMUMapping[1] = -3 // +3 for RY836AI } // This is the "forward direction" chosen during the orientation process. diff --git a/web/plates/js/settings.js b/web/plates/js/settings.js index fdada70c..2c75bb0d 100644 --- a/web/plates/js/settings.js +++ b/web/plates/js/settings.js @@ -232,18 +232,11 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) { $http.post(URL_AHRS_ORIENT, action). then(function (response) { // console.log("sent " + action + " message."); - setTimeout(getSettings, 5000); // Sleep to allow leveling to finish. }, function(response) { // failure: cancel the calibration // console.log(response.data); $scope.Orientation_Failure_Message = response.data; - switch (action) { - case "forward": - $scope.Ui.turnOff("modalCalibrateUp"); - break; - case "up": - $scope.Ui.turnOff('modalCalibrateDone'); - } + $scope.Ui.turnOff('modalCalibrateDone'); $scope.Ui.turnOn("modalCalibrateFailed"); }); }; diff --git a/web/plates/settings.html b/web/plates/settings.html index b3acb13b..c6f8bbd3 100644 --- a/web/plates/settings.html +++ b/web/plates/settings.html @@ -261,31 +261,11 @@ - - - - - @@ -322,7 +303,7 @@ - -