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

Move drone while recording video? (python programming)

hybotenuse

New member
Joined
May 20, 2022
Messages
3
Reaction score
0
Hey everyone, just got a tello and dived straight into programming but have an issue right now.

I've imported and am using the djitellopy package, and am trying to be able to control the drone to move forward while also recording video.

The issue is I'm trying to have the drone move in a specified pattern (travel along the perimeter of a square), and the easiest way I've thought of to do this is with the move_right() and rotate_counter_clockwise() functions, for example, move_right(50), then rotate_counter_clockwise(90), then repeat until the drone makes a full square.

This works, but the issue is that to record video, I would need a while loop of getting the frames, which would be incompatible with the movement of the drone (code wont run past move_right() until it is done executing).

I've tried using multiprocessing and running the two in conjunction, but tello errors, which I assume is a result of it not being able to hand capturing frames while it is executing move_right().

Any thoughts/advice?
Thank you!
 

Hacky

Well-known member
Joined
Jul 19, 2021
Messages
228
Reaction score
101
Location
Germany
You do not need multiprocessing - multithreading is sufficient. You should start the function to read and display frames in a seperate thread.
 

hybotenuse

New member
Joined
May 20, 2022
Messages
3
Reaction score
0
You do not need multiprocessing - multithreading is sufficient. You should start the function to read and display frames in a seperate thread.
This seems to work and allow the move function and read/display frames function to run concurrently, but now no window is showing up despite terminal output suggesting that the camera is recording.

From some searching online there seems to be issues with cv2 and multithreading, have you encountered this before?
 

hybotenuse

New member
Joined
May 20, 2022
Messages
3
Reaction score
0
I think I was able to figure it out, the trick is to create a thread for the drone's movement function with daemon=True, start that thread, and then use the main thread for the frames.
 

Hacky

Well-known member
Joined
Jul 19, 2021
Messages
228
Reaction score
101
Location
Germany
Usually the display functions and UI event handling should be in the main loop. The reading and processing of frames can be in a separate thread.
 

New Threads

Members online

No members online now.

Forum statistics

Threads
5,422
Messages
38,729
Members
15,302
Latest member
kenb7976