bebop: enable video on firmware 3.3+
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
ecb03b64e1
commit
66a64111fc
|
@ -23,6 +23,8 @@ type drone interface {
|
||||||
StopRecording() error
|
StopRecording() error
|
||||||
HullProtection(protect bool) error
|
HullProtection(protect bool) error
|
||||||
Outdoor(outdoor bool) error
|
Outdoor(outdoor bool) error
|
||||||
|
VideoEnable(enable bool) error
|
||||||
|
VideoStreamMode(mode int8) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adaptor is gobot.Adaptor representation for the Bebop
|
// Adaptor is gobot.Adaptor representation for the Bebop
|
||||||
|
|
|
@ -140,3 +140,13 @@ func (a *Driver) HullProtection(protect bool) error {
|
||||||
func (a *Driver) Outdoor(outdoor bool) error {
|
func (a *Driver) Outdoor(outdoor bool) error {
|
||||||
return a.adaptor().drone.Outdoor(outdoor)
|
return a.adaptor().drone.Outdoor(outdoor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VideoEnable tells the drone to start/stop streaming video
|
||||||
|
func (a *Driver) VideoEnable(enable bool) error {
|
||||||
|
return a.adaptor().drone.VideoEnable(enable)
|
||||||
|
}
|
||||||
|
|
||||||
|
// VideoStreamMode tells the drone what mode to use for streaming video
|
||||||
|
func (a *Driver) VideoStreamMode(mode int8) error {
|
||||||
|
return a.adaptor().drone.VideoStreamMode(mode)
|
||||||
|
}
|
||||||
|
|
|
@ -651,6 +651,50 @@ func (b *Bebop) Outdoor(outdoor bool) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Bebop) VideoEnable(enable bool) error {
|
||||||
|
cmd := &bytes.Buffer{}
|
||||||
|
|
||||||
|
cmd.WriteByte(ARCOMMANDS_ID_PROJECT_ARDRONE3)
|
||||||
|
cmd.WriteByte(ARCOMMANDS_ID_ARDRONE3_CLASS_MEDIASTREAMING)
|
||||||
|
|
||||||
|
tmp := &bytes.Buffer{}
|
||||||
|
binary.Write(tmp,
|
||||||
|
binary.LittleEndian,
|
||||||
|
uint16(ARCOMMANDS_ID_ARDRONE3_MEDIASTREAMING_CMD_VIDEOENABLE),
|
||||||
|
)
|
||||||
|
|
||||||
|
cmd.Write(tmp.Bytes())
|
||||||
|
|
||||||
|
tmp = &bytes.Buffer{}
|
||||||
|
binary.Write(tmp, binary.LittleEndian, bool2int8(enable))
|
||||||
|
cmd.Write(tmp.Bytes())
|
||||||
|
|
||||||
|
_, err := b.write(b.networkFrameGenerator(cmd, ARNETWORKAL_FRAME_TYPE_DATA, BD_NET_CD_NONACK_ID).Bytes())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *Bebop) VideoStreamMode(mode int8) error {
|
||||||
|
cmd := &bytes.Buffer{}
|
||||||
|
|
||||||
|
cmd.WriteByte(ARCOMMANDS_ID_PROJECT_ARDRONE3)
|
||||||
|
cmd.WriteByte(ARCOMMANDS_ID_ARDRONE3_CLASS_MEDIASTREAMING)
|
||||||
|
|
||||||
|
tmp := &bytes.Buffer{}
|
||||||
|
binary.Write(tmp,
|
||||||
|
binary.LittleEndian,
|
||||||
|
uint16(ARCOMMANDS_ID_ARDRONE3_MEDIASTREAMING_CMD_VIDEOSTREAMMODE),
|
||||||
|
)
|
||||||
|
|
||||||
|
cmd.Write(tmp.Bytes())
|
||||||
|
|
||||||
|
tmp = &bytes.Buffer{}
|
||||||
|
binary.Write(tmp, binary.LittleEndian, mode)
|
||||||
|
cmd.Write(tmp.Bytes())
|
||||||
|
|
||||||
|
_, err := b.write(b.networkFrameGenerator(cmd, ARNETWORKAL_FRAME_TYPE_DATA, BD_NET_CD_NONACK_ID).Bytes())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func bool2int8(b bool) int8 {
|
func bool2int8(b bool) int8 {
|
||||||
if b {
|
if b {
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -174,4 +174,7 @@ const (
|
||||||
ARCOMMANDS_ID_ARDRONE3_SPEEDSETTINGS_CMD_MAXROTATIONSPEED byte = 1
|
ARCOMMANDS_ID_ARDRONE3_SPEEDSETTINGS_CMD_MAXROTATIONSPEED byte = 1
|
||||||
ARCOMMANDS_ID_ARDRONE3_SPEEDSETTINGS_CMD_HULLPROTECTION byte = 2
|
ARCOMMANDS_ID_ARDRONE3_SPEEDSETTINGS_CMD_HULLPROTECTION byte = 2
|
||||||
ARCOMMANDS_ID_ARDRONE3_SPEEDSETTINGS_CMD_OUTDOOR byte = 3
|
ARCOMMANDS_ID_ARDRONE3_SPEEDSETTINGS_CMD_OUTDOOR byte = 3
|
||||||
|
|
||||||
|
ARCOMMANDS_ID_ARDRONE3_MEDIASTREAMING_CMD_VIDEOENABLE byte = 0
|
||||||
|
ARCOMMANDS_ID_ARDRONE3_MEDIASTREAMING_CMD_VIDEOSTREAMMODE byte = 1
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
This example will connect to the Bebop and stream it's video to a webpage
|
This example will connect to the Bebop and stream its video to a webpage
|
||||||
via ffserver. This requires you to have both ffmpeg and ffserver installed
|
via ffserver. This requires you to have both ffmpeg and ffserver installed
|
||||||
on your computer.
|
on your computer.
|
||||||
|
|
||||||
|
@ -32,6 +32,16 @@ func main() {
|
||||||
return
|
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")
|
ffmpeg := exec.Command("ffmpeg", "-i", "pipe:0", "http://localhost:8090/bebop.ffm")
|
||||||
|
|
||||||
ffmpegErr, err := ffmpeg.StderrPipe()
|
ffmpegErr, err := ffmpeg.StderrPipe()
|
||||||
|
|
|
@ -19,3 +19,5 @@ func (t testDrone) StartRecording() error { return nil }
|
||||||
func (t testDrone) StopRecording() error { return nil }
|
func (t testDrone) StopRecording() error { return nil }
|
||||||
func (t testDrone) HullProtection(protect bool) error { return nil }
|
func (t testDrone) HullProtection(protect bool) error { return nil }
|
||||||
func (t testDrone) Outdoor(outdoor bool) error { return nil }
|
func (t testDrone) Outdoor(outdoor bool) error { return nil }
|
||||||
|
func (t testDrone) VideoEnable(enable bool) error { return nil }
|
||||||
|
func (t testDrone) VideoStreamMode(mode int8) error { return nil }
|
||||||
|
|
Loading…
Reference in New Issue