gobot.io/x/gobot/v2@v2.1.0/platforms/parrot/bebop/client/examples/takeoff.go (about)

     1  //go:build example
     2  // +build example
     3  
     4  //
     5  // Do not build by default.
     6  
     7  package main
     8  
     9  import (
    10  	"fmt"
    11  	"time"
    12  
    13  	"gobot.io/x/gobot/v2/platforms/parrot/bebop/client"
    14  )
    15  
    16  func main() {
    17  	bebop := client.New()
    18  
    19  	if err := bebop.Connect(); err != nil {
    20  		fmt.Println(err)
    21  		return
    22  	}
    23  
    24  	bebop.HullProtection(true)
    25  
    26  	fmt.Println("takeoff")
    27  	if err := bebop.TakeOff(); err != nil {
    28  		fmt.Println(err)
    29  		fmt.Println("fail")
    30  		return
    31  	}
    32  	time.Sleep(5 * time.Second)
    33  	fmt.Println("land")
    34  	if err := bebop.Land(); err != nil {
    35  		fmt.Println(err)
    36  		return
    37  	}
    38  
    39  	time.Sleep(5 * time.Second)
    40  	fmt.Println("done")
    41  }