func main() { bebop := client.New() if err := bebop.Connect(); err != nil { fmt.Println(err) return } bebop.HullProtection(true) fmt.Println("takeoff") if err := bebop.TakeOff(); err != nil { fmt.Println(err) fmt.Println("fail") return } time.Sleep(5 * time.Second) fmt.Println("land") if err := bebop.Land(); err != nil { fmt.Println(err) return } time.Sleep(5 * time.Second) fmt.Println("done") }
// NewAdaptor returns a new BebopAdaptor func NewAdaptor() *Adaptor { return &Adaptor{ name: "Bebop", drone: client.New(), connect: func(a *Adaptor) error { return a.drone.Connect() }, } }
func main() { bebop := client.New() if err := bebop.Connect(); err != nil { fmt.Println(err) return } if err := bebop.VideoEnable(true); err != nil { fmt.Println(err) return } if err := bebop.VideoStreamMode(0); err != nil { fmt.Println(err) return } ffmpeg := exec.Command("ffmpeg", "-i", "pipe:0", "http://localhost:8090/bebop.ffm") ffmpegErr, err := ffmpeg.StderrPipe() if err != nil { fmt.Println(err) return } ffmpegIn, err := ffmpeg.StdinPipe() if err != nil { fmt.Println(err) return } if err := ffmpeg.Start(); err != nil { fmt.Println(err) return } go func() { for { buf, err := ioutil.ReadAll(ffmpegErr) if err != nil { fmt.Println(err) } if len(buf) > 0 { fmt.Println(string(buf)) } } }() go func() { for { if _, err := ffmpegIn.Write(<-bebop.Video()); err != nil { fmt.Println(err) } } }() time.Sleep(99 * time.Second) }