## 3 Our Approach to Estimation of Robot Pose and Pipe Diameter (EPD)
### Framework of Robot Pose and Pipe Diameter Estimation
The parameters governing this rigid transformation correspond to the quintuple robot pose in the PCS, denoted by \((\theta_{x},\theta_{y},\theta_{z},\delta_{y},\delta_{z})\), where \((\theta_{x},\theta_{y},\theta_{z})\) represents a three-axis rotation (roll, pitch, yaw) and \((\delta_{y},\delta_{z})\) represents a translation along the Y- and Z-axes, which align with the pipe's major and minor axes, respectively. Combining these pose parameters with the pipe's major- and minor-axis lengths yields a septuple-parameter vector, as follows:  
\[\mathbf{\beta}=(D_{\text{max}},D_{\text{min}},\theta_{x},\theta_{y},\theta_{z}, \delta_{y},\delta_{z}). \tag{2}\]  
To map the measurement points \(\hat{\pi}_{i,S}\) in the SCS to the corresponding points \(\hat{\pi}_{i,P}\) in the PCS, we apply a rigid transformation that consists of rotations and translations. The transformation is defined as  
\[\hat{\pi}_{i,P}=\mathbf{R}_{Z}(\theta_{z})\mathbf{R}_{Y}(\theta_{y})\mathbf{R}_{X}(\theta _{x})\hat{\pi}_{i,S}+[0,\delta_{y},\delta_{z}]^{T}. \tag{3}\]  
where \(\mathbf{R}_{X}(\theta_{x})\), \(\mathbf{R}_{Y}(\theta_{y})\), and \(\mathbf{R}_{Z}(\theta_{z})\) are 3D rotation matrices about the X-, Y-, and Z axes, respectively, and \([0,\delta_{y},\delta_{z}]^{T}\) represents the translation vector. Given this transformation, the measurement points in the PCS align with the elliptical cross-section model of the pipe, enabling a more structured evaluation of the data. We formulate the problem of estimating \(\mathbf{\beta}\) as a non-linear least-squares fitting problem, which minimizes errors by fitting the sensor measurements to an elliptical cross-section model. The optimization minimizes the sum of squared residuals between the transformed points and the elliptical model of the pipe. The residual function, denoted as \(r(\hat{\pi}_{i,P},\mathbf{\beta})\), evaluates the fit of each transformed point, \(\hat{\pi}_{i,P}\), to the ellipse defined by the parameters \(D_{\text{max}}\) and \(D_{\text{min}}\). The objective function for this optimization is expressed as  
\[F(\mathbf{\beta})=\sum_{i=1}^{N}r^{2}(\hat{\pi}_{i,P},\mathbf{\beta}). \tag{4}\]  
To solve this non-linear least-squares problem, we employ iterative optimization algorithms that are widely used in non-linear parameter estimation. These include the gradient descent algorithm [23], the Gauss-Newton algorithm [24], and the Levenberg-Marquardt algorithm [25; 26]. The gradient descent algorithm follows the steepest path in the opposite direction to the gradient with a step size called learning rate. A small learning rate leads to slow convergence while a large one incurs divergence. The Gauss-Newton method approximates the objective function as a quadratic function and computes a step that minimizes the quadratic function. It may not converge if the initial guess is far from the solution. The Levenberg-Marquardt algorithm combines these two algorithms by introducing the damping factor. Based on the damping factor, it acts like gradient descent for stability when far from the solution and acts like the Gauss-Newton model when close to the solution for faster convergence. Due to its advantages, we choose the Levenberg-Marquardt method as the optimization algorithm. This algorithm iteratively updates the parameters of \(\mathbf{\beta}\) to minimize the residual errors, ensuring that the transformed points closely match the elliptical model of the pipe. In the following sections, we define two types of residual functions and mathematically model their impacts on the estimation of robot pose and pipe diameter.