leap

package
v0.0.0-...-86e32b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2014 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

README

Leap

This package provides the Gobot adaptor and driver for the Leap Motion

Getting Started

First install the Leap Motion Software

Now you can install the package with

go get github.com/hybridgroup/gobot && go install 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()
}

Documentation

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"`
	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"`
}

type Gesture

type Gesture struct {
	Direction     []float64   `json:"direction"`
	Duration      int         `json:"duration"`
	Hands         []Hand      `json:"hands"`
	ID            int         `json:"id"`
	Pointables    []Pointable `json:"pointables"`
	Position      []float64   `json:"position"`
	Speed         float64     `json:"speed"`
	StartPosition []float64   `json:"StartPosition"`
	State         string      `json:"state"`
	Type          string      `json:"type"`
}

type Hand

type Hand struct {
	Direction              []float64   `json:"direction"`
	ID                     int         `json:"id"`
	PalmNormal             []float64   `json:"palmNormal"`
	PalmPosition           []float64   `json:"PalmPosition"`
	PalmVelocity           []float64   `json:"PalmVelocity"`
	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"`
}

func (*Hand) X

func (h *Hand) X() float64

func (*Hand) Y

func (h *Hand) Y() float64

func (*Hand) Z

func (h *Hand) Z() float64

type InteractionBox

type InteractionBox struct {
	Center []int     `json:"center"`
	Size   []float64 `json:"size"`
}

type LeapMotionAdaptor

type LeapMotionAdaptor struct {
	gobot.Adaptor
	// contains filtered or unexported fields
}

func NewLeapMotionAdaptor

func NewLeapMotionAdaptor(name string, port string) *LeapMotionAdaptor

func (*LeapMotionAdaptor) Connect

func (l *LeapMotionAdaptor) Connect() bool

func (*LeapMotionAdaptor) Finalize

func (l *LeapMotionAdaptor) Finalize() bool

type LeapMotionDriver

type LeapMotionDriver struct {
	gobot.Driver
}

func NewLeapMotionDriver

func NewLeapMotionDriver(a *LeapMotionAdaptor, name string) *LeapMotionDriver

func (*LeapMotionDriver) Halt

func (l *LeapMotionDriver) Halt() bool

func (*LeapMotionDriver) Init

func (l *LeapMotionDriver) Init() bool

func (*LeapMotionDriver) ParseFrame

func (l *LeapMotionDriver) ParseFrame(data []byte) Frame

func (*LeapMotionDriver) Start

func (l *LeapMotionDriver) Start() bool

type Pointable

type Pointable struct {
	Direction             []float64 `json:"direction"`
	HandID                int       `json:"handId"`
	ID                    int       `json:"id"`
	Length                float64   `json:"length"`
	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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL