hybridgroup.gobot/platforms/leap/README.md

73 lines
1.8 KiB
Markdown
Raw Normal View History

2014-07-07 03:17:10 +08:00
# Leap
2014-11-29 07:34:42 +08:00
The Leap Motion is a user-interface device that tracks the user's hand motions, and translates them into events that can control robots and physical computing hardware.
2014-11-29 07:34:42 +08:00
For more info about the Leap Motion platform click [Leap Motion](https://www.leapmotion.com/)
## How to Install
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-11-29 07:34:42 +08:00
2014-06-10 10:01:53 +08:00
```
go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/leap
2014-06-10 10:01:53 +08:00
```
2014-11-29 07:34:42 +08:00
## How to Use
```go
package main
import (
"fmt"
2014-07-11 08:02:00 +08:00
"github.com/hybridgroup/gobot"
2014-06-10 10:01:53 +08:00
"github.com/hybridgroup/gobot/platforms/leap"
)
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")
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-07-11 08:02:00 +08:00
robot := gobot.NewRobot("leapBot",
[]gobot.Connection{leapMotionAdaptor},
[]gobot.Device{l},
work,
)
gbot.AddRobot(robot)
2014-06-10 10:01:53 +08:00
gbot.Start()
}
2014-07-11 08:02:00 +08:00
```
2014-11-29 07:34:42 +08:00
## How To Connect
### OSX
2014-11-29 07:34:42 +08:00
This driver works out of the box with the vanilla installation of the Leap Motion Software that you get in their [Setup Guide](https://www.leapmotion.com/setup).
The main steps are:
* Run Leap Motion.app to open a websocket connection in port 6437.
* Connect your Computer and Leap Motion Controller.
* Connect to the device via Gobot.
### Ubuntu
The Linux download of the Leap Motion software can be obtained from [Leap Motion Dev Center](https://developer.leapmotion.com/downloads) (requires free signup)
The main steps are:
* Run the leapd daemon, to open a websocket connection in port 6437.
* Connect your computer and the Leap Motion controller
* Connect to the device via Gobot