Implementation of Kalman Filter on Visual Tracking Using PID Controller

This paper explain the design of visual control system which equip Kalman filter as an additional subsystem to predict object movement. It is a method to overcome some weakness, such as low range view of camera and low FPS (Frame per Second). It also assists the system to track a fast moving object. The system is implemented to 2 motor servos, which are move on horizontal and vertical axis. Digital PID (Proportional, Integral, and Derivative) controller is used in the system, and bi-linear transformation is used to approximate the value of derivative in transforming the analogue to digital controller on ztransform.In conclusion, we can get the value of system responses time from both motor servos. The rise time and settling time of motor servo in horizontal axis are 0.402s and 1.63s, and vertical axis’s responses are 0.38s and 1.34s.


INTRODUCTION
In this digital era, robotic technologies are implementing vision-based control, such as object tracking [1], face tracking [2], and position-based control [3]. It was developed as one of the control method in robotic community. Researchers keep learning and involving the control system to transform itas close as human capability. Recent paper describes the vision-based control and computer vision as numerical theory [4], unfortunately there are lack of paper which describedand design the system in a more practical way.
There are many add-on systems in vision-based control to improve accuracy, such as image filter and predictive filter. To implement such systems, which will be used onvarious environment with lots of noises, the method should therefore always be develop to reduce noises. So, there are many researchers in this field to improve the system's capability.
Gian Luca designedimage-based visual servo using geometry [5] in mobile robot and combined it with kinematic design.This paper will explain about a visual tracking system controlled by visual control using PID (Proportional, integral, and derivative) control law to move plants in horizontal and vertical axis. It also combined with Kalman filter to predict the object movement within camera frame.
The purpose of the system is to predict the object movement, so it can make the system work in a better performance to predict the object movement while it is not detected. The system will not search the object while it was outside the range of vision of the system without using kalman filter. The control law (PID), filter, and feature extraction will be designed in one processor.
We will use 2-D in feature extraction, there are two axis which are being the feature for control system. The feature extraction method is contour in color detection, however it will not be discussed in this paper. This paper will concern to the design in development of visual control in robotics using the predictive filter. This paper proposedon how to implement and design the system in a more practicalway.According to the passages above, we canconclude that the advantages of the proposed system are: − The digital PID algorithm will be designed using z-transform which make it easier to understand and implement.
− Kalman filter will be used to predict object movement, so it will help the system's responsewhen tracking faster object. Kalman filter is useful on system arrangement using low resolution and low FPS camera. It will be useful if the camera frame which used in the system doesn't have enough resolution and bad fps (frame per second) [6].
This paper is organized in 5 sections. Section 2 and 3 explain about the digital control system design and Kalman filter theory. Section 4 will discussed about the design from the control system perspective and the next section contains results and data analysis comparingdata between system with Kalman filter and nowithout Kalman filter. Finally, the last section is about the conclusion of all the system.

DIGITAL CONTROL SYSTEM DESIGN
In this section, we will review the digital control system. Z-transform can be used to design the digital control system. To transform the analogue to digital system, the system must following these requirements [7]: − A stable analogue system must transform to a stable digital system. − The frequency response of the digital system must closely resemble the frequency response of the analogue system in the frequency range 0 2 ⁄ where is the sampling frequency.
There are many methods to transform the analogue to digital system, consist of:

Differencing Method
The system can be represented by a transfer function or differential equation. Numerical analysis provides standard approximations of the derivative so as to obtain the solution to a differential equation. There are 2 types of the differencing method [7], such as: In forward differencing the derivative approach will found through the basic equation 2.1: Electronic copy available at: https://ssrn.com/abstract=3662088

DISCRETE KALMAN FILTER
Kalman filter is essentially a set of mathematical equations that implement a predictor-corrector type estimator that is optimal in the sense that it minimizes the estimated error covariance. There are 2 general processes to implemented, such as time update and measurement update. The time update equations can be thought of as predictor equation, while the measurement update equations can be thought of as corrector equation. Indeed the final estimation algorithm resembles that of a predictor-corrector algorithm for solving numerical problems [8] as shown in Figure 1. Kalman filter can be use in visual control to track the object. Normally, a tracking algorithm would be able to locate the object anywhere within the image at any point in time. However, only a limited region of the image is searched. Visual tracking will be failed if the object was moving to outside the region of camera frame and movetoo fast. Kalman filter can predict the object movement and solve these problems [6].
To implement discrete Kalman filter [8], we need to write down these equations into algorithm: − Time update First task is to determine the prediction value (xk), followed by error covariance (pk).
There are other variables, such as A, B, uk, and Q. These variables can be assumed as constant variables.
The process continued to determine Kalman gain (kk), error covariance (pk), and prediction value (xk). Xk will be the output of Kalman filter and used as feedback in control system. H can be determined as identity matrix, furthermore R is standard deviation. The method determine variable R is various, variable can be considered as a constant value or measured using the equation.

SYSTEM DESIGN
The system was designed to control 2 plants, consist of servo in horizontal axis and servo in vertical axis. These were controlled using PID controller and Kalman filter as feedback to move camera. The output of camera is an image frame which is proceed by computer vision technology before proceed to Kalman filter.
Electronic copy available at: https://ssrn.com/abstract=3662088  Figure 2 is the block diagram of the control system that explained on the proceeding section. Each block in the system has their own function. Set point has 2 values, there are x and y coordinate, which are proceed by their own PID block. Then, the output PID will be converted into degree and give instructions to servo to move to certain position.
Servo has its own controller to activate the DC motor, so motor servo can determine its position. A Camera will be attached to a servo, therefore the servo's position also shows the camera frame. The object will be recognized using image processing algorithm in feature extraction and release the x and y coordinate. Figure 3 is illustrating the hardware of the system using two servos (white) and the camera (green) so the system can move the camera in 2 axis, such as horizontal and vertical axis. Kalman filter will proceed both coordinates in the same time, it means the coordinates will be merged. Kalman filter will be designed using the program. Finally, the output of the filter will be used as feedback in the whole system. Subsection below will explain 2 most important components in control system, such as digital PID (Proportional, Integral, and Derivative) controller and Kalman filter. The control system is a control loop, so Ziegler-Nichols type 2 was used to find the PID parameter. However, we need to tune it manually to get the best responses time. This method proposed as practical procedure to find the parameter properly.

Kalman Filter
Kalman filter was designed to estimate the moving object which caught in camera frame. This filter is really beneficial in the system with a small visual angle of camera. Equations below Electronic copy available at: https://ssrn.com/abstract=3662088 There are 2 variables that can be changed to adjust the filter's responses, i.e. Q and R. Best responses will be depend on plant and the capability of the algorithm. Q will be a random value depend on the environment, however R will be found using the basic equation of standard deviation, there is: "̅ = " B + " + " + " E + " F : 5 We take 5 samples to find the standard deviation. 5 samples were the most appropriate among all. If we sample more than 5, a minor change will not affect the system.

RESULT AND ANALYSIS
In this section, we present the simulation and analysed the data. There are 2 types of data which will be analysed, consist of filter data and PID parameters. MATLAB R2013a is used to monitoring the data in graphs.
Kalman filter need to analyse before the control system. According to Figure 4, Kalman filter has fast responses, however Kalman filter can search the object whether the object is not detected.
Kalman filter will search the object depend on the last velocity of the object. The filter is also used to reduce noises (simulated by shaking the object), nevertheless there are no noises in system, so it will not be used.

Q = proses noise -= input kalman
Electronic copy available at: https://ssrn.com/abstract=3662088 We determine the Q equal to 5.0 and R equal to standard deviation for each 5 sampling data. If we increase Q to 20, we will get a faster response than before as shown inFigure 5.On actual process we implemented the dynamic camera (camera is moving), a slow responses Kalman will only helpful in the static camera. Fast responses are not good enough in dynamic camera, because plant will move the camera outside the moving range harshly if the object is not detected. So, we can conclude that Q should equal to 5.0. After the value of Q has been fixed, the control system will be designed. According to the section 3, we will use a digital PID (Proportional, Integral, and Derivative) controller in bilinear transform.
First of all, the controller will be designed using Ziegler-Nichols type 2. We need to find the ultimate gain using P controller in this method, we should made the system oscillating constantly,

Input kalman
Output kalman Object is not detected on camera frame Object is shaking Electronic copy available at: https://ssrn.com/abstract=3662088 and then we got two variables, such as ultimate gain andPeriod of oscillation. After that, we will find the PID parameters using these equations: According to the measurement using the equation 5.1 until equation 5.3, we got the PID parameter shown in Table 1 for horizontal axis and Table 2 for vertical axis. We control motor servo, which has its own controller. After some experiments, we conclude that PD control law should be used to control the position of motor servos, so Ki is changed to 0. Control system moves 2 motor servo, such as: -Motor servo in horizontal axis - Figure 5 (A) shows the system responses using Kalman filter. There are a lot of noises because the environment condition which affect the image processing, furthermore there is a state where the object moving outside the camera frame, then Kalman filter try to find the object. Table 3 is the result of system's response in horizontal axis using Kalman filter.   Figure 6 (B) is a PID response without Kalman filter. However, the system without Kalman filter has a faster response which has smaller settling time, rise time, and overshoot.
-Motor servo in vertical axis Figure 7(A) is the system's response of motor servo in vertical axis. According to the Table 5, system has a better result than horizontal axis with a smaller overshoot. There are also noises in the system, which has a same problem with motor servo in horizontal axis.  Electronic copy available at: https://ssrn.com/abstract=3662088 Meanwhile, system response without Kalman filter has been taken and it has a faster response than using Kalman filter. We can see on the Table 6 that a system without Kalman filter has a smaller settling time, but bigger overshoot.
According to the explanation, the response without Kalman filter is better than the otherwise. The reason is the feedback is not the real-time position, but it is the predictive position. It was predicted based on the object movement, therefore the response will be slower. The error happened when the object is moving. Theerror graphs have an overshoot, which is signed by a blue circle,the reason is Kalman filter need to adapt with the environment. It won't happened if the camera was in static condition. It is the reason why the settling time was slower than without using Kalman filter. The benefit of Kalman filter is able to predict the object movement, which is illustrated in Figure  9. Kalman output is signed by red square, and the object is green square. On the Figure 9(B), the object was blocked by another object and the system can't detect the object, however the system still predicted the movement. Although it has no better response, kalman filter can be used in this state and the object position can be estimated while the object was blocked.  Electronic copy available at: https://ssrn.com/abstract=3662088

SUMMARY AND CONCLUSION
The paper proposed the designed system which is easier to implement. It was written in a more practical way and less numerical theory. The final response we can get is settling time equal to 1.34s and rise time 0.38 for vertical axis. Beside, the horizontal axis has settling time and rise time in 1.603s and 0.402s.
The result shows the difference between a system using Kalman filter and without Kalman filter.
We have a faster and better result when it is not using Kalman filter. However, there are some advantages for the system using Kalman filter, such as: -Control system can predict the object movement when the object moves to outside the camera frame. -Kalman filter can estimate the object position when the object moves behind another object.
So, the conclusion is the system will be better using kalman filter. In the implementation, the system will be used to aim an object, and the ability to predict the object movement is really needed. It has a slower settling time than without using kalman filter, because the system need to adapt to the environment when the camera is moving.