├── Position.png ├── Velocity.png ├── Acceleration.png ├── Control_scheme.png ├── Robot_Control_tutorial.pdf ├── maxfig.m ├── mydialog.m ├── Kalman_Filter.m ├── README.md └── main.m /Position.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SaysWis/Robot_Control/HEAD/Position.png -------------------------------------------------------------------------------- /Velocity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SaysWis/Robot_Control/HEAD/Velocity.png -------------------------------------------------------------------------------- /Acceleration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SaysWis/Robot_Control/HEAD/Acceleration.png -------------------------------------------------------------------------------- /Control_scheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SaysWis/Robot_Control/HEAD/Control_scheme.png -------------------------------------------------------------------------------- /Robot_Control_tutorial.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SaysWis/Robot_Control/HEAD/Robot_Control_tutorial.pdf -------------------------------------------------------------------------------- /maxfig.m: -------------------------------------------------------------------------------- 1 | figure 2 | % find screen size 3 | screensize = get( 0, 'ScreenSize' ); 4 | % set figure to screen size 5 | set(gcf,'Position',screensize) 6 | -------------------------------------------------------------------------------- /mydialog.m: -------------------------------------------------------------------------------- 1 | function[Kp,Ki]= mydialog 2 | prompt = {'Proportional Gain (Kp):','Integral Gain (Ki):'}; 3 | dlgtitle = 'PID Controller Gains'; 4 | dims = [1 50; 1 50]; 5 | definput = {'0.8','0.001'}; 6 | answer = inputdlg(prompt,dlgtitle,dims,definput); 7 | values = str2double(answer); 8 | 9 | %% 10 | Kp = values(1); 11 | Ki = values(2); 12 | end -------------------------------------------------------------------------------- /Kalman_Filter.m: -------------------------------------------------------------------------------- 1 | function [x_up, P_up] = Kalman_Filter(x_k_1, P_k_1, y, F, H, Q, R) 2 | 3 | x_k = F*x_k_1; 4 | P_k = F*P_k_1*F'+Q; % Project the State Covariance Ahead 5 | 6 | Kk = P_k*H'*inv(H*P_k*H'+R); % Kalman Gain 7 | x_up = x_k+Kk*(y-H*x_k); % Update Measurement with measurement 8 | P_up = P_k-Kk*H*P_k; % Update the Error Covariance 9 | 10 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Robot Control using PID Controller and Kalman Filter 2 | The objective is to estimate the Velocity using a Linear Kalman Filter and to control a robot using a PID Controller. 3 | 4 | Consider a robot on frictionless, straight lane. Initially, the robot is stationary at position 0. We measure the position of the robot every $\Delta t$ seconds, but these measurements are imprecise; we want to maintain a model of the robot's position and velocity. 5 | 6 | We show here how we derive the model from which we create our Kalman filter. 7 | Since $F$, $H$ , $R$ and $Q$ are constant, their time indices are dropped. 8 | 9 | The position and velocity of the robot are described by the linear state space 10 | $x_k$ = [ $x$ , $v$ ] % $x$ : position 11 | ; $v$ : velocity 12 | 13 | We assume that a(k) is unknown and normally distributed with mean 0 and standard deviation $\sigma_a$. From Newton's laws of motion we conclude that 14 | $$x(k) = F x(k-1) + G a(k)$$ 15 | 16 | We suppose there is no control inputs $G a(k)$ term, where 17 | $$F = [1 \quad Δt;0 \quad 1]$$ 18 | $$G = [Δt^2/2;Δt]$$ 19 | 20 | 21 | Then, a PID controller is used to generates the acceleration ( $a$ ) to control the robot's velocity ( $v$ ) using the estimated one ( $\tilde{v}$ ). 22 | 23 |
24 |
25 |