2015-07-22 11:03:27 +08:00
|
|
|
package bebop
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hybridgroup/gobot/platforms/bebop/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
2015-07-24 00:03:46 +08:00
|
|
|
StartRecording() error
|
|
|
|
StopRecording() error
|
2015-10-05 14:06:26 +08:00
|
|
|
HullProtection(protect bool) error
|
2015-10-25 07:45:53 +08:00
|
|
|
Outdoor(outdoor bool) error
|
2015-07-22 11:03:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 }
|