# Chimney Sweeping Robot Based on a Pneumatic Actuator
## 4 Numerical Simulations and Experiments
### Numerical Simulation  
In this part, the focus is on the implementation of the mathematical background of the robot (mentioned in the previous section) into the numerical simulation and comparing the simulation with the real robot motion. For the simulation, MATLAB R2019b software was used. The robot motion can be described by the following Algorithm 1. ```
1:Initialization of variables and constants
2:FOR cycle = 1 TO Number of required cycles BY 1
3:FOR i = 0 TO T BY dt // Forward motion of pneumatic piston
4:IF (i > valveDelay) THEN
5:\(F_{C}=F_{max}\)
6:END
7: Computation of mass 1 acceleration, velocity, position
8:IF (contact < \(\rho\)) AND (\(y_{1}>y_{1 max}\)) THEN
9:contact++
10:\(F_{R}=(y_{1}-y_{1 max})c+dy_{1}b\)
11:ELSEIF (contact== \(\rho\)) AND (\(y_{1}>y_{1 max}\)) THEN
12:\(F_{C}=F_{R}=dy_{1}=dy_{1}=0\)
13:ELSEIF (contact==0) AND (\(y_{1}<y_{1 max}\)) THEN
14:\(F_{R}=0\)
15:END
16:\(m_{2}\frac{dy_{2}}{dt}=F_{R}+F_{f}-G_{2}\)
17: Computation of mass 2 acceleration, velocity, position
18:END
19:FOR i = 0 TO T BY dt // Backward motion of pneumatic piston
20:IF (i > valveDelay) THEN
21:\(F_{C}=F_{max}\)
22:END
23: Computation of mass 1 acceleration, velocity, position
24:IF (\(y_{1}\leq 0\)) THEN
25:\(dv_{1}=dy_{1}=y_{1}=0\)
26:END
27: Computation of mass 2 acceleration, velocity, position
28:END
29:END
```  
**Algorithm 1** Numerical simulation  
The algorithm is divided into two parts. The first part deals with the extension of the pneumatic piston, and the second part deals with the insertion of the piston. The algorithm uses mathematical background, which is described in the previous section. The constant _valveDelay_ is the value from the datasheet of the pneumatic valve. It is the time delay of the used pneumatic valve. The force \(F_{max}\) represents the maximal force of the used pneumatic cylinder, which is given by the datasheet. As can be seen from the algorithm, there is variable _contact_, which stands for the simulation of the time period in which two masses are in contact. The value of this variable was empirically determined as constant \(\rho\). The simulations use the constants given in the Table 1.  
Choosing the correct damping and stiffness coefficients is very important for a successful simulation. In our case, the spring and damper do not represent the actual springs and dampers; hence, the theoretical approach of determining the values was chosen. Following the approach in [25], the stiffness of the contact can be calculated with the following equation:  
\[c=4\pi^{2}f^{2}m \tag{3}\]The damping coefficient \(b_{1}\) is also selected by a similar approach [26]. In this equation, the recommended value of \(\beta\) lies between 0.1 and 0.4. \[b=2\beta\sqrt{km} \tag{4}\]  
The calculated stiffness and damping coefficient have to be checked with the simulation and, if necessary, adjusted. Note that the higher the stiffness of the contact is, the slower the calculations in the simulations will be. This means that the goal here is to choose the proper constant as low as possible while keeping the plausibility of the simulation. In the first cycle, the algorithm starts with the calculations of the acceleration and velocity of the moving mass at the end of the pneumatic piston, which is changes as the piston extends toward the point of contact between the moving mass and the collision insert that is connected to the robot's body. The next step in the first cycle is the simulation of the contact between the moving mass and the collision insert. This contact is represented in the mathematical model with the damper and spring. The collision that happens is simulated by creating an impulse contact force that is the sum of the forces created by the spring and the damper, as described in Section 4.1. Initially, before the robot starts the motion, the gravitational force that pulls the robot down equals the friction force of the brushes and walls of the chimney/pipeline, which is why the robot stands still and does not fall toward the ground.