Documentation
¶
Overview ¶
Package leap provides the Gobot adaptor and driver for the Leap Motion.
Installing:
* First install the [Leap Motion Software](https://www.leapmotion.com/setup). * Then install the package:
go get github.com/hybridgroup/gobot/platforms/leap
Example:
package main import ( "fmt" "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/platforms/leap" ) func main() { gbot := gobot.NewGobot() leapMotionAdaptor := leap.NewLeapMotionAdaptor("leap", "127.0.0.1:6437") l := leap.NewLeapMotionDriver(leapMotionAdaptor, "leap") work := func() { gobot.On(l.Event("message"), func(data interface{}) { fmt.Println(data.(leap.Frame)) }) } robot := gobot.NewRobot("leapBot", []gobot.Connection{leapMotionAdaptor}, []gobot.Device{l}, work, ) gbot.AddRobot(robot) gbot.Start() }
For more information refer to the leap README: https://github.com/hybridgroup/gobot/blob/master/platforms/leap/README.md
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Frame ¶
type Frame struct { CurrentFrameRate float64 `json:"currentFrameRate"` Devices []Device `json:"devices"` Gestures []Gesture `json:"gestures"` Hands []Hand `json:"hands"` ID int `json:"id"` InteractionBox InteractionBox `json:"interactionBox"` Pointables []Pointable `json:"pointables"` R [][]float64 `json:"r"` S float64 `json:"s"` T []float64 `json:"t"` Timestamp int `json:"timestamp"` }
Base representation returned that holds every other objects
type Gesture ¶
type Gesture struct { // circle only Center []float64 `json:"center"` // swipe, keyTap, screenTap only Direction []float64 `json:"direction"` Duration int `json:"duration"` HandIDs []int `json:"handIds"` ID int `json:"id"` PointableIDs []int `json:"pointablesIds"` // swipe, keyTap, screenTap only Position []float64 `json:"position"` // circle, keyTap, screenTap only Progress float64 `json:"progress"` // circle only Radius float64 `json:"radius"` // swipe only Speed float64 `json:"speed"` // swipe only StartPosition []float64 `json:"StartPosition"` // one of "start", "update", "stop" State string `json:"state"` // one of "circle", "swipe", "keyTap", "screenTap" Type string `json:"type"` }
type Hand ¶
type Hand struct { ArmBasis [][]float64 `json:"armBasis"` ArmWidth float64 `json:"armWidth"` Confidence float64 `json:"confidence"` Direction []float64 `json:"direction"` Elbow []float64 `json:"elbow"` GrabStrength float64 `json:"grabStrength"` ID int `json:"id"` PalmNormal []float64 `json:"palmNormal"` PalmPosition []float64 `json:"PalmPosition"` PalmVelocity []float64 `json:"PalmVelocity"` PinchStrength float64 `json:"PinchStrength"` R [][]float64 `json:"r"` S float64 `json:"s"` SphereCenter []float64 `json:"sphereCenter"` SphereRadius float64 `json:"sphereRadius"` StabilizedPalmPosition []float64 `json:"stabilizedPalmPosition"` T []float64 `json:"t"` TimeVisible float64 `json:"TimeVisible"` Type string `json:"type"` Wrist []float64 `json:"wrist"` }
type InteractionBox ¶
type LeapMotionAdaptor ¶
type LeapMotionAdaptor struct {
// contains filtered or unexported fields
}
func NewLeapMotionAdaptor ¶
func NewLeapMotionAdaptor(name string, port string) *LeapMotionAdaptor
NewLeapMotionAdaptor creates a new leap motion adaptor using specified name and port
func (*LeapMotionAdaptor) Connect ¶
func (l *LeapMotionAdaptor) Connect() (errs []error)
Connect returns true if connection to leap motion is established succesfully
func (*LeapMotionAdaptor) Finalize ¶
func (l *LeapMotionAdaptor) Finalize() (errs []error)
Finalize ends connection to leap motion
func (*LeapMotionAdaptor) Name ¶
func (l *LeapMotionAdaptor) Name() string
func (*LeapMotionAdaptor) Port ¶
func (l *LeapMotionAdaptor) Port() string
type LeapMotionDriver ¶
func NewLeapMotionDriver ¶
func NewLeapMotionDriver(a *LeapMotionAdaptor, name string) *LeapMotionDriver
NewLeapMotionDriver creates a new leap motion driver with specified name
Adds the following events:
"message" - Gets triggered when receiving a message from leap motion
func (*LeapMotionDriver) Connection ¶
func (l *LeapMotionDriver) Connection() gobot.Connection
func (*LeapMotionDriver) Halt ¶
func (l *LeapMotionDriver) Halt() (errs []error)
Halt returns true if driver is halted succesfully
func (*LeapMotionDriver) Name ¶
func (l *LeapMotionDriver) Name() string
func (*LeapMotionDriver) ParseFrame ¶
func (l *LeapMotionDriver) ParseFrame(data []byte) Frame
ParseFrame converts json data to a Frame
func (*LeapMotionDriver) Start ¶
func (l *LeapMotionDriver) Start() (errs []error)
Start inits leap motion driver by enabling gestures and listening from incoming messages.
Publishes the following events:
"message" - Emits Frame on new message received from Leap.
type Pointable ¶
type Pointable struct { Bases [][]float64 `json:"bases"` BTipPosition []float64 `json:"btipPosition"` CarpPosition []float64 `json:"carpPosition"` DipPosition []float64 `json:"dipPosition"` Direction []float64 `json:"direction"` Extended bool `json:"extended"` HandID int `json:"handId"` ID int `json:"id"` Length float64 `json:"length"` MCPPosition []float64 `json:"mcpPosition"` PIPPosition []float64 `json:"pipPosition"` StabilizedTipPosition []float64 `json:"stabilizedTipPosition"` TimeVisible float64 `json:"timeVisible"` TipPosition []float64 `json:"tipPosition"` TipVelocity []float64 `json:"tipVelocity"` Tool bool `json:"tool"` TouchDistance float64 `json:"touchDistance"` TouchZone string `json:"touchZone"` Type int `json:"type"` Width float64 `json:"width"` }