2014-07-07 03:17:10 +08:00
|
|
|
# Leap
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-06-10 10:01:53 +08:00
|
|
|
This package provides the Gobot adaptor and driver for the [Leap Motion](https://www.leapmotion.com/)
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
## Getting Started
|
|
|
|
|
2014-06-10 10:01:53 +08:00
|
|
|
First install the [Leap Motion Software](https://www.leapmotion.com/setup)
|
|
|
|
|
|
|
|
Now you can install the package with
|
|
|
|
```
|
2014-07-07 03:17:10 +08:00
|
|
|
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/leap
|
2014-06-10 10:01:53 +08:00
|
|
|
```
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-07-11 08:02:00 +08:00
|
|
|
|
2014-04-26 18:11:51 +08:00
|
|
|
"github.com/hybridgroup/gobot"
|
2014-06-10 10:01:53 +08:00
|
|
|
"github.com/hybridgroup/gobot/platforms/leap"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-06-10 10:01:53 +08:00
|
|
|
gbot := gobot.NewGobot()
|
2014-07-11 08:02:00 +08:00
|
|
|
|
|
|
|
leapMotionAdaptor := leap.NewLeapMotionAdaptor("leap", "127.0.0.1:6437")
|
|
|
|
l := leap.NewLeapMotionDriver(leapMotionAdaptor, "leap")
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
work := func() {
|
2014-07-11 08:02:00 +08:00
|
|
|
gobot.On(l.Event("message"), func(data interface{}) {
|
2014-06-10 10:01:53 +08:00
|
|
|
fmt.Println(data.(leap.Frame))
|
2014-04-26 18:11:51 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-11 08:02:00 +08:00
|
|
|
robot := gobot.NewRobot("leapBot",
|
|
|
|
[]gobot.Connection{leapMotionAdaptor},
|
|
|
|
[]gobot.Device{l},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-06-10 10:01:53 +08:00
|
|
|
gbot.Start()
|
2014-04-26 18:11:51 +08:00
|
|
|
}
|
2014-07-11 08:02:00 +08:00
|
|
|
```
|