## 2 Design, Modeling, and Control
### Robot Kinematics  
Regarding the movement of the vehicle, there are three possible locomotion modes--purely legged, purely wheeled, and hybrid. In the purely wheeled mode, whether in low-power or when it is at a defined height, the robot always tries to maintain the wheels' \(x_{l}\) axis aligned with the rotation axis of joint 0, for all legs. This strategy prevents the wheel from dragging laterally when moving the leg, guaranteeing that the contact point of the wheel with the floor does not move in \(y\), rather rotating only on its axis.  
The variables used to calculate the robot kinematics are pictured in Figure 20. The variables \(a,\ b,\ \text{and}\ d\) are the linear distances to the center of the robot. \(v_{r}\) and \(v_{n_{r}}\) represent the robot's linear speeds along the \(x\) and \(y\) axes, respectively, while \(\omega_{r}\) represents its angular speed. For each wheel, a \(v_{i_{w}}\) speed is defined, as well as its orthogonal projections \(v_{x}\) and \(v_{y}\). The angle \(\theta_{i_{w}}\) is the wheel angular position relative to the \(x\) axis.  
Following are the equations relative to the robot kinematics, considering, as already mentioned, that the rotation axis of joint 0 is aligned with the rotation axis of the wheel, regardless of the robot's height. The variables to be controlled are each leg joint 0 angle, which defines the wheel's angle (\(\theta_{0}^{l}\)), as well as the speed of the wheel (\(v_{y}^{l}\)).  
Figure 19: Complete joint control block diagram.  
Figure 20: Robot kinematic variables.  
Equations (3) to (12) present the generic deduction of the contribution that each leg will have in the calculations of the robot's \(v_{r}\), \(v_{n_{r}}\), and \(\omega_{r}\) speeds. Although Equations ( 3) to (5) are quite intuitive, three computationally demanding functions were used (sin, cos, and atan2). So, Equations (6) to (8) present a simplification set on trigonometric rules, which makes it possible to decrease the number of computationally demanding functions being used. The only one that was not possible to stop using was atan2. The simplified equations are presented in Equations (9) to (12).  
\[\beta=\text{atan2}(y,x) \tag{3}\] \[v_{x}=v-\omega\cdot d\cdot\sin\beta\] (4) \[v_{y}=v_{n}+\omega\cdot d\cdot\cos\beta \tag{5}\]  
\[d=\sqrt{x^{2}+y^{2}} \tag{6}\] \[\sin\beta=\frac{y}{\sqrt{x^{2}+y^{2}}}=\frac{y}{d}\] (7) \[\cos\beta=\frac{x}{\sqrt{x^{2}+y^{2}}}=\frac{x}{d} \tag{8}\]  
\[v_{x}=v-\omega\cdot y \tag{9}\] \[v_{y}=v_{n}+\omega\cdot x \tag{10}\]  
\[v_{wheel}=\sqrt{v_{x}^{2}+v_{y}^{2}} \tag{11}\] \[\theta_{wheel}=\text{atan2}(v_{y},v_{x}). \tag{12}\]  
Next, Table 6 presents the equations that were implemented in software, which allow the calculation of the individual angle of each leg, as well as the respective speed of each wheel.  
After obtaining \(\theta_{0j\ ref}\) and \(\omega_{w_{l}\ ref}\) for the desired \(v_{r}\), \(v_{n_{r}}\), and \(\omega_{r}\), joints 0 are controlled with PID position controllers, while the wheels' speeds are controlled through PID speed controllers. The diagram in Figure 21 presents the mentioned controllers.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Leg 0** & **Leg 1** & **Leg 2** & **Leg 3** \\ \hline \(x=a\) & \(x=a\) & \(x=-a\) & \(x=-a\) \\ \(y=-b\) & \(y=b\) & \(y=b\) & \(y=-b\) \\ \(v_{x}=v+\omega\cdot b\) & \(v_{x}=v-\omega\cdot b\) & \(v_{x}=v-\omega\cdot b\) & \(v_{x}=v+\omega\cdot b\) \\ \(v_{y}=v_{n}+\omega\cdot a\) & \(v_{y}=v_{n}+\omega\