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

31 lines
661 B
Go
Raw Normal View History

2014-04-27 17:43:15 -07:00
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
2014-05-22 20:35:45 -07:00
"github.com/hybridgroup/gobot/platforms/leap"
2014-04-27 17:43:15 -07:00
)
func main() {
2014-05-22 20:35:45 -07:00
gbot := gobot.NewGobot()
leapMotionAdaptor := leap.NewLeapMotionAdaptor("leap", "127.0.0.1:6437")
2014-06-08 18:05:52 -07:00
l := leap.NewLeapMotionDriver(leapMotionAdaptor, "leap")
2014-04-27 17:43:15 -07:00
work := func() {
2014-06-08 18:05:52 -07:00
gobot.On(l.Events["Message"], func(data interface{}) {
2014-04-27 17:43:15 -07:00
printHands(data.(leap.Frame))
})
}
2014-05-22 20:35:45 -07:00
gbot.Robots = append(gbot.Robots, gobot.NewRobot(
2014-06-08 18:05:52 -07:00
"leapBot", []gobot.Connection{leapMotionAdaptor}, []gobot.Device{l}, work))
2014-04-27 17:43:15 -07:00
2014-05-22 20:35:45 -07:00
gbot.Start()
2014-04-27 17:43:15 -07:00
}
func printHands(frame leap.Frame) {
for key, hand := range frame.Hands {
fmt.Println("Hand", key, hand)
}
}