Gyropode + ESP32-S3 + L298N et MPU6050

Bonjour à tous,

Mon gyropode est fini depuis des semaines, étant novice je me suis fait aider par l’I.A. et je dois avouer que cela c’est dans l’ensemble assez bien passé. Seulement voilà, je suis dans la phase réglage pour arriver à le faire tenir son équilibre, et là je galère car faire cela avec l’I.A. c’est juste pas possible, car lui-même tourne en rond…et je suis dans ma troisième semaine à augmenter le Kd et le Kp, puis à le diminuer et à l’augmenter à nouveau, et de retoucher l’offset, puis le retoucher dans l’autre sens en négatif, puis changer les paramètres moteurs pour leurs donner plus de patates pour qu’ils arrivent à redresser le robot, puis…puis…puis… et ça fait 3 semaines maintenant.
Donc je post ce sujet, car si quelqu’un d’entre vous à déjà su régler ce genre d’animal, je voudrais bien qu’il m’aide par méthodologie et ne pas partir dans tous les sens comme le fait l’I.A.
Merci à tous.
P.S. je peux envoyer mon code complet à la demande

Sorry we don’t have a solution or a methodology to offer for your balancing robot at this time. Hope another community member with experience in this specific area can chime in and help you out.

Best of luck with your project!

There’s not too much information here as to your actual control structure, but many years ago, I majored in control systems, so i may be able to give some generic advice..

From a control systems perspective, trying to tune one PID loop for the whole system rarely works for a self-balancing robot. You need to first split the problem into separate layers. Maybe you already did? I’m not sure from the description.

Assuming not, then first, tune the angle (balance) loop on its own as a fast inner loop (P first then add PD). The robot should be able to stand upright in place before anything else is added.

Then add a slower outer position loop, which adjusts the tilt target slightly to control drift.

Finally, add yaw control if the robot slowly rotates.

Also, make sure the angle measurement is stable—often a simple sensor fusion method (like a complementary filter) is needed before PID tuning will behave properly.

A lot of problems at this stage can come from sensor errors e.g imu such as noise, scaling, motor imbalance, or timing issues rather than the PID values themselves. These may need calibrating and filtering too before use.

To be honest, you’ll likely find more step-by-step examples in dedicated robotics or control-focused forums rather than here, with all respect to Sunfounder,! where people have documented full working implementations and sample code. I know that I’ve seen such examples in the past, but unfortunately I cant remember exactly where.

As I said, the above is very generic and I’ve made a lot of assumptions about your existing structure, so please ignore if I’ve missed the point!

Addendum. I just noticed you were using an mpu6050 imu, they’re not ideal for this type of application, they’re not accurate nor stable enough. You’ll definitely need to add at least a complementary filter IMHO prior to pid use. Or to simplify, a better imu.