kopia lustrzana https://github.com/cyoung/stratux
Remove 'up' section from orientation procedure.
rodzic
ccf04867fb
commit
e0faa71b3f
|
@ -1132,7 +1132,7 @@ func defaultSettings() {
|
||||||
globalSettings.DisplayTrafficSource = false
|
globalSettings.DisplayTrafficSource = false
|
||||||
globalSettings.ReplayLog = false //TODO: 'true' for debug builds.
|
globalSettings.ReplayLog = false //TODO: 'true' for debug builds.
|
||||||
globalSettings.AHRSLog = false
|
globalSettings.AHRSLog = false
|
||||||
globalSettings.IMUMapping = [2]int{-1, -3} // OpenFlightBox AHRS normal mapping
|
globalSettings.IMUMapping = [2]int{-1, 0}
|
||||||
globalSettings.OwnshipModeS = "F00000"
|
globalSettings.OwnshipModeS = "F00000"
|
||||||
globalSettings.DeveloperMode = false
|
globalSettings.DeveloperMode = false
|
||||||
globalSettings.StaticIps = make([]string, 0)
|
globalSettings.StaticIps = make([]string, 0)
|
||||||
|
|
|
@ -429,8 +429,6 @@ func handleRebootRequest(w http.ResponseWriter, r *http.Request) {
|
||||||
go delayReboot()
|
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) {
|
func handleOrientAHRS(w http.ResponseWriter, r *http.Request) {
|
||||||
// define header in support of cross-domain AJAX
|
// define header in support of cross-domain AJAX
|
||||||
setNoCache(w)
|
setNoCache(w)
|
||||||
|
@ -444,7 +442,6 @@ func handleOrientAHRS(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
var (
|
var (
|
||||||
action []byte = make([]byte, 1)
|
action []byte = make([]byte, 1)
|
||||||
u int
|
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -455,37 +452,21 @@ func handleOrientAHRS(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
switch action[0] {
|
switch action[0] {
|
||||||
case 'f': // Set sensor "forward" direction (toward nose of airplane).
|
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)
|
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)
|
http.Error(w, fmt.Sprintf("couldn't read accelerometer: %s\n", err), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("AHRS Info: sensor orientation: received forward direction %d\n", f)
|
log.Printf("AHRS Info: sensor orientation success! forward axis is %d\n", f)
|
||||||
case 'u': // Set sensor "up" direction (toward top of airplane).
|
globalSettings.IMUMapping = [2]int{f, 0}
|
||||||
if u, err = getMinAccelDirection(); err != nil {
|
case 'd': // Set sensor "up" direction (toward top of airplane).
|
||||||
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}
|
|
||||||
globalSettings.SensorQuaternion = [4]float64{0, 0, 0, 0}
|
globalSettings.SensorQuaternion = [4]float64{0, 0, 0, 0}
|
||||||
saveSettings()
|
saveSettings()
|
||||||
myIMUReader.Close()
|
myIMUReader.Close()
|
||||||
globalStatus.IMUConnected = false // restart the processes depending on the orientation
|
globalStatus.IMUConnected = false // restart the processes depending on the orientation
|
||||||
ResetAHRSGLoad()
|
ResetAHRSGLoad()
|
||||||
log.Printf("AHRS Info: sensor orientation success! forward: %d; up: %d\n", f, u)
|
time.Sleep(2000 * time.Millisecond)
|
||||||
default: // Cancel the sensor calibration.
|
|
||||||
f = 0
|
|
||||||
log.Println("AHRS Info: sensor orientation: canceled")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,7 +330,6 @@ func updateExtraLogging() {
|
||||||
func makeOrientationQuaternion(g [3]float64) (f *[4]float64) {
|
func makeOrientationQuaternion(g [3]float64) (f *[4]float64) {
|
||||||
if globalSettings.IMUMapping[0] == 0 { // if unset, default to some standard orientation
|
if globalSettings.IMUMapping[0] == 0 { // if unset, default to some standard orientation
|
||||||
globalSettings.IMUMapping[0] = -1 // +2 for RY836AI
|
globalSettings.IMUMapping[0] = -1 // +2 for RY836AI
|
||||||
globalSettings.IMUMapping[1] = -3 // +3 for RY836AI
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the "forward direction" chosen during the orientation process.
|
// This is the "forward direction" chosen during the orientation process.
|
||||||
|
|
|
@ -232,18 +232,11 @@ function SettingsCtrl($rootScope, $scope, $state, $location, $window, $http) {
|
||||||
$http.post(URL_AHRS_ORIENT, action).
|
$http.post(URL_AHRS_ORIENT, action).
|
||||||
then(function (response) {
|
then(function (response) {
|
||||||
// console.log("sent " + action + " message.");
|
// console.log("sent " + action + " message.");
|
||||||
setTimeout(getSettings, 5000); // Sleep to allow leveling to finish.
|
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
// failure: cancel the calibration
|
// failure: cancel the calibration
|
||||||
// console.log(response.data);
|
// console.log(response.data);
|
||||||
$scope.Orientation_Failure_Message = response.data;
|
$scope.Orientation_Failure_Message = response.data;
|
||||||
switch (action) {
|
$scope.Ui.turnOff('modalCalibrateDone');
|
||||||
case "forward":
|
|
||||||
$scope.Ui.turnOff("modalCalibrateUp");
|
|
||||||
break;
|
|
||||||
case "up":
|
|
||||||
$scope.Ui.turnOff('modalCalibrateDone');
|
|
||||||
}
|
|
||||||
$scope.Ui.turnOn("modalCalibrateFailed");
|
$scope.Ui.turnOn("modalCalibrateFailed");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -261,31 +261,11 @@
|
||||||
<h4 class="modal-title">Set AHRS Sensor Orientation: Forward Direction</h4>
|
<h4 class="modal-title">Set AHRS Sensor Orientation: Forward Direction</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Point the Stratux/sensor box so that the end that will be pointing toward the <strong>nose</strong> of the airplane is pointing toward the sky and press the <strong>Set Forward Direction</strong> button.</p>
|
<p>Point the Stratux so that the end that will be pointing toward the <strong>nose</strong> of the airplane is pointing toward the sky and press the <strong>Set Forward Direction</strong> button.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a ui-turn-off="modalCalibrateForward" ui-turn-on="modalCalibrateCanceled" class="btn btn-default">Cancel</a>
|
<a ui-turn-off="modalCalibrateForward" class="btn btn-default">Cancel</a>
|
||||||
<a ng-click="setOrientation('forward')" ui-turn-off="modalCalibrateForward" ui-turn-on="modalCalibrateUp" class="btn btn-default btn-primary">Set Forward Direction</a>
|
<a ng-click="setOrientation('forward')" ui-turn-off="modalCalibrateForward" ui-turn-on="modalCalibrateDone" class="btn btn-default btn-primary">Set Forward Direction</a>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="modal" ui-if="modalCalibrateUp" ui-state="modalCalibrateUp">
|
|
||||||
<div class="modal-overlay "></div>
|
|
||||||
<div class="vertical-alignment-helper center-block">
|
|
||||||
<div class="modal-dialog vertical-align-center">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button class="close" ui-turn-off="modalCalibrateUp"></button>
|
|
||||||
<h4 class="modal-title">Set AHRS Sensor Orientation: Up Direction</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p>Place the Stratux/sensor box in the orientation it will be in during flight and press the <strong>Set Up Direction</strong> button.</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a ui-turn-off="modalCalibrateUp" ui-turn-on="modalCalibrateCanceled" class="btn btn-default">Cancel</a>
|
|
||||||
<a ng-click="setOrientation('up')" ui-turn-off="modalCalibrateUp" ui-turn-on="modalCalibrateDone" class="btn btn-default btn-primary">Set Up Direction</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -301,10 +281,11 @@
|
||||||
<h4 class="modal-title">Set AHRS Sensor Orientation: Finished</h4>
|
<h4 class="modal-title">Set AHRS Sensor Orientation: Finished</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>The sensors are calibrated. These settings will be saved for future flights.</p>
|
<p>The sensor orientation is set. These settings will be saved for future flights.</p>
|
||||||
|
<p>Place the Stratux in its in-flight orientation and press the <strong>Done</strong> button.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a ui-turn-off="modalCalibrateDone" class="btn btn-default btn-primary">OK</a>
|
<a ng-click="setOrientation('done')" ui-turn-off="modalCalibrateDone" class="btn btn-default btn-primary">Done</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -322,7 +303,7 @@
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>There was an error: {{Orientation_Failure_Message}}</p>
|
<p>There was an error: {{Orientation_Failure_Message}}</p>
|
||||||
<p><div id="orientationFailureMessage"></div></p>
|
<p><div id="orientationFailureMessage"></div></p>
|
||||||
<p>The calibration failed.</p>
|
<p>The calibration failed. Please try again.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a ui-turn-off="modalCalibrateFailed" class="btn btn-default btn-primary">OK</a>
|
<a ui-turn-off="modalCalibrateFailed" class="btn btn-default btn-primary">OK</a>
|
||||||
|
@ -331,25 +312,5 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal" ui-if="modalCalibrateCanceled" ui-state="modalCalibrateCanceled">
|
|
||||||
<div class="modal-overlay "></div>
|
|
||||||
<div class="vertical-alignment-helper center-block">
|
|
||||||
<div class="modal-dialog vertical-align-center">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button class="close" ui-turn-off="modalCalibrateCanceled"></button>
|
|
||||||
<h4 class="modal-title">Set AHRS Sensor Orientation: Canceled</h4>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p>Calibration canceled.</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a ui-turn-off="modalCalibrateCanceled" class="btn btn-default btn-primary">OK</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue