1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-14 19:29:32 +08:00
Ron Evans 03e3dcd9b8 tello: ability to send real-time stick commands
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-04-13 13:50:11 +02:00

18 lines
407 B
Go

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