ollie

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2017 License: Apache-2.0, Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

README

Sphero Ollie

The Sphero Ollie is a toy robot from Sphero that is controlled using Bluetooth LE. For more information, go to http://www.sphero.com/ollie

How to Install

go get -d -u gobot.io/x/gobot/... && go install gobot.io/x/gobot/platforms/ble

How to Use

package main

import (
	"os"
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/ble"
	"gobot.io/x/gobot/platforms/sphero/ollie"
)

func main() {
	bleAdaptor := ble.NewClientAdaptor(os.Args[1])
	ollie := ollie.NewDriver(bleAdaptor)

	work := func() {
		gobot.Every(1*time.Second, func() {
			r := uint8(gobot.Rand(255))
			g := uint8(gobot.Rand(255))
			b := uint8(gobot.Rand(255))
			ollie.SetRGB(r, g, b)
		})
	}

	robot := gobot.NewRobot("ollieBot",
		[]gobot.Connection{bleAdaptor},
		[]gobot.Device{ollie},
		work,
	)

	robot.Start()
}

How to Connect

The Sphero Ollie is a Bluetooth LE device.

You need to know the BLE ID of the Ollie you want to connect to. The Gobot BLE client adaptor also lets you connect by friendly name, aka "2B-1247".

OSX

To run any of the Gobot BLE code you must use the GODEBUG=cgocheck=0 flag in order to get around some of the issues in the CGo-based implementation.

For example:

GODEBUG=cgocheck=0 go run examples/ollie.go 2B-1247

OSX uses its own Bluetooth ID system which is different from the IDs used on Linux. The code calls thru the XPC interfaces provided by OSX, so as a result does not need to run under sudo.

Ubuntu

On Linux the BLE code will need to run as a root user account. The easiest way to accomplish this is probably to use go build to build your program, and then to run the requesting executable using sudo.

For example:

go build examples/ollie.go
sudo ./minidrone 2B-1247
Windows

Hopefully coming soon...

Documentation

Overview

Package ollie contains the Gobot driver for the Sphero Ollie.

For more information refer to the Ollie README: https://github.com/hybridgroup/gobot/blob/master/platforms/sphero/ollie/README.md

Index

Constants

View Source
const (

	// SensorData event
	SensorData = "sensordata"

	// Collision event
	Collision = "collision"

	// Error event
	Error = "error"

	// Packet header size
	PacketHeaderSize = 5

	// Response packet max size
	ResponsePacketMaxSize = 20

	// Collision Packet data size: The number of bytes following the DLEN field through the end of the packet
	CollisionDataSize = 17

	// Full size of the collision response
	CollisionResponseSize = PacketHeaderSize + CollisionDataSize
)

Variables

This section is empty.

Functions

func DefaultCollisionConfig added in v1.2.0

func DefaultCollisionConfig() sphero.CollisionConfig

DefaultCollisionConfig returns a CollisionConfig with sensible collision defaults

Types

type Driver

type Driver struct {
	gobot.Eventer
	// contains filtered or unexported fields
}

Driver is the Gobot driver for the Sphero Ollie robot

func NewDriver

func NewDriver(a *ble.ClientAdaptor) *Driver

NewDriver creates a Driver for a Sphero Ollie

func (*Driver) AntiDOSOff

func (b *Driver) AntiDOSOff() (err error)

AntiDOSOff turns off Anti-DOS code so we can control Ollie

func (*Driver) ConfigureCollisionDetection added in v1.2.0

func (b *Driver) ConfigureCollisionDetection(cc sphero.CollisionConfig)

ConfigureCollisionDetection configures the sensitivity of the detection.

func (*Driver) Connection

func (b *Driver) Connection() gobot.Connection

Connection returns the connection to this Ollie

func (*Driver) EnableStopOnDisconnect

func (b *Driver) EnableStopOnDisconnect()

EnableStopOnDisconnect auto-sends a Stop command after losing the connection

func (*Driver) Halt

func (b *Driver) Halt() (err error)

Halt stops Ollie driver (void)

func (*Driver) HandleResponses

func (b *Driver) HandleResponses(data []byte, e error)

HandleResponses handles responses returned from Ollie

func (*Driver) Init

func (b *Driver) Init() (err error)

Init is used to initialize the Ollie

func (*Driver) Name

func (b *Driver) Name() string

Name returns the name for the Driver

func (*Driver) Roll

func (b *Driver) Roll(speed uint8, heading uint16)

Roll tells the Ollie to roll

func (*Driver) SetName

func (b *Driver) SetName(n string)

SetName sets the Name for the Driver

func (*Driver) SetRGB

func (b *Driver) SetRGB(r uint8, g uint8, bl uint8)

SetRGB sets the Ollie to the given r, g, and b values

func (*Driver) SetTXPower

func (b *Driver) SetTXPower(level int) (err error)

SetTXPower sets transmit level

func (*Driver) Sleep

func (b *Driver) Sleep()

Sleep says Go to sleep

func (*Driver) Start

func (b *Driver) Start() (err error)

Start tells driver to get ready to do work

func (*Driver) Stop

func (b *Driver) Stop()

Stop tells the Ollie to stop

func (*Driver) Wake

func (b *Driver) Wake() (err error)

Wake wakes Ollie up so we can play

Jump to

Keyboard shortcuts

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