Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does matlab realize PID to control the car to advance to the designated position?

Shulou Source: shulou.com Published: 2022-06-01 03:20:53 09月10日 Update

This article mainly introduces "matlab how to achieve PID to control the car to the designated position". In the daily operation, I believe that many people have doubts about how to achieve matlab to control the car to the designated position. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for everyone to answer the question of "how to achieve PID to control the car to advance to the designated position". Next, please follow the editor to study!

There are three steps:

Determine the forward direction of the car according to the target position

Calculate the difference between the target direction and the current direction

Select appropriate PID parameters to drive the left and right wheels

First open this file.

In

Realize PID to control the car to move forward to the designated position.

START CODE BLOCK

1. Calculate the heading (angle) to the goal.

% distance between goal and robot in x-direction

Uplix = x_g-x

% distance between goal and robot in y-direction

Upliy = y_g-y

% angle from robot to goal. Hint: use ATAN2, u_x, u_y here.

Theta_g = atan2 (upright _

2. Calculate the heading error.

% error between the goal angle and robot's angle

% Hint: Use ATAN2 to make sure this stays in [- pi,pi].

EReck = atan2 (sin (theta_g-theta), cos (theta_g-theta))

3. Calculate PID for the steering angle

% error for the proportional term

Ethereal P = estrangk

% error for the integral term. Hint: Approximate the integral using

% the accumulated error, obj.E_k, and the error for

% this time step, eQuik.

EBay I = obj.E_k + e_k*dt

% error for the derivative term. Hint: Approximate the derivative

% using the previous error, obj.e_k_1, and the

% error for this time step, eQuik.

EBay D = (e_k-obj.e_k_1) / dt

END CODE BLOCK

Last run

At this point, the study on "how to achieve matlab PID to control the car to the designated position" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Location car control learning direction more goal help practical appropriate next parameters differences files articles methods theory knowledge articles websites Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker Shulou Tech Info MariaDB Apple