1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-14 19:29:32 +08:00
hybridgroup.gobot/platforms/ardrone/ardrone_adaptor.go

51 lines
832 B
Go
Raw Normal View History

package ardrone
import (
2014-04-28 11:23:12 -07:00
client "github.com/hybridgroup/go-ardrone/client"
"github.com/hybridgroup/gobot"
)
2014-06-14 13:55:12 -07:00
type drone interface {
Takeoff() bool
Land()
Up(n float64)
Down(n float64)
Left(n float64)
Right(n float64)
Forward(n float64)
Backward(n float64)
Clockwise(n float64)
Counterclockwise(n float64)
Hover()
}
type ArdroneAdaptor struct {
gobot.Adaptor
2014-04-28 11:23:12 -07:00
drone drone
connect func(*ArdroneAdaptor)
}
func NewArdroneAdaptor(name string) *ArdroneAdaptor {
2014-04-28 11:23:12 -07:00
return &ArdroneAdaptor{
Adaptor: gobot.Adaptor{
Name: name,
},
2014-04-28 11:23:12 -07:00
connect: func(a *ArdroneAdaptor) {
d, err := client.Connect(client.DefaultConfig())
if err != nil {
panic(err)
}
a.drone = d
},
}
}
2014-04-28 11:23:12 -07:00
func (a *ArdroneAdaptor) Connect() bool {
a.connect(a)
return true
}
2014-04-28 11:23:12 -07:00
func (a *ArdroneAdaptor) Finalize() bool {
return true
}