1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-24 13:48:49 +08:00
hybridgroup.gobot/examples/leap_motion_gestures.go

40 lines
640 B
Go

//go:build example
// +build example
//
// Do not build by default.
package main
import (
"fmt"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/leap"
)
func main() {
leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437")
l := leap.NewDriver(leapMotionAdaptor)
work := func() {
_ = l.On(leap.GestureEvent, func(data interface{}) {
printGesture(data.(leap.Gesture))
})
}
robot := gobot.NewRobot("leapBot",
[]gobot.Connection{leapMotionAdaptor},
[]gobot.Device{l},
work,
)
if err := robot.Start(); err != nil {
panic(err)
}
}
func printGesture(gesture leap.Gesture) {
fmt.Println("Gesture", gesture)
}