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