ardrone

package
v1.8.0 Latest Latest
Warning

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

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

README

Ardrone

The ARDrone from Parrot is an inexpensive quadcopter that is controlled using WiFi. It includes a built-in front-facing HD video camera, as well as a second lower resolution bottom facing video camera.

For more info about the ARDrone platform click here.

How to Install

go get -d -u gobot.io/x/gobot/...

How to Use

package main

import (
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/parrot/ardrone"
)

func main() {
	ardroneAdaptor := ardrone.NewAdaptor("Drone")
	drone := ardrone.NewDriver(ardroneAdaptor, "Drone")

	work := func() {
		drone.On(drone.Event("flying"), func(data interface{}) {
			gobot.After(3*time.Second, func() {
				drone.Land()
			})
		})
		drone.TakeOff()
	}

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

	robot.Start()
}

How to Connect

The ARDrone is a WiFi device, so there is no additional work to establish a connection to a single drone. However, in order to connect to multiple drones, you need to perform some configuration steps on each drone via SSH.

Documentation

Overview

Package ardrone provides the Gobot adaptor and driver for the Parrot Ardrone.

Installing:

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

Example:

package main

import (
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/platforms/parrot/ardrone"
)

func main() {
	ardroneAdaptor := ardrone.NewAdaptor()
	drone := ardrone.NewDriver(ardroneAdaptor)

	work := func() {
		drone.TakeOff()
		drone.On(drone.Event("flying"), func(data interface{}) {
			gobot.After(3*time.Second, func() {
				drone.Land()
			})
		})
	}

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

	robot.Start()
}

For more information refer to the ardrone README: https://github.com/hybridgroup/gobot/tree/master/platforms/parrot/ardrone/README.md

Index

Constants

View Source
const (
	// Flying event
	Flying = "flying"
)

Variables

This section is empty.

Functions

func ValidatePitch added in v1.2.0

func ValidatePitch(data float64, offset float64) float64

ValidatePitch helps validate pitch values such as those created by a joystick to values between 0-1.0 that are required as params to Parrot ARDrone PCMDs

Types

type Adaptor

type Adaptor struct {
	// contains filtered or unexported fields
}

Adaptor is gobot.Adaptor representation for the Ardrone

func NewAdaptor

func NewAdaptor(v ...string) *Adaptor

NewAdaptor returns a new ardrone.Adaptor and optionally accepts:

string: The ardrones IP Address

func (*Adaptor) Connect

func (a *Adaptor) Connect() (err error)

Connect establishes a connection to the ardrone

func (*Adaptor) Finalize

func (a *Adaptor) Finalize() (err error)

Finalize terminates the connection to the ardrone

func (*Adaptor) Name

func (a *Adaptor) Name() string

Name returns the Adaptor Name

func (*Adaptor) SetName

func (a *Adaptor) SetName(n string)

SetName sets the Adaptor Name

type Driver

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

Driver is gobot.Driver representation for the Ardrone

func NewDriver

func NewDriver(connection *Adaptor) *Driver

NewDriver creates an Driver for the ARDrone.

It add the following events:

'flying' - Sent when the device has taken off.

func (*Driver) Backward

func (a *Driver) Backward(speed float64)

Backward causes the drone go backward, controls the pitch. speed can be a value from `0.0` to `1.0`.

func (*Driver) Clockwise

func (a *Driver) Clockwise(speed float64)

Clockwise causes the drone to spin in clockwise direction speed can be a value from `0.0` to `1.0`.

func (*Driver) Connection

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

Connection returns the Driver Connection

func (*Driver) CounterClockwise

func (a *Driver) CounterClockwise(speed float64)

CounterClockwise the drone to spin in counter clockwise direction speed can be a value from `0.0` to `1.0`.

func (*Driver) Down

func (a *Driver) Down(speed float64)

Down makes the drone reduce altitude. speed can be a value from `0.0` to `1.0`.

func (*Driver) Forward

func (a *Driver) Forward(speed float64)

Forward causes the drone go forward, controls the pitch. speed can be a value from `0.0` to `1.0`.

func (*Driver) Halt

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

Halt halts the Driver

func (*Driver) Hover

func (a *Driver) Hover()

Hover makes the drone to hover in place.

func (*Driver) Land

func (a *Driver) Land()

Land causes the drone to land

func (*Driver) Left

func (a *Driver) Left(speed float64)

Left causes the drone to bank to the left, controls the roll, which is a horizontal movement using the camera as a reference point. speed can be a value from `0.0` to `1.0`.

func (*Driver) Name

func (a *Driver) Name() string

Name returns the Driver Name

func (*Driver) Right

func (a *Driver) Right(speed float64)

Right causes the drone to bank to the right, controls the roll, which is a horizontal movement using the camera as a reference point. speed can be a value from `0.0` to `1.0`.

func (*Driver) SetName

func (a *Driver) SetName(n string)

SetName sets the Driver Name

func (*Driver) Start

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

Start starts the Driver

func (*Driver) TakeOff

func (a *Driver) TakeOff()

TakeOff makes the drone start flying, and publishes `flying` event

func (*Driver) Up

func (a *Driver) Up(speed float64)

Up makes the drone gain altitude. speed can be a value from `0.0` to `1.0`.

Jump to

Keyboard shortcuts

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