kopia lustrzana https://github.com/cyoung/stratux
sensors.go gets sensor orientation from globalSettings.
rodzic
af2ea7196b
commit
b6fef3ca9a
|
@ -1036,6 +1036,7 @@ type settings struct {
|
|||
DisplayTrafficSource bool
|
||||
DEBUG bool
|
||||
ReplayLog bool
|
||||
IMUMapping [3]int // Map from aircraft axis to sensor axis: accelerometer
|
||||
PPM int
|
||||
OwnshipModeS string
|
||||
WatchList string
|
||||
|
@ -1103,6 +1104,7 @@ func defaultSettings() {
|
|||
globalSettings.DEBUG = false
|
||||
globalSettings.DisplayTrafficSource = false
|
||||
globalSettings.ReplayLog = false //TODO: 'true' for debug builds.
|
||||
globalSettings.IMUMapping = [3]int{2, -1, 3} // RY83XAI orientation mapping
|
||||
globalSettings.OwnshipModeS = "F00000"
|
||||
globalSettings.DeveloperMode = false
|
||||
}
|
||||
|
|
|
@ -285,6 +285,9 @@ func handleSettingsSetRequest(w http.ResponseWriter, r *http.Request) {
|
|||
if v != globalSettings.ReplayLog { // Don't mark the files unless there is a change.
|
||||
globalSettings.ReplayLog = v
|
||||
}
|
||||
case "IMUMapping":
|
||||
globalSettings.IMUMapping = val.([3]int)
|
||||
globalStatus.IMUConnected = false // Force a restart of the IMU reader
|
||||
case "PPM":
|
||||
globalSettings.PPM = int(val.(float64))
|
||||
case "Baud":
|
||||
|
|
|
@ -145,7 +145,8 @@ func sensorAttitudeSender() {
|
|||
t time.Time
|
||||
s ahrs.AHRSProvider
|
||||
m *ahrs.Measurement
|
||||
bx, by, bz, ax, ay, az, mx, my, mz float64
|
||||
a1, a2, a3, b1, b2, b3, m1, m2, m3 float64 // IMU measurements
|
||||
ff *[3][3]float64 // Sensor orientation matrix
|
||||
mpuError, magError error
|
||||
headingMag, slipSkid, turnRate, gLoad float64
|
||||
errHeadingMag, errSlipSkid, errTurnRate, errGLoad error
|
||||
|
@ -168,19 +169,46 @@ func sensorAttitudeSender() {
|
|||
// Need a 10Hz sampling freq
|
||||
timer := time.NewTicker(100 * time.Millisecond) // ~10Hz update.
|
||||
for {
|
||||
ff = new([3][3]float64)
|
||||
if globalSettings.IMUMapping[0]==0 { // if unset, default to RY836AI
|
||||
globalSettings.IMUMapping[0] = -1 // +2
|
||||
globalSettings.IMUMapping[1] = +2 // -1
|
||||
globalSettings.IMUMapping[2] = -3 // +3
|
||||
saveSettings()
|
||||
}
|
||||
f := globalSettings.IMUMapping
|
||||
for i := 0; i < 3; i++ {
|
||||
if f[i] < 0 {
|
||||
ff[i][-f[i] - 1] = -1
|
||||
} else {
|
||||
ff[i][f[i] - 1] = +1
|
||||
}
|
||||
}
|
||||
|
||||
<-timer.C
|
||||
for (globalSettings.Sensors_Enabled && globalStatus.IMUConnected) {
|
||||
<-timer.C
|
||||
t = stratuxClock.Time
|
||||
m.T = float64(t.UnixNano() / 1000) / 1e6
|
||||
|
||||
_, bx, by, bz, ax, ay, az, mx, my, mz, mpuError, magError = myIMUReader.ReadRaw()
|
||||
//TODO westphae: allow user configuration of this mapping from a file, plus UI modification
|
||||
//m.B1, m.B2, m.B3 = +by, -bx, +bz // This is how the RY83XAI is wired up
|
||||
//m.A1, m.A2, m.A3 = -ay, +ax, -az // This is how the RY83XAI is wired up
|
||||
m.B1, m.B2, m.B3 = -bx, +by, -bz // This is how the OpenFlightBox board is wired up
|
||||
m.A1, m.A2, m.A3 = -ay, +ax, +az // This is how the OpenFlightBox board is wired up
|
||||
m.M1, m.M2, m.M3 = +mx, +my, +mz
|
||||
_, b1, b2, b3, a1, a2, a3, m1, m2, m3, mpuError, magError = myIMUReader.ReadRaw()
|
||||
// This is how the RY83XAI is wired up
|
||||
//m.A1, m.A2, m.A3 = -a2, +a1, -a3
|
||||
//m.B1, m.B2, m.B3 = +b2, -b1, +b3
|
||||
//m.M1, m.M2, m.M3 = +m1, +m2, +m3
|
||||
// This is how the OpenFlightBox board is wired up
|
||||
//m.A1, m.A2, m.A3 = +a1, -a2, +a3
|
||||
//m.B1, m.B2, m.B3 = -b1, +b2, -b3
|
||||
//m.M1, m.M2, m.M3 = +m2, +m1, +m3
|
||||
m.A1 = -(ff[0][0]*a1 + ff[0][1]*a2 + ff[0][2]*a3)
|
||||
m.A2 = -(ff[1][0]*a1 + ff[1][1]*a2 + ff[1][2]*a3)
|
||||
m.A3 = -(ff[2][0]*a1 + ff[2][1]*a2 + ff[2][2]*a3)
|
||||
m.B1 = ff[0][0]*b1 + ff[0][1]*b2 + ff[0][2]*b3
|
||||
m.B2 = ff[1][0]*b1 + ff[1][1]*b2 + ff[1][2]*b3
|
||||
m.B3 = ff[2][0]*b1 + ff[2][1]*b2 + ff[2][2]*b3
|
||||
m.M1 = ff[0][0]*m1 + ff[0][1]*m2 + ff[0][2]*m3
|
||||
m.M2 = ff[1][0]*m1 + ff[1][1]*m2 + ff[1][2]*m3
|
||||
m.M3 = ff[2][0]*m1 + ff[2][1]*m2 + ff[2][2]*m3
|
||||
m.SValid = mpuError == nil
|
||||
m.MValid = magError == nil
|
||||
if mpuError != nil {
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
<p><strong>GPS</strong> shows position with estimated accuracy, ground track, ground speed, and geometric altitude. Location is displayed on a world map.</p>
|
||||
<p><strong>Satellites</strong> shows the status of GNSS constellations, and lists all satellites that your receiver is tracking. Stratux uses Satellite Based Augmentation System (SBAS) and multi-GNSS solutions on supported receivers. GPS satellites are prefixed with "G", SBAS satellites such as WAAS or EGNOS are prefixed with "S", and Russian GLONASS satellites are prefixed with "R". A checkmark shows if each satellite is used in the current position solution. For each satellite, the elevation, azimuth, and signal strength are provided. A summary of total satellites is presented at the bottom of the table.</p>
|
||||
<p><strong>AHRS</strong> reports heading, pressure altitude, pitch and roll, along with a graphical representation of movement. As of version v0.8, heading is derived from GPS track, and is provided in degrees true.</p>
|
||||
<p>The AHRS graphical depiction is a 3-dimensional paper airplane. Heading of 000° is depicted with the nose of the airplane into the page; 180° is depicted with the nose pointing out of the page.The airplane will pitch up/down and left/right based on the data from the AHRS. To aid with recognizing orientation, the <span class="paperairplane_left">left wing is blue</span> and the <span class="paperairplane_right">right wing is tan</span>.</p>
|
||||
<p>The AHRS graphical depiction is an artificial horizon with a heading readout at the bottom. The AHRS sensor orientation must be specified relative to the aircraft before use by pressing the "Calibrate AHRS Sensors" button in the "AHRS" section of the <strong>Settings</strong> page.</p>
|
||||
<p class="text-warning">NOTE: This page is for reference only and must not be used for flight operations.</p>
|
||||
</div>
|
|
@ -56,7 +56,7 @@ ahrsRenderer.prototype = {
|
|||
},
|
||||
|
||||
animate: function (t, pitch, roll, heading) {
|
||||
var FPS = 100; // we assume we can maintain a certain frame rate
|
||||
var FPS = 80; // we assume we can maintain a certain frame rate
|
||||
var x_inc = ((pitch - this.pitch) / (FPS * t));
|
||||
var y_inc = ((roll - this.roll) / (FPS * t));
|
||||
if ((heading < this.heading) && (this.heading - heading) > 180) {
|
||||
|
|
Ładowanie…
Reference in New Issue