1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-06 19:29:15 +08:00
deadprogram 47a13159ef ardrone: add ValidatePitch helper function for ARDrone 2.0 to package
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-02-07 11:31:27 +01:00

18 lines
401 B
Go

package ardrone
import "math"
// ValidatePitch helps validate pitch values such as those created by
// a joystick to values between 0-1.0 that are required as
// params to Parrot ARDrone PCMDs
func ValidatePitch(data float64, offset float64) float64 {
value := math.Abs(data) / offset
if value >= 0.1 {
if value <= 1.0 {
return float64(int(value*100)) / 100
}
return 1.0
}
return 0.0
}