forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
Oops, something went wrong.