# The Tractor-Cart System Controller with Fuzzy Logic Rules
## 2 Tractor and Cart System Modeling
### Kinematic Bicycle Model
In most of the models reported in literature devoted to vehicle and cart motion, the slip angle is not considered. In this model, the effect of slip angle was considered. In a second input control signal \(u_{2}(\alpha)\), the hitch control was taken to steer the hitch arm in order to minimize the error of the cart position with respect to the reference pattern. The tractor velocity was assumed to be constant. By discretizing differential Equations in (1), (3), and (4), and integrating them with respect to the sampling time (\(\Delta t=\frac{1}{f_{s}}\), \(f_{s}\): sampling frequency), and updating controller's equations with control signals, the next Equations (5)-(7) were derived:  
\[\left[ \begin{array}{c}X_{t}(t)\\ Y_{t}(t)\\ \varphi_{t}(t)\end{array} \right]=V_{t}\Delta t\left[ \begin{array}{c}\cos[ \varphi_{t}(t)+\beta(t)]\\ \sin[\varphi_{t}(t)+\beta(t)]\\ \frac{\cos(\beta(t))\tan u_{1}(t)}{L_{t}}\end{array} \right] \tag{5}\]  
\[\varphi_{c}(t)=\frac{V_{t}\Delta t\cos\beta(t)\sin(\varphi_{t}(t)-\varphi_{c} (t))}{L_{c}}-\frac{aV_{t}\Delta t\cos\beta(t)\tan u_{1}(t)\cos(\varphi_{t}(t) -\varphi_{c}(t))}{L_{t}L_{c}} \tag{6}\]  
\[\varphi_{c}(t)=\frac{V_{t}\Delta t\cos\beta(t)\cos u_{2}(t)\sin\sigma(t)-R \Delta t\dot{\alpha}(t)\cos\sigma(t)}{L_{c}} \tag{7}\]  
where \(\sigma=\varphi_{t}-\alpha-\varphi_{c}\). The cart position without and with a controller is given in Equations (8) and (9), respectively:  
\[\left[ \begin{array}{c}X_{c}(t)\\ Y_{c}(t)\end{array} \right]=\left[ \begin{array}{c}X_{t}(t)-L_{r}\cos\varphi_ {t}(t)-L_{c}\cos\varphi_{c}(t)\\ Y_{t}(t)-L_{r}\sin\varphi_{t}(t)-L_{c}\sin\varphi_{c}(t)\end{array} \right] \tag{8}\]  
\[\left[ \begin{array}{c}X_{c}(t)\\ Y_{c}(t)\end{array} \right]=\left[ \begin{array}{c}X_{t}(t)-L_{r}\cos\varphi_ {t}(t)-R\cos(\varphi_{t}(t)-\alpha(t))-L_{c}\cos\varphi_{c}(t)\\ Y_{t}(t)-L_{r}\sin\varphi_{t}(t)-R\sin(\varphi_{t}(t)-\alpha(t))-L_{c}\sin \varphi_{c}(t)\end{array} \right] \tag{9}\]  
The resulting state vector of the overall kinematic model is expressed by Equation (10):  
\[x=\left[ \begin{array}{cccccc}X_{t}&Y_{t}&\varphi_{t}&\beta&V_{t}&\varphi_{c }&X_{c}&Y_{c}\end{array} \right] \tag{10}\]  
The overall control vector is given in (11):  
\[u=\left[ \begin{array}{cc}\delta&\alpha\end{array} \right] \tag{11}\]  
Finally, a generalized system model is expressed in (12):  
\[x(t_{i+1})=f(x(t_{i}),\delta(t_{i}),\alpha(t_{i})) \tag{12}\]  
Row patterns of crops in the fields in general do not change abruptly and don't have sharp curves. Thus, angles of \(\beta\), \(\delta\), and \(\alpha\) can be considered to have relatively small values. To simplify and linearize the model equations given in (5)-(9), all the trigonometric functions were substituted with their fourth and fifth degree Taylor Series expansions. The system Equations (5)-(9) were re-written in (13)-(17):  
\[\left[ \begin{array}{c}X_{t}(t)\\ Y_{t}(t)\\ \varphi_{t}(t)\end{array} \right]=V_{t}\Delta t\left[ \begin{array}{c}1-\frac{ \left(\varphi_{t}(t)+\beta(t)\right)^{2}}{2!}+\frac{\left(\varphi_{t}(t)+ \beta(t)\right)^{4}}{4!}\\ \left(\varphi_{t}(t)+\beta(t)\right)-\frac{\left(\varphi_{t}(t)+\beta(t) \right)^{3}}{3!}+\frac{\left(\varphi_{t}(t)+\beta(t)\right)^{5}}{5!}\\ \frac{1}{L_{t}}(1-\frac{\beta(t)^{2}}{2!}+\frac{\beta(t)^{4}}{4!})(\delta(t)+ \frac{\delta(t)^{3}}{3}+\frac{2\beta(t)^{5}}{15})\end{array}