minidrone

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2016 License: Apache-2.0, Apache-2.0, Apache-2.0 Imports: 6 Imported by: 0

README

Parrot Minidrone

The Parrot Minidrone is very inexpensive quadcopter that is controlled using Bluetooth LE.

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 (
	"fmt"
	"os"
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/ble"
	"gobot.io/x/gobot/platforms/parrot/minidrone"
)

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

	work := func() {
		drone.On(drone.Event("battery"), func(data interface{}) {
			fmt.Printf("battery: %d\n", data)
		})

		drone.On(drone.Event("status"), func(data interface{}) {
			fmt.Printf("status: %d\n", data)
		})

		drone.On(drone.Event("flying"), func(data interface{}) {
			fmt.Println("flying!")
			gobot.After(5*time.Second, func() {
				fmt.Println("landing...")
				drone.Land()
				drone.Land()
			})
		})

		drone.On(drone.Event("landed"), func(data interface{}) {
			fmt.Println("landed.")
		})

		time.Sleep(1000 * time.Millisecond)
		drone.TakeOff()
	}

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

	robot.Start()
}

How to Connect

The Parrot Minidrone is a Bluetooth LE device.

You need to know the BLE ID of the Minidrone you want to connect to. The Gobot BLE client adaptor also lets you connect by friendly name, aka "RS_1234".

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/minidrone.go RS_1234

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/minidrone.go
sudo ./bb8 RS_1234
Windows

Hopefully coming soon...

Documentation

Overview

Package minidrone contains the Gobot driver for the Parrot Minidrone.

For more information refer to the minidrone README: https://gobot.io/x/gobot/blob/master/platforms/parrot/minidrone/README.md

Index

Constants

View Source
const (
	// service IDs
	DroneCommandService      = "9a66fa000800919111e4012d1540cb8e"
	DroneNotificationService = "9a66fb000800919111e4012d1540cb8e"

	// characteristic IDs
	PcmdCharacteristic         = "9a66fa0a0800919111e4012d1540cb8e"
	CommandCharacteristic      = "9a66fa0b0800919111e4012d1540cb8e"
	FlightStatusCharacteristic = "9a66fb0e0800919111e4012d1540cb8e"
	BatteryCharacteristic      = "9a66fb0f0800919111e4012d1540cb8e"

	// Battery event
	Battery = "battery"

	// flight status event
	Status = "status"

	// flying event
	Flying = "flying"

	// landed event
	Landed = "landed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver is gobot software device to the keyboard

func NewDriver

func NewDriver(a *ble.ClientAdaptor) *Driver

NewDriver creates a Parrot Minidrone Driver

func (*Driver) BackFlip

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

func (*Driver) Backward

func (b *Driver) Backward(val int) error

func (*Driver) Clockwise

func (b *Driver) Clockwise(val int) error

func (*Driver) Connection

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

func (*Driver) CounterClockwise

func (b *Driver) CounterClockwise(val int) error

func (*Driver) Down

func (b *Driver) Down(val int) error

func (*Driver) FlatTrim

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

func (*Driver) Forward

func (b *Driver) Forward(val int) error

func (*Driver) FrontFlip

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

func (*Driver) GenerateAllStates

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

func (*Driver) Halt

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

Halt stops minidrone driver (void)

func (*Driver) HullProtection

func (b *Driver) HullProtection(protect bool) error

HullProtection not supported

func (*Driver) Init

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

func (*Driver) Land

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

func (*Driver) Left

func (b *Driver) Left(val int) error

func (*Driver) LeftFlip

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

func (*Driver) Name

func (b *Driver) Name() string

Name returns the Driver Name

func (*Driver) Outdoor

func (b *Driver) Outdoor(outdoor bool) error

Outdoor not supported

func (*Driver) Right

func (b *Driver) Right(val int) error

func (*Driver) RightFlip

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

func (*Driver) SetName

func (b *Driver) SetName(n string)

SetName sets the Driver Name

func (*Driver) Start

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

Start tells driver to get ready to do work

func (*Driver) StartPcmd

func (b *Driver) StartPcmd()

func (*Driver) StartRecording

func (b *Driver) StartRecording() error

StartRecording not supported

func (*Driver) Stop

func (b *Driver) Stop() error

func (*Driver) StopRecording

func (b *Driver) StopRecording() error

StopRecording not supported

func (*Driver) TakeOff

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

func (*Driver) Up

func (b *Driver) Up(val int) error

type Pcmd

type Pcmd struct {
	Flag  int
	Roll  int
	Pitch int
	Yaw   int
	Gaz   int
	Psi   float32
}

Jump to

Keyboard shortcuts

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