gobot.io/x/gobot@v1.16.0/examples/bebop.go (about)

     1  // +build example
     2  //
     3  // Do not build by default.
     4  
     5  package main
     6  
     7  import (
     8  	"time"
     9  
    10  	"gobot.io/x/gobot"
    11  	"gobot.io/x/gobot/platforms/parrot/bebop"
    12  )
    13  
    14  func main() {
    15  	bebopAdaptor := bebop.NewAdaptor()
    16  	drone := bebop.NewDriver(bebopAdaptor)
    17  
    18  	work := func() {
    19  		drone.On(bebop.Flying, func(data interface{}) {
    20  			gobot.After(10*time.Second, func() {
    21  				drone.Land()
    22  			})
    23  		})
    24  
    25  		drone.HullProtection(true)
    26  		drone.TakeOff()
    27  	}
    28  
    29  	robot := gobot.NewRobot("drone",
    30  		[]gobot.Connection{bebopAdaptor},
    31  		[]gobot.Device{drone},
    32  		work,
    33  	)
    34  
    35  	robot.Start()
    36  }