gobot.io/x/gobot/v2@v2.1.0/examples/bebop_rtp_video.go (about)

     1  //go:build example
     2  // +build example
     3  
     4  //
     5  // Do not build by default.
     6  
     7  /*
     8  This example will connect to the Parrot Bebop and streams the drone video
     9  via the RTP protocol.
    10  
    11  In order to run this example you will first need to connect to the drone with:
    12  
    13  	$ go run bebop_ps3_video.go
    14  
    15  then in a separate terminal run this program:
    16  
    17  	$ mplayer examples/bebop.sdp
    18  
    19  You can view the video feed by navigating to
    20  http://localhost:8090/bebop.mjpeg in a web browser.
    21  *NOTE* firefox works best for viewing the video feed.
    22  */
    23  package main
    24  
    25  import (
    26  	"gobot.io/x/gobot/v2"
    27  	"gobot.io/x/gobot/v2/platforms/parrot/bebop"
    28  )
    29  
    30  func main() {
    31  	bebopAdaptor := bebop.NewAdaptor()
    32  	drone := bebop.NewDriver(bebopAdaptor)
    33  
    34  	work := func() {
    35  		drone.VideoEnable(true)
    36  	}
    37  
    38  	robot := gobot.NewRobot("drone",
    39  		[]gobot.Connection{bebopAdaptor},
    40  		[]gobot.Device{drone},
    41  		work,
    42  	)
    43  
    44  	robot.Start()
    45  }