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 “Class Reinforcement Learning Robot Manipulator #3: PID Control & Computed Torque as a Comparison”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
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, two classical controllers tracking a circular path. PI is off by about 17 mm, whereas Computed Torque using the dynamic model only 9 per 100 mm. But what happens if the model is wrong? Let's get started. Hello, welcome to episode three of the reinforcement learning series on robot manipulator control. Before training the reinforcement learning agent, we need a fair comparison. Today we are making two classical controllers, PI that knows nothing about the robot, and Computed Torque that uses the dynamic model from the previous episode.
Create file control.py The PI class calculates torque for each joint from angular error, integral error, and angular velocity error. The Computed Torque class is much smarter, its torque is M multiplied by reference acceleration plus PD correction, plus C and G. With an accurate model, the entire nonlinear dynamics of the robot is canceled out, leaving a simple linear system. Notice the payload model parameters. This controller assumes the arm is weightless.
The simulation function runs any controller along a circular path for 8 seconds. Every 1 per 100 seconds, the controller calculates torque limited to 40 Nm, then the robot is simulated for 5 substeps. We can add a payload at the end of the arm and external torque disturbance starting from the fourth second. Error is calculated as the distance from the end-effector to the reference point in millimeters.
Create file test_classic.py and run it without payload and without disturbance. PI has an RMS error of 17.48 mm with a maximum error of almost 48 mm, and its torque occasionally reaches the 40 Nm limit. Computed Torque performs perfectly, RMS error of 0.09 mm with a maximum torque of only 16.6 Nm. An accurate model makes the controller much more accurate and energy-efficient.
Let's look at the graphs. The PI path deviates from the reference circle, whereas Computed Torque sticks closely to it. The logarithmic error graph shows a difference over 100 times greater. But Computed Torque relies entirely on the model. In the final episode, we will see what happens when the arm carries an unknown load.
Done. We have already created the PID controller and Computed Torque, the simulation function for tracking with load and disturbance, and compared both. In the next episode, we build a reinforcement learning environment using gymnasium. Currently working on a thesis, dissertation, or research in the field of robotics and reinforcement learning? Cerdas Inovasi Digital helps implement robot control, from manipulator kinematics and dynamics, PID and Computed Torque, gymnasium environment, up to soft actor critic agent training, as well as opening a Python programming course for electrical engineering and mechatronics. Want to master the entire series, from robotic arm kinematics to adaptive agent reinforcement learning testing? All 6 episodes, complete with step-by-step PDF guides and source code, Available for premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or pay once Rp999.000 for lifetime access. 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 →