Skip to content

Commit

Permalink
Initial support for the bebop drone
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Jul 22, 2015
1 parent 88f7a68 commit 00c0e49
Show file tree
Hide file tree
Showing 10 changed files with 1,141 additions and 0 deletions.
13 changes: 13 additions & 0 deletions platforms/bebop/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) 2014 The Hybrid Group

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
12 changes: 12 additions & 0 deletions platforms/bebop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Bebop

The Bebop 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.


## How to Install
```
go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/bebop
```
## How to Connect

The Bebop 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.
59 changes: 59 additions & 0 deletions platforms/bebop/bebop_adaptor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package bebop

import (
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/bebop/client"
)

var _ gobot.Adaptor = (*BebopAdaptor)(nil)

// drone defines expected drone behaviour
type drone interface {
TakeOff() error
Land() error
Up(n int) error
Down(n int) error
Left(n int) error
Right(n int) error
Forward(n int) error
Backward(n int) error
Clockwise(n int) error
CounterClockwise(n int) error
Stop() error
Connect() error
Video() chan []byte
}

// BebopAdaptor is gobot.Adaptor representation for the Bebop
type BebopAdaptor struct {
name string
drone drone
//config client.Config
connect func(*BebopAdaptor) error
}

// NewBebopAdaptor returns a new BebopAdaptor
func NewBebopAdaptor(name string) *BebopAdaptor {
return &BebopAdaptor{
name: name,
drone: client.New(),
connect: func(a *BebopAdaptor) error {
return a.drone.Connect()
},
}
}

// Name returns the BebopAdaptors Name
func (a *BebopAdaptor) Name() string { return a.name }

// Connect establishes a connection to the ardrone
func (a *BebopAdaptor) Connect() (errs []error) {
err := a.connect(a)
if err != nil {
return []error{err}
}
return
}

// Finalize terminates the connection to the ardrone
func (a *BebopAdaptor) Finalize() (errs []error) { return }
115 changes: 115 additions & 0 deletions platforms/bebop/bebop_driver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package bebop

import (
"github.com/hybridgroup/gobot"
)

var _ gobot.Driver = (*BebopDriver)(nil)

// BebopDriver is gobot.Driver representation for the Bebop
type BebopDriver struct {
name string
connection gobot.Connection
gobot.Eventer
}

// NewBebopDriver creates an BebopDriver with specified name.
func NewBebopDriver(connection *BebopAdaptor, name string) *BebopDriver {
d := &BebopDriver{
name: name,
connection: connection,
Eventer: gobot.NewEventer(),
}
return d
}

// Name returns the BebopDrivers Name
func (a *BebopDriver) Name() string { return a.name }

// Connection returns the BebopDrivers Connection
func (a *BebopDriver) Connection() gobot.Connection { return a.connection }

// adaptor returns ardrone adaptor
func (a *BebopDriver) adaptor() *BebopAdaptor {
return a.Connection().(*BebopAdaptor)
}

// Start starts the BebopDriver
func (a *BebopDriver) Start() (errs []error) {
return
}

// Halt halts the BebopDriver
func (a *BebopDriver) Halt() (errs []error) {
return
}

// TakeOff makes the drone start flying
func (a *BebopDriver) TakeOff() {
a.adaptor().drone.TakeOff()
}

// Land causes the drone to land
func (a *BebopDriver) Land() {
a.adaptor().drone.Land()
}

// Up makes the drone gain altitude.
// speed can be a value from `0` to `100`.
func (a *BebopDriver) Up(speed int) {
a.adaptor().drone.Up(speed)
}

// Down makes the drone reduce altitude.
// speed can be a value from `0` to `100`.
func (a *BebopDriver) Down(speed int) {
a.adaptor().drone.Down(speed)
}

// 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` to `100`.
func (a *BebopDriver) Left(speed int) {
a.adaptor().drone.Left(speed)
}

// 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` to `100`.
func (a *BebopDriver) Right(speed int) {
a.adaptor().drone.Right(speed)
}

// Forward causes the drone go forward, controls the pitch.
// speed can be a value from `0` to `100`.
func (a *BebopDriver) Forward(speed int) {
a.adaptor().drone.Forward(speed)
}

// Backward causes the drone go forward, controls the pitch.
// speed can be a value from `0` to `100`.
func (a *BebopDriver) Backward(speed int) {
a.adaptor().drone.Backward(speed)
}

// Clockwise causes the drone to spin in clockwise direction
// speed can be a value from `0` to `100`.
func (a *BebopDriver) Clockwise(speed int) {
a.adaptor().drone.Clockwise(speed)
}

// CounterClockwise the drone to spin in counter clockwise direction
// speed can be a value from `0` to `100`.
func (a *BebopDriver) CounterClockwise(speed int) {
a.adaptor().drone.CounterClockwise(speed)
}

// Stop makes the drone to hover in place.
func (a *BebopDriver) Stop() {
a.adaptor().drone.Stop()
}

// Video returns a channel which raw video frames will be broadcast on
func (a *BebopDriver) Video() chan []byte {
return a.adaptor().drone.Video()
}
Loading

0 comments on commit 00c0e49

Please sign in to comment.