2023-05-20 20:25:21 +08:00
|
|
|
//go:build example
|
2017-03-13 23:01:39 +08:00
|
|
|
// +build example
|
2023-05-20 20:25:21 +08:00
|
|
|
|
2017-03-13 23:01:39 +08:00
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
2016-12-27 08:07:21 +08:00
|
|
|
/*
|
2023-05-20 20:25:21 +08:00
|
|
|
This example will connect to the Parrot Bebop and streams the drone video
|
|
|
|
via the RTP protocol.
|
|
|
|
|
|
|
|
In order to run this example you will first need to connect to the drone with:
|
2016-12-27 08:07:21 +08:00
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
$ go run bebop_ps3_video.go
|
2016-12-27 08:07:21 +08:00
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
then in a separate terminal run this program:
|
2016-12-27 08:07:21 +08:00
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
$ mplayer examples/bebop.sdp
|
2016-12-27 08:07:21 +08:00
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
You can view the video feed by navigating to
|
|
|
|
http://localhost:8090/bebop.mjpeg in a web browser.
|
|
|
|
*NOTE* firefox works best for viewing the video feed.
|
2016-12-27 08:07:21 +08:00
|
|
|
*/
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-02-11 22:34:50 +08:00
|
|
|
"fmt"
|
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
"gobot.io/x/gobot/v2"
|
|
|
|
"gobot.io/x/gobot/v2/platforms/parrot/bebop"
|
2016-12-27 08:07:21 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
bebopAdaptor := bebop.NewAdaptor()
|
|
|
|
drone := bebop.NewDriver(bebopAdaptor)
|
|
|
|
|
|
|
|
work := func() {
|
2024-02-11 22:34:50 +08:00
|
|
|
if err := drone.VideoEnable(true); err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
2016-12-27 08:07:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("drone",
|
|
|
|
[]gobot.Connection{bebopAdaptor},
|
|
|
|
[]gobot.Device{drone},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2024-02-11 22:34:50 +08:00
|
|
|
if err := robot.Start(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-12-27 08:07:21 +08:00
|
|
|
}
|