2014-10-17 23:43:48 +08:00
|
|
|
/*
|
2014-10-29 05:52:59 +08:00
|
|
|
Package leap provides the Gobot adaptor and driver for the Leap Motion.
|
2014-10-17 23:43:48 +08:00
|
|
|
|
|
|
|
Installing:
|
|
|
|
|
|
|
|
* First install the [Leap Motion Software](https://www.leapmotion.com/setup).
|
|
|
|
* Then install the package:
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
go get gobot.io/x/gobot/platforms/leap
|
2014-10-17 23:43:48 +08:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/platforms/leap"
|
2014-10-17 23:43:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-09-26 03:36:01 +08:00
|
|
|
leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437")
|
|
|
|
l := leap.NewDriver(leapMotionAdaptor)
|
2014-10-17 23:43:48 +08:00
|
|
|
|
|
|
|
work := func() {
|
2016-10-17 14:43:04 +08:00
|
|
|
l.On(l.Event("message"), func(data interface{}) {
|
2014-10-17 23:43:48 +08:00
|
|
|
fmt.Println(data.(leap.Frame))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("leapBot",
|
|
|
|
[]gobot.Connection{leapMotionAdaptor},
|
|
|
|
[]gobot.Device{l},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-19 03:37:10 +08:00
|
|
|
robot.Start()
|
2014-10-17 23:43:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
For more information refer to the leap README:
|
2016-12-08 20:24:03 +08:00
|
|
|
https://gobot.io/x/gobot/blob/master/platforms/leap/README.md
|
2014-10-17 23:43:48 +08:00
|
|
|
*/
|
2016-12-08 20:24:03 +08:00
|
|
|
package leap // import "gobot.io/x/gobot/platforms/leap"
|