2014-04-28 11:23:12 -07:00
|
|
|
package ardrone
|
2014-04-26 03:11:51 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ArdroneDriver struct {
|
|
|
|
gobot.Driver
|
|
|
|
Adaptor DroneInterface
|
|
|
|
}
|
|
|
|
|
|
|
|
type DroneInterface interface {
|
|
|
|
Drone() drone
|
|
|
|
}
|
|
|
|
|
2014-05-20 23:36:44 -07:00
|
|
|
func NewArdroneDriver(adaptor DroneInterface, name string) *ArdroneDriver {
|
2014-04-28 11:23:12 -07:00
|
|
|
return &ArdroneDriver{
|
|
|
|
Driver: gobot.Driver{
|
2014-05-20 23:36:44 -07:00
|
|
|
Name: name,
|
2014-04-28 11:23:12 -07:00
|
|
|
Events: map[string]chan interface{}{
|
|
|
|
"Flying": make(chan interface{}, 1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Adaptor: adaptor,
|
|
|
|
}
|
2014-04-26 03:11:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func (me *ArdroneDriver) Start() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Halt() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Init() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (me *ArdroneDriver) TakeOff() {
|
|
|
|
gobot.Publish(me.Events["Flying"], gobot.Call(me.Adaptor.Drone(), "Takeoff"))
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Land() {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Land")
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Up(a float64) {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Up", a)
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Down(a float64) {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Down", a)
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Left(a float64) {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Left", a)
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Right(a float64) {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Right", a)
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Forward(a float64) {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Forward", a)
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Backward(a float64) {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Backward", a)
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Clockwise(a float64) {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Clockwise", a)
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) CounterClockwise(a float64) {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Counterclockwise", a)
|
|
|
|
}
|
|
|
|
func (me *ArdroneDriver) Hover() {
|
|
|
|
gobot.Call(me.Adaptor.Drone(), "Hover")
|
|
|
|
}
|