ardrone

package
v0.0.0-...-b9750d8 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2014 License: MIT Imports: 7 Imported by: 100

README

ardrone

A Go implementation of the Parrot AR Drone protocols. Not complete yet, but the stuff that is implemented should work : ).

Get the latest version from Github

go get github.com/felixge/ardrone

The code below will execute a nice little sequence, but please make sure you have enough space when running it.

package main

import (
	"github.com/felixge/ardrone"
	"time"
)

func main() {
	client, err := ardrone.Connect(ardrone.DefaultConfig())
	if err != nil {
		panic(err)
	}

	client.Takeoff()
	client.Vertical(1*time.Second, 0.5)
	time.Sleep(3 * time.Second)
	client.Roll(1*time.Second, 0.5)
	time.Sleep(3 * time.Second)
	client.Roll(1*time.Second, -0.5)
	time.Sleep(3 * time.Second)
	client.Animate(ardrone.FLIP_LEFT, 200)
	time.Sleep(5 * time.Second)
	client.Land()
}

Save the code into a file and run:

go run main.go

API Documentation

The API documentation can be found here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnimationId

type AnimationId int
const (
	PHI_M30_DEG AnimationId = iota
	PHI_30_DEG
	THETA_M30_DEG
	THETA_30_DEG
	THETA_20_DEG_YAW_200_DEG
	THETA_20_DEG_YAWM_200_DEG
	TURNAROUND
	TURNAROUND_GODOWN
	YAW_SHAKE
	YAW_DANCE
	PHI_DANCE
	THETA_DANCE
	VZ_DANCE
	WAVE
	PHI_THETA_MIXED
	DOUBLE_PHI_THETA_MIXED
	FLIP_AHEAD
	FLIP_BEHIND
	FLIP_LEFT
	FLIP_RIGHT
)

type Client

type Client struct {
	Config Config

	Navdata chan *navdata.Navdata // @TODO: make read-only
	// contains filtered or unexported fields
}

func Connect

func Connect(config Config) (*Client, error)

func (*Client) Animate

func (client *Client) Animate(id AnimationId, arg int)

func (*Client) Apply

func (client *Client) Apply(state State)

Apply sets the desired state of the drone. Internally this is turned into one or more commands that the sendLoop transmits to the drone every 30ms.

func (*Client) ApplyFor

func (client *Client) ApplyFor(duration time.Duration, state State)

Applies a given state for a certain duration, and resets the state to its zero value (hover) before returning.

func (*Client) Backward

func (client *Client) Backward(speed float64)

func (*Client) Clockwise

func (client *Client) Clockwise(speed float64)

func (*Client) Connect

func (client *Client) Connect() error

func (*Client) Counterclockwise

func (client *Client) Counterclockwise(speed float64)

func (*Client) Down

func (client *Client) Down(speed float64)

func (*Client) Forward

func (client *Client) Forward(speed float64)

func (*Client) Hover

func (client *Client) Hover()

func (*Client) Land

func (client *Client) Land()

@TODO Implement error return value

func (*Client) Left

func (client *Client) Left(speed float64)

func (*Client) Pitch

func (client *Client) Pitch(duration time.Duration, speed float64)

func (*Client) Right

func (client *Client) Right(speed float64)

func (*Client) Roll

func (client *Client) Roll(duration time.Duration, speed float64)

func (*Client) Takeoff

func (client *Client) Takeoff() bool

@TODO Implement error return value

func (*Client) Up

func (client *Client) Up(speed float64)

func (*Client) Vertical

func (client *Client) Vertical(duration time.Duration, speed float64)

func (*Client) Yaw

func (client *Client) Yaw(duration time.Duration, speed float64)

type Config

type Config struct {
	Ip             string
	NavdataPort    int
	AtPort         int
	NavdataTimeout time.Duration
}

func DefaultConfig

func DefaultConfig() Config

type KeyVal

type KeyVal struct {
	Key   string
	Value string
}

type State

type State struct {
	Pitch     float64  // -1 = max back, 1 = max forward
	Roll      float64  // -1 = max left, 1 = max right
	Yaw       float64  // -1 = max counter clockwise, 1 = max clockwise
	Vertical  float64  // -1 = max down, 1 = max up
	Fly       bool     // Set to false for landing.
	Emergency bool     // Used to disable / trigger emergency mode
	Config    []KeyVal // Config values to send
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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