Skip to content

Commit

Permalink
Add bebop video recording command
Browse files Browse the repository at this point in the history
  • Loading branch information
zankich committed Jul 23, 2015
1 parent 00c0e49 commit 9afb744
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions platforms/bebop/bebop_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type drone interface {
Stop() error
Connect() error
Video() chan []byte
StartRecording() error
StopRecording() error
}

// BebopAdaptor is gobot.Adaptor representation for the Bebop
Expand Down
10 changes: 10 additions & 0 deletions platforms/bebop/bebop_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,13 @@ func (a *BebopDriver) Stop() {
func (a *BebopDriver) Video() chan []byte {
return a.adaptor().drone.Video()
}

// StartRecording starts the recording video to the drones interal storage
func (a *BebopDriver) StartRecording() error {
return a.adaptor().drone.StartRecording()
}

// StopRecording stops a previously started recording
func (a *BebopDriver) StopRecording() error {
return a.adaptor().drone.StopRecording()
}
42 changes: 42 additions & 0 deletions platforms/bebop/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,48 @@ func (b *Bebop) packetReceiver(buf []byte) {
}
}

func (b *Bebop) StartRecording() error {
buf := b.videoRecord(ARCOMMANDS_ARDRONE3_MEDIARECORD_VIDEO_RECORD_START)

b.write(b.networkFrameGenerator(buf, ARNETWORKAL_FRAME_TYPE_DATA, BD_NET_CD_NONACK_ID).Bytes())
return nil
}

func (b *Bebop) StopRecording() error {
buf := b.videoRecord(ARCOMMANDS_ARDRONE3_MEDIARECORD_VIDEO_RECORD_STOP)

b.write(b.networkFrameGenerator(buf, ARNETWORKAL_FRAME_TYPE_DATA, BD_NET_CD_NONACK_ID).Bytes())
return nil
}

func (b *Bebop) videoRecord(state byte) *bytes.Buffer {
//
// ARCOMMANDS_Generator_GenerateARDrone3MediaRecordVideo
//

cmd := &bytes.Buffer{}

cmd.WriteByte(ARCOMMANDS_ID_PROJECT_ARDRONE3)
cmd.WriteByte(ARCOMMANDS_ID_ARDRONE3_CLASS_MEDIARECORD)

tmp := &bytes.Buffer{}
binary.Write(tmp,
binary.LittleEndian,
uint16(ARCOMMANDS_ID_ARDRONE3_MEDIARECORD_CMD_VIDEO),
)

cmd.Write(tmp.Bytes())

tmp = &bytes.Buffer{}
binary.Write(tmp, binary.LittleEndian, uint32(state))

cmd.Write(tmp.Bytes())

cmd.WriteByte(0)

return cmd
}

func (b *Bebop) Video() chan []byte {
return b.video
}
Expand Down

0 comments on commit 9afb744

Please sign in to comment.