gobot.io/x/gobot/v2@v2.1.0/platforms/parrot/bebop/bebop_adaptor.go (about) 1 package bebop 2 3 import ( 4 "gobot.io/x/gobot/v2" 5 "gobot.io/x/gobot/v2/platforms/parrot/bebop/client" 6 ) 7 8 // drone defines expected drone behaviour 9 type drone interface { 10 TakeOff() error 11 Land() error 12 Up(n int) error 13 Down(n int) error 14 Left(n int) error 15 Right(n int) error 16 Forward(n int) error 17 Backward(n int) error 18 Clockwise(n int) error 19 CounterClockwise(n int) error 20 Stop() error 21 Connect() error 22 Video() chan []byte 23 StartRecording() error 24 StopRecording() error 25 HullProtection(protect bool) error 26 Outdoor(outdoor bool) error 27 VideoEnable(enable bool) error 28 VideoStreamMode(mode int8) error 29 } 30 31 // Adaptor is gobot.Adaptor representation for the Bebop 32 type Adaptor struct { 33 name string 34 drone drone 35 connect func(*Adaptor) error 36 } 37 38 // NewAdaptor returns a new BebopAdaptor 39 func NewAdaptor() *Adaptor { 40 return &Adaptor{ 41 name: gobot.DefaultName("Bebop"), 42 drone: client.New(), 43 connect: func(a *Adaptor) error { 44 return a.drone.Connect() 45 }, 46 } 47 } 48 49 // Name returns the Bebop Adaptors Name 50 func (a *Adaptor) Name() string { return a.name } 51 52 // SetName sets the Bebop Adaptors Name 53 func (a *Adaptor) SetName(n string) { a.name = n } 54 55 // Connect establishes a connection to the ardrone 56 func (a *Adaptor) Connect() (err error) { 57 err = a.connect(a) 58 return 59 } 60 61 // Finalize terminates the connection to the ardrone 62 func (a *Adaptor) Finalize() (err error) { return }