Skip to content

Commit

Permalink
tello: improve video encoding rate API call
Browse files Browse the repository at this point in the history
Signed-off-by: Ron Evans <[email protected]>
  • Loading branch information
deadprogram committed Apr 19, 2018
1 parent dda57b1 commit 9875acb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion examples/tello_opencv.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func main() {
fmt.Println("Connected")
drone.StartVideo()
drone.SetExposure(1)
drone.SetVideoEncoderRate(3)
drone.SetVideoEncoderRate(4)

gobot.Every(250*time.Millisecond, func() {
drone.StartVideo()
})
Expand Down
2 changes: 1 addition & 1 deletion examples/tello_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
drone.On(tello.ConnectedEvent, func(data interface{}) {
fmt.Println("Connected")
drone.StartVideo()
drone.SetExposure(0)
drone.SetVideoEncoderRate(4)
gobot.Every(250*time.Millisecond, func() {
drone.StartVideo()
})
Expand Down
18 changes: 15 additions & 3 deletions platforms/dji/tello/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ func (d *Driver) Start() error {

// send stick commands
go func() {
time.Sleep(100 * time.Millisecond)
time.Sleep(50 * time.Millisecond)
for {
err := d.SendStickCommand()
if err != nil {
fmt.Println("stick command error:", err)
}
time.Sleep(50 * time.Millisecond)
time.Sleep(20 * time.Millisecond)
}
}()

Expand Down Expand Up @@ -335,7 +335,19 @@ func (d *Driver) SetExposure(level int) (err error) {

// SetVideoEncoderRate sets the drone video encoder rate.
func (d *Driver) SetVideoEncoderRate(rate int) (err error) {
pkt := []byte{messageStart, 0x60, 0x00, 0x27, 0x68, videoEncoderRateCommand, 0x00, 0xe6, 0x01, byte(rate), 0x00, 0x00}
pkt := []byte{messageStart, 0x62, 0x00, 0x27, 0x68, videoEncoderRateCommand, 0x00, 0xe6, 0x01, byte(rate), 0x00, 0x00, 0x00}

// sets ending crc bytes for packet
l := len(pkt)
pkt[(l - 2)], pkt[(l - 1)] = CalculateCRC(pkt)

_, err = d.reqConn.Write(pkt)
return
}

// Rate does some still unknown thing.
func (d *Driver) Rate() (err error) {
pkt := []byte{messageStart, 0x58, 0x00, 0x7c, 0x48, 40, 0x00, 0xe6, 0x01, 0x6c, 0x95}

// sets ending crc bytes for packet
l := len(pkt)
Expand Down

0 comments on commit 9875acb

Please sign in to comment.