Hello Tello Pilot!
Join our DJI Tello community & remove this banner.
Sign up

Gobot Question

SMerrony

Well-known member
Joined
May 1, 2018
Messages
64
Likes
59
Location
France
#1
I've got each of the example Gobot programs from the recent article running, so now I want to combine two of them so I can have vision and control simultaneously.

I couldn't find an example, so I tried the following approach - which seg faults...

Code:
package main

import (
    "fmt"
    "os/exec"
    "time"

    "gobot.io/x/gobot"
    "gobot.io/x/gobot/platforms/dji/tello"
)

func main() {
    droneCam := tello.NewDriver("8890")
    droneCmd := tello.NewDriver("8888")

    work := func() {
        mplayer := exec.Command("mplayer", "-vo", "x11", "-fps", "30", "-")
        mplayerIn, _ := mplayer.StdinPipe()
        if err := mplayer.Start(); err != nil {
            fmt.Println(err)
            return
        }
        droneCam.On(tello.ConnectedEvent, func(data interface{}) {
            fmt.Println("Connected")
            droneCam.StartVideo()
            droneCam.SetVideoEncoderRate(2)
            gobot.Every(2000*time.Millisecond, func() {
                droneCam.StartVideo()
            })
        })

        droneCam.On(tello.VideoFrameEvent, func(data interface{}) {
            pkt := data.([]byte)
            if _, err := mplayerIn.Write(pkt); err != nil {
                fmt.Println(err)
            }
        })

        // droneCmd.TakeOff()

        // gobot.After(5*time.Second, func() {
        //     droneCmd.Land()
        // })
    }

    robot := gobot.NewRobot("tello",
        []gobot.Connection{},
        []gobot.Device{droneCam, droneCmd},
        work,
    )

    robot.Start()
}
Can anyone point me in the right direction?
 

redruff

Active member
Joined
Apr 26, 2018
Messages
37
Likes
13
#4
I'm kind of new at GO but what actually happened when you ran that code? Did it throw an error?
And what I'm really getting at is....can you control two drones with one program by calling two drivers???
 

SMerrony

Well-known member
Joined
May 1, 2018
Messages
64
Likes
59
Location
France
#5
I'm kind of new at GO but what actually happened when you ran that code? Did it throw an error?
And what I'm really getting at is....can you control two drones with one program by calling two drivers???
My code worked as soon as I used a single driver as suggested by javaguy, I got a video stream and control of the drone simultaneously.

I think you need to look at the "swarm" concept in Gobot to control two or more drones - can't help there as I'm monodromous at the moment.:D
 
Likes: Inakigarm
Joined
Jul 26, 2018
Messages
10
Likes
0
#6
PLEASE HELP.

I am using a UBUNTU 16 virtual machine. I have Gobot installed and I can run the sample scripts. I connect the Wifi network of my PC to TELLO, but I get nothing from the drone. I attach a screenshot.

Help much appreciated. The problem can be becasuse I am using a virtual machine and does not access Wifi directly?
 

Attachments

Last edited:
Joined
Jul 26, 2018
Messages
10
Likes
0
#7
I have done some research, and I think that the problem is that my laptop is not connecting TELLO´s Wifi propperly. I see a symbol over the connection. Can someone help?
 

Attachments

Joined
Jul 26, 2018
Messages
10
Likes
0
#8
Hi again,

I can run the GO code and TELLO starts to work, but like after 2 seconds, it disconnects every time. Any idea on how to avoid getting dissconnected?
 

Attachments

New Threads

Forum statistics

Threads
2,181
Messages
15,649
Members
5,248
Latest member
Beard Beardington