gobot.io/x/gobot/v2@v2.1.0/platforms/parrot/ardrone/pitch.go (about) 1 package ardrone 2 3 import "math" 4 5 // ValidatePitch helps validate pitch values such as those created by 6 // a joystick to values between 0-1.0 that are required as 7 // params to Parrot ARDrone PCMDs 8 func ValidatePitch(data float64, offset float64) float64 { 9 value := math.Abs(data) / offset 10 if value >= 0.1 { 11 if value <= 1.0 { 12 return float64(int(value*100)) / 100 13 } 14 return 1.0 15 } 16 return 0.0 17 }