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

I am new to the Tello Programming, just created a face detection & tracking program

YOLO

Member
Joined
Sep 19, 2023
Messages
19
Reaction score
2
Location
United Kingdom
Hello all,

I have owned Tello for years... but recently fell in love with the SDK and Python, and started to create some projects. Recently, I have just made the Tello do face detection and tracking. Would like to share it with all of you, please check it out from

my website - Drone Programming – Face Detection and Tracking | Molex's Workshop or
Facebook page - Log into Facebook.

Hope I can share what I learned and improve my skills with your valuable input.

Thanks,
YOLO
 
  • Like
Reactions: GFields
Thanks for sharing.
Next step would be, implementing a PID control loop for smoother operation ;-)
 
Thank you for very much for your feedback... but I got failed when I was studying feedback control in my college.. :p

Just finished the gesture control and trying swarm... then, I got my EDU expansion kits to TT.. Once, I learned and touched all these basic, I will try to make thing better. Can't avoid from PID.. lol
 
Hi Hacky,

I spent a whole day reading and studying the PID. But, I just wonder why and how I implement PID. Is that good enough if we just vary the drone speed based on the distance away from the center? really need PID? It looks to me like it's a kind of feedback control.

Thanks,
YOLO
 
At least, that's how I implemented the applications you find in my signature. Only this way you get smooth continous motions.
 
Thanks for your information... but I still have no clue how to properly implement PID into my program. But, I changed the speed from constant value to variable to the distance to the center, and it looks much better, can target the exact center instead of a +/- 50 box. I really want to see how this compares with PID.

From

if x > 530:
rV = +30
elif x < 430:
rV = -30
else:
rV = 0

if y > 410:
vV = -20
elif y < 310:
vV = 20
else:
vV = 0
.
.
.
tello.send_rc_control(hV, dV, vV, rV)

To

if x > 480:
rV = int((x - 480)/4.8)
elif x < 480:
rV = -int((480 - x)/4.8)
else:
rV = 0

if y > 360:
vV = -int((y - 360)/3.6)
elif y < 360:
vV = int((360 - y)/3.6)
else:
vV = 0
.
.
.
tello.send_rc_control(hV, dV, vV, rV)
 
Last edited:
Your current implementation is a plain step-proportional one. That is a simplification of the "P" component in a PID and lacks the I and D components.

Why you want a full PID:

Your approach is fine if Tello moves slowly. As you try to increase your P-Factor to improve performance you will realize issues with this approach: Tello will overreact, it will turn too far, it will move sideways too quick, it will come after you and probably hit you. It may start to oszillate in one direction or another. The "D" component solves that

Also if you continously move you will realize that with a P or PD control Tello is never able to keep you centered in the frame. Instead you are always a bit off-center. The "I" component solves that


Depending on the PID implementation you feed the PID controller with the current value whenever a new frame has been analyzed. You get some output that you use for controlling the drone. Alternatively you can feed the PID in the loop used to control the drone.

There are many simple and a few smarter PID implementations available on the net. Just pick one for the language you use and tweak it as you go
 
Hi volate!lo,

Thank you very much for your detailed reply, I need time to digest and study this. Let me come back to you guys if I can achieve this... or further roadblocks.

Great to join TelloPilots, big thanks to you and Hacky.

Regards,
YOLO
 
As you are using Python, take a look at simple-pid library.
You will need seperate PID controllers for each axis. After tuning, you will end up with quite different PID parameters for horizontal and vertical movements because the physics behind these movements are also quite different. You find PID tuning guides all over the web. As a starting point, you can set 0.25 for P.

Later you will see that the system you would like control here, is not behaving "linear" and PID control loops do not work well with non-linear systems. There are several approaches to handle this - e.g. by applying some kind of transformation to the input values before sending them to the PID controller. But that is advanced stuff, you can care for, after you saw the limits of PID.
 
As you are using Python, take a look at simple-pid library.
You will need seperate PID controllers for each axis. After tuning, you will end up with quite different PID parameters for horizontal and vertical movements because the physics behind these movements are also quite different. You find PID tuning guides all over the web. As a starting point, you can set 0.25 for P.

Later you will see that the system you would like control here, is not behaving "linear" and PID control loops do not work well with non-linear systems. There are several approaches to handle this - e.g. by applying some kind of transformation to the input values before sending them to the PID controller. But that is advanced stuff, you can care for, after you saw the limits of PID.
Hi Hacky and volate!lo,

Thank you very much for your time and valuable input. It gave me a heads-up that my original code was a simple P controller... I keep sticking to how to add PID to my if/then loop. Finally, I found that just replace the whole code with the PID like below,

FROM
if y > 360:
vV = -int((y - 360)/3.6)
elif y < 360:
vV = int((360 - y)/3.6)
else:
vV = 0

TO
vKp, vKi, vKd = 1/3.6, 1/36, 1/3.6
vIntegal = vP_Error = 0
current_time = previous_time = time.time()
.
.
vError = 360 - y
vIntegal += vError * delta_t
vDerivative = (vError - vP_Error) / delta_t if delta_t > 0 else 0
vOutput = vKp * vError + vKi * vIntegal + vKd * vDerivative
vP_Error = vError
vV = int(np.clip(vOutput, -100, 100))
.
.
previous_time = time.time()
tello.send_rc_control(hV, dV, vV, rV)

Yes, next step I need to fine-tune the PID for the best result, understanding this before I can go further. Thank again!

Best regards,
YOLO
 
  • Like
Reactions: volate!lo
If I control the height only, the result is acceptable.. but when I put it together with rotation (yaw), it affects each other..
V only.png
 
You need seperate PID controllers with different PIDs for yaw and x, y, z velocity.
 
Yes, I know. I just tried each movement one by one to see the result. It will be affecting each other when moving the same time.
 
Roll, pitch and throttle affect each other. Yaw also but to a lesser extend

No worries you can achieve acceptable results with a P-only controller. Even a fully tuned PID only required if you want stellar performance, which IMO isn't necessary in a lab environment.
 
Um... fine tuning a full PID is not easy.. I need to further understand the whole equation and relationship, try to develp some tools to help. But, yes, I found P-only controller is working fine.

May I check with you how do you fine tune the PID? purely try and error?
 
Pure Try and Error.
I can adapt the PID while in flight from the normal GUI so its fairly easy

But i also take other parameters like distance or device Performance into account.
 
Got it, thanks... it will be interesting if I can create a tool and change Kp, Ki & Kd in real-time and capture necessary data to review... but, I want to try the swarm control first. XD
 

New Posts

Members online

No members online now.

Forum statistics

Threads
5,701
Messages
39,968
Members
17,067
Latest member
atapattu

New Posts