32 lines
520 B
Go
32 lines
520 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/platforms/leap"
|
|
)
|
|
|
|
func main() {
|
|
leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437")
|
|
l := leap.NewDriver(leapMotionAdaptor)
|
|
|
|
work := func() {
|
|
l.On(leap.HandEvent, func(data interface{}) {
|
|
printHand(data.(leap.Hand))
|
|
})
|
|
}
|
|
|
|
robot := gobot.NewRobot("leapBot",
|
|
[]gobot.Connection{leapMotionAdaptor},
|
|
[]gobot.Device{l},
|
|
work,
|
|
)
|
|
|
|
robot.Start()
|
|
}
|
|
|
|
func printHand(hand leap.Hand) {
|
|
fmt.Println("Hand", hand)
|
|
}
|