Memuat
Memuat
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Quadrotor Control Sliding Mode Control Class #2: Flight Simulation and PID Control for Altitude & Attitude”.
Other ways we can help with Python.
Learn with a mentor
Scheduled Simulation & Engineering courses with live guidance and a certificate.

Course/Training Ansys ~ Heat Transfer and Heat Flux Analysis
★ 5.0 (10)

Course/Training MATLAB — MATLAB App Design: The Ultimate Guide to MATLAB Apps
★ 5.0 (10)

Course/Training Ansys — Airflow Simulation of a Car Radiator with ANSYS
★ 5.0 (9)
Have it built for you
No time to learn Python? Our team can do the project for you.

Matlab Development Service — Complete Neural Signal Processing and Analysis Zero to Hero
★ 5.0 (59)

Ansys Maxwell Development Service
★ 5.0 (50)

Petrel Development Service
★ 5.0 (14)
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
Here is the final result, the quadrotor takes off from the ground to a height of 2 meters, then flies to a new point, controlled by PI in a multi-level setup that we wrote ourselves. We also see its shortcomings, overshoot and large tilt angles. Let's start. Hello, welcome to episode two of the quadrotor control series with sliding mode control. The quadrotor only has four inputs, total thrust and three moments, although its position is three-dimensional. Therefore, the control is made in layers, the outer loop controls the position by determining the tilt angle, and the inner loop controls that angle. Today we are building it with PID.
Create a control.py file. The reference angle function converts the desired horizontal acceleration into roll and pitch angles, using a small angle approach. To move forward, the drone must pitch proportionally to its acceleration divided by gravity. The PI control class has six channels, three for position and three for angles, each with proportional, integral, and derivative gains.
In each step, the position loop calculates the reference acceleration from the position error and velocity, then converts it into reference roll and pitch. Total thrust is calculated so that the vertical component keeps holding the weight even when the drone is tilted, so it is divided by the cosine of roll and pitch. The attitude loop generates moments to achieve the reference angle. The simulation function runs any control on the quadrotor model with adjustable references and wind.
Create a fly underscore PID.py file. The quadrotor starts on the ground, rises to 2 meters, then at the fifth second moves to the point 2, 1, 2. Run The time to reach 90% of the height is about 1.2 seconds, but with an overshoot of 13.6%. When moving, the roll and pitch angles temporarily reach 37 degrees, and the final position is still off by about 10 cm.
Let's look at the graphs. The X, Y, and Z positions reach their targets with slight oscillations. The attitude graph shows the drone must tilt sharply to accelerate and then tilt in the opposite direction to brake. Thrust spikes up to 31 N during takeoff. PID is sufficient for basic flight, but it is not robust against disturbances like wind, and that is what sliding mode control will improve. Done
We have already built a PI controller for the quadrotor, position loop, attitude reference angle, compensated thrust, and attitude loop, then flew it. In the next episode, we will study the theory of sliding mode control. Currently working on a thesis, dissertation, or research in the field of control systems, drones, and UAVs. Cerdas Inovasi Digital helps implement control systems, from 6 degrees of freedom quadrotor modeling, hierarchical PI, sliding mode control, up to disturbance observer for wind, and also opens Python programming courses for electrical and mechatronics engineering. Want to master the entire series, from quadrotor models to 3D path testing with wind? All 6 episodes, complete with PDF step-by-step guides and source code, are available for premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or one-time payment of Rp999.000 for lifetime access. Want just one class? Buy a single class with lifetime access. Subscribe now at the premium page cerdasinovasidigital.com Contact us via WhatsApp, or visit cerdasinovasidigital.com Thank you for watching, see you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →