# Position Tracking Control of 4-DOF Underwater Robot Leg Using Deep Learning
## 4 Torque Control Based on the Neural Network  
### Data Collection  
For excellent learning performance, high-quality data is essential. To achieve this, we needed to prepare data that accurately reflects relevant aspects for learning dynamic characteristics. Most recently manufactured servo motors support high-performance position control. When a desired angle is input as the position command, the high-speed position controller within the motor driver generates the required torque to precisely follow the position input. In this process, the dynamic characteristics for moving the output link of the motor to the input position are reflected in the motor torque. Therefore, by employing machine learning based on the desired motion and joint torque output, we can calculate joint torque without the need for modeling and computation of the effects of the fluid. Moreover, non-linear factors, such as motor friction, can also be learned. Thus, based on the derived torque and motor encoder readings, we deemed the data meaningful and utilized it for learning. Relying solely on the reading of the motor encoders may appear to be somewhat less accurate, as it depends on the performance of the motor. However, the goal of this paper is to learn the dynamic patterns that occur during the interaction between the robot and the fluid in the real world. Therefore, even if there is an error in the encoder reading, the dynamic characteristics for that case can still be learned and reflected in the control itself.  
The radial-type quadruped walking robot, serving as the model for the test platform, exhibits the ability to move in various directions without rotating its body, thanks to its radially mounted legs. During the robot's walking motions, the leg moves in two directions with respect to the body: forward and lateral. The training trajectory was set based on these motions, encompassing all aspects of low and high speeds, narrow and wide ranges, and both forward and lateral directions. While performing position tracking control of the training trajectory of the foot tip, we collected the input data set X, as depicted in Figure 5.  
The input data set \(X\) was constructed as follows.  
\[X=\left\{\theta,\dot{\theta},P_{x},P_{y},P_{z},R_{Y},Env.\right\} \tag{1}\]  
where \(\theta\in\mathbb{R}^{4}\) is the angle of each joint, \(\dot{\theta}\in\mathbb{R}^{4}\) denotes the angular velocity of each joint. \(P_{x},P_{y},P_{z}\) is the \(x,y\), and \(z\) position of the foot tip and \(R_{Y}\) is the pitch angle in task-space. \(Env.=\left\{\begin{matrix}0&(Air)\\ 1&(Water)\end{matrix}\right.\) is the environment in which the robot is located. This data set \(X\) is labeled to determine the robot's motion state based on input data. The motion of the  
Figure 5: Reference foot tip trajectory.  
robot leg is identified through the angle and angular velocity of the joint. The posture of the leg during the motion is identified by the position and orientation of the foot tip. The environment in which the robot is located is determined through _Env_. In the learning process, environmental data is automatically classified using one-hot encoding. In this study, data in both air and water environments are classified and learned, but the approach can be applied in more various environments. In the learning process, the neural network learns the relationship between the data set \(X\) and the measured joint torque. After this process, the neural network can predict the suitable joint torque for the input trajectory regardless of the environment.