36 lines
594 B
Go
36 lines
594 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/platforms/leap"
|
|
)
|
|
|
|
func main() {
|
|
gbot := gobot.NewMaster()
|
|
|
|
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,
|
|
)
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
gbot.Start()
|
|
}
|
|
|
|
func printGesture(gesture leap.Gesture) {
|
|
fmt.Println("Gesture", gesture)
|
|
}
|