Change float32 types to float64 types to match AHRS library outputs.

pull/624/head
Christopher Young 2017-06-05 16:19:45 -04:00
rodzic 215b6034d6
commit ca4ae22c42
3 zmienionych plików z 22 dodań i 22 usunięć

Wyświetl plik

@ -250,7 +250,7 @@ func degreesHdg(angle float64) float64 {
} }
// roundToInt16 cheaply rounds a float64 to an int16, rather than truncating // roundToInt16 cheaply rounds a float64 to an int16, rather than truncating
func roundToInt16(in float32) (out int16) { func roundToInt16(in float64) (out int16) {
if in >= 0 { if in >= 0 {
out = int16(in + 0.5) out = int16(in + 0.5)
} else { } else {

Wyświetl plik

@ -87,15 +87,15 @@ type SituationData struct {
// From AHRS source. // From AHRS source.
muAttitude *sync.Mutex muAttitude *sync.Mutex
AHRSPitch float32 AHRSPitch float64
AHRSRoll float32 AHRSRoll float64
AHRSGyroHeading float32 AHRSGyroHeading float64
AHRSMagHeading float32 AHRSMagHeading float64
AHRSSlipSkid float32 AHRSSlipSkid float64
AHRSTurnRate float32 AHRSTurnRate float64
AHRSGLoad float32 AHRSGLoad float64
AHRSGLoadMin float32 AHRSGLoadMin float64
AHRSGLoadMax float32 AHRSGLoadMax float64
AHRSLastAttitudeTime time.Time AHRSLastAttitudeTime time.Time
AHRSStatus uint8 AHRSStatus uint8
} }
@ -1874,7 +1874,7 @@ func makeAHRSGDL90Report() {
} }
if isTempPressValid() { if isTempPressValid() {
palt = uint16(mySituation.BaroPressureAltitude + 5000.5) palt = uint16(mySituation.BaroPressureAltitude + 5000.5)
vs = roundToInt16(mySituation.BaroVerticalSpeed) vs = roundToInt16(float64(mySituation.BaroVerticalSpeed))
} }
// Roll. // Roll.
@ -1936,9 +1936,9 @@ func gpsAttitudeSender() {
mySituation.muGPSPerformance.Lock() mySituation.muGPSPerformance.Lock()
index := len(myGPSPerfStats) - 1 index := len(myGPSPerfStats) - 1
if index > 1 { if index > 1 {
mySituation.AHRSPitch = float32(myGPSPerfStats[index].gpsPitch) mySituation.AHRSPitch = myGPSPerfStats[index].gpsPitch
mySituation.AHRSRoll = float32(myGPSPerfStats[index].gpsRoll) mySituation.AHRSRoll = myGPSPerfStats[index].gpsRoll
mySituation.AHRSGyroHeading = mySituation.GPSTrueCourse mySituation.AHRSGyroHeading = float64(mySituation.GPSTrueCourse)
mySituation.AHRSLastAttitudeTime = stratuxClock.Time mySituation.AHRSLastAttitudeTime = stratuxClock.Time
makeAHRSGDL90Report() makeAHRSGDL90Report()

Wyświetl plik

@ -278,15 +278,15 @@ func sensorAttitudeSender() {
mySituation.muAttitude.Lock() mySituation.muAttitude.Lock()
if s.Valid() { if s.Valid() {
roll, pitch, heading = s.RollPitchHeading() roll, pitch, heading = s.RollPitchHeading()
mySituation.AHRSRoll = float32(roll / ahrs.Deg) mySituation.AHRSRoll = roll / ahrs.Deg
mySituation.AHRSPitch = float32(pitch / ahrs.Deg) mySituation.AHRSPitch = pitch / ahrs.Deg
mySituation.AHRSGyroHeading = float32(heading / ahrs.Deg) mySituation.AHRSGyroHeading = heading / ahrs.Deg
// TODO westphae: until magnetometer calibration is performed, no mag heading // TODO westphae: until magnetometer calibration is performed, no mag heading
mySituation.AHRSMagHeading = ahrs.Invalid mySituation.AHRSMagHeading = ahrs.Invalid
mySituation.AHRSSlipSkid = float32(s.SlipSkid()) mySituation.AHRSSlipSkid = s.SlipSkid()
mySituation.AHRSTurnRate = float32(s.RateOfTurn()) mySituation.AHRSTurnRate = s.RateOfTurn()
mySituation.AHRSGLoad = float32(s.GLoad()) mySituation.AHRSGLoad = s.GLoad()
if mySituation.AHRSGLoad < mySituation.AHRSGLoadMin || mySituation.AHRSGLoadMin == 0 { if mySituation.AHRSGLoad < mySituation.AHRSGLoadMin || mySituation.AHRSGLoadMin == 0 {
mySituation.AHRSGLoadMin = mySituation.AHRSGLoad mySituation.AHRSGLoadMin = mySituation.AHRSGLoad
} }
@ -462,6 +462,6 @@ func updateAHRSStatus() {
} }
} }
func isAHRSInvalidValue(val float32) bool { func isAHRSInvalidValue(val float64) bool {
return math.Abs(float64(val)-float64(ahrs.Invalid)) < 0.01 return math.Abs(val-ahrs.Invalid) < 0.01
} }