1 Introduction

Complex components find wide application in the core parts of advanced equipment across various fields such as aerospace, shipbuilding, and new energy. The level of their manufacturing represents a significant measure of a nation’s industrial development [1]. As a crucial element in intelligent manufacturing [2], industrial robots offer numerous advantages, including a large workspace, exceptional processing flexibility, and the ability to adapt quickly to different scenarios. Moreover, in comparison to CNC machine tools, industrial robots possess greater degrees of freedom and can be enhanced with positioners, mobile bases, and other components. This high processing flexibility renders them highly promising for manufacturing complex components. By meeting the quality requirements of the machining process, robot machining can effectively reduce costs and improve efficiency [3, 4].

However, the weak stiffness of industrial robots makes them more susceptible to changes in cutting force during milling [5]. When the cutting force becomes unstable or excessively high, it compromises the stability of robot milling, leading to a decline in machining quality and potentially causing damage to the workpiece or tool [6]. Consequently, in robot milling, operators typically opt for relatively safe and conservative machining parameters. However, this approach hampers machining efficiency and impedes the widespread adoption of robots in manufacturing [7]. Erkorkmaz [8] has pointed out and demonstrated that by effectively controlling cutting forces, mechanical loss and energy consumption can be reduced while improving machining efficiency. Furthermore, Wang [9] has highlighted the significance of controlling grinding forces in robot grinding of thin-walled parts. This control effectively reduces the amplitude of workpiece vibration, ultimately minimizing machining errors. Therefore, optimizing robot stiffness and ensuring load stability in the machining toolpath are crucial for maintaining the performance and stability of robot milling operations.

Existing research on milling force optimization primarily focuses on feed rate optimization and machining toolpath optimization. Erdim [10] developed an approximately linear relationship model between feed rate and cutting force based on a tool engagement model. They then offline optimized the feed rate with the objective of maintaining a constant cutting force. Huang [11] measured actual cutting forces through pre-experiments and subsequently optimized the feed rate offline, avoiding the need for complex cutting force simulations and experimental coefficient calibration. Ridwan [12] proposed a control method to optimize cutting forces during the machining process using fuzzy adaptive control. By monitoring changes in cutting force, the feed rate can be automatically adjusted. This method increases the feed rate when the cutting force is small, enabling higher machining efficiency while maintaining a stable material removal rate. Wang [13] presented a feed rate optimization method for side milling that maintains a constant peak cutting force. The method calculates the instantaneous undeformed cutting thickness based on the least square principle, establishes a cutting force model, and quickly determines the optimal feed rate while keeping the peak cutting force constant. However, when milling complex surfaces, the feed rate optimization method places higher demands on the response speed and motion performance of the robot controller. Additionally, the frequently changing feed rate can lead to frequent acceleration and deceleration of the robot joints, reducing the stability of the machining process. Therefore, in robot machining, optimizing the toolpath is highly significant for controlling cutting forces.

Fig. 1
figure 1

The overall framework of the method in this work

Wu [14] employed the corner looping tool path to gradually remove materials in the corner area during cavity milling, effectively limiting the cutting force to an acceptable level. However, sudden changes in cutting force still occur in the non-corner areas. Kim [15] utilized the pixel method to simulate the material removal rate (MRR) and inserted additional arc toolpaths in regions with excessive MRR. This method successfully maintained the stability of the cutting force in plane milling. Rahman [16] proposed a milling toolpath planning method for critical machining regions that consists of smoothly connected linear segments and multi-segment arcs. This approach guarantees a stable MRR at a constant speed for the machine tool. Ma [17] stated that reducing fluctuations in cutting force during milling can enhance machining quality. They proposed a path planning method that ensures uniform cutting amounts by considering the geometric features of curved surface parts. Wang [18] noted that trochoidal trajectories effectively stabilize cutting forces in milling and possess advantages in terms of smoothness and continuity. Building upon the benefits of trochoidal toolpaths, Luo [19] presented a toolpath planning method for the four-axis blade disk machining. These studies illustrate that a suitable toolpath planning approach can effectively stabilize cutting forces and enhance machining quality. However, existing constant milling load research primarily focuses on cavity machining, with limited emphasis on freeform surface machining. Additionally, current toolpath planning methods target CNC machine tools and do not consider the challenge of further reducing machining quality under constraints of stiffness and smoothness in robot machining. Moreover, the weak stiffness of robots severely constrains feasibility in robot surface milling due to the instability of cutting forces.

The stiffness of a robot is influenced by its structure and will vary based on the robot’s position and posture within its workspace [20, 21]. Previous research has shown that the robot’s posture and cutting force direction are crucial factors in determining its stiffness [22, 23]. Complex surface machining can lead to interference, singularity, and abrupt changes in posture due to significant variations in the tool axis vector and robot posture during the machining process. Therefore, there is a challenge in optimizing the redundant degrees of freedom (DOF) in robot milling to improve machining quality while ensuring non-interference, non-singularity, and smooth joint motion. This challenge holds significant application value. To address this challenge, researchers have proposed various approaches. Xiong [24] developed an evaluation index considering the complete deformation matrix and optimized the robot posture while transplanting the milling toolpath used by a five-axis machine tool into the robot to enhance its stiffness. Bu [25] proposed an optimized stiffness ellipsoid model to analyze the distribution of robot stiffness in space. They then optimized the robot posture when the robot followed a fixed drilling toolpath to improve stiffness performance. Chen [26] introduced a stiffness index that considers the cutting force and the normal vector direction of the machining position to guide toolpath planning and posture optimization in robot milling. Lin [27, 28] highlighted that the robot’s stiffness changes with its end position. They optimized the assembly position and orientation of the robot’s end effector during the machining process by combining the main body stiffness index, kinematics performance index, and deformation evaluation index to enhance robot stiffness in machining. However, the existing stiffness indicators do not account for the adaptability of stiffness to the current processing conditions, making it challenging to maximize the robot’s stiffness performance in real-time situations.

In robot milling of freeform surfaces, ensuring the stability of milling force and the robot stiffness are crucial for achieving high-quality surface machining. This study aims to address the requirements of constant load and high stiffness milling by proposing a toolpath planning method based on the Dexel model for freeform surface milling MRR simulation. This method combines the conformal mapping algorithm with a variable radius trochoidal trajectory. Additionally, a stiffness MRR matching evaluation index is introduced, which, when combined with the dynamic A* algorithm, enables the calculation of the optimal sequence of robot posture changes under motion constraints. The primary objective is to optimize stiffness matching. Furthermore, through simulation and experimentation, the effectiveness of cutting force optimization and the improvement in machining quality in robot milling of freeform surfaces are demonstrated and verified. The overall framework of the method in this article is shown in Fig. 1.

2 Toolpath planning method with constant load

In this work, we propose a constant load milling toolpath planning method based on MRR simulation. Firstly, we calculate the change in MRR when the milling tool follows a specific toolpath using the Dexel model. Then, we apply the threshold segmentation algorithm to extract the critical region where the MRR exceeds a predefined threshold. Next, taking advantage of the stability of cutting force provided by the variable radius trochoid toolpath and utilizing the conformal mapping algorithm, we generate a constant load milling toolpath for free-form surfaces. This method aims to ensure consistent and stable milling forces throughout the machining process.

2.1 Dexel-based MRR calculation method

Park [29] found a positive correlation between MRR and cutting force under fixed machining parameters, which can be derived from the relationship between MRR and spindle power. Thus, MRR is commonly used as an efficient evaluation index for cutting load. To address the challenge of optimizing toolpaths during the planning stage, which often involves significant computation time and resources, this study proposes an MRR prediction method for free-form surface milling based on the Dexel model. Compared to solid models, the Dexel model (depth pixel) simplifies three-dimensional Boolean operations into one-dimensional Boolean operations during simulation. This model exhibits characteristics such as compact storage space, fast operation speed, and high efficiency. As illustrated in Fig. 2, leveraging the advantages of the Dexel model, this study converts the calculation of MRR in the milling process into one-dimensional Boolean operations of the Dexel model, considering the workpiece and tool at each cutting location.

In this method, the mesh model of the workpiece and tool is converted into a Dexel model. As depicted in Fig. 2(a), the mesh model is initially projected onto the XOY plane to determine the bounding box size (\({X_{\min }}\), \({X_{\max }}\), \({Y_{\min }}\), \({Y_{\max }}\))and discretize it into a grid with a side length of \(sl_x\) and \(sl_y\). Then, a ray parallel to the z-axis is cast at the intersection of each grid to obtain the intersection set with the mesh model, including the tool and workpiece. Line segments are generated based on the Z values, and each line segment is associated with the intersecting grid to uniquely represent the Dexel model within the tool or workpiece. As shown in Fig. 2(b), to perform the one-dimensional Boolean operation between the workpiece Dexel model and the tool Dexel model, it is crucial to align both models within the same discrete grid. Additionally, given that the workpiece is generally larger than the tool in milling, this method employs the discrete grid of the workpiece as the reference grid to construct the Dexel model for both the workpiece and tool.

Fig. 2
figure 2

Calculation process of the Dexel model

The flow chart for MRR calculation based on the Dexel model is presented in Fig. 2. Initially, following the Dexel model calculation method mentioned earlier, the Dexel model of the workpiece is established. Subsequently, the toolpath is interpolated to determine discrete cutter location (CL) points with a certain calculation accuracy. The Dexel model of the tool is computed at each discrete CL point. Next, a Boolean operation is carried out on the Dexel models of the tool and workpiece, allowing for the calculation of the instantaneous MRR. Simultaneously, the Dexel model of the workpiece is updated.

The CL point contains position coordinate information \(\left( {x,y,z} \right) \) and tool axis direction information \(\left( {\alpha ,\beta ,\gamma } \right) \) during surface milling. If the distance between the two CL points is close enough and the angle is small enough, the MRR between these two CL points can be regarded as the instantaneous MRR corresponding to each CL point.

If the distance \(Dis{t_{{P_t},{P_{t + 1}}}}\) between two adjacent CL points \({P_t}\left( {{x_t},{y_t},{z_t},{\alpha _t},{\beta _t},{\gamma _t}} \right) \) and \({P_{t + 1}}\left( {{x_{t + 1}},{y_{t + 1}},{z_{t + 1}},{\alpha _{t + 1}},{\beta _{t + 1}},{\gamma _{t + 1}}} \right) \) is greater than the maximum distance allowable value \({\max _\alpha }\) or the included angle \(Angl{e_{{P_t},{P_{t + 1}}}}\) is greater than the maximum angle allowable value , n-segment linear interpolation subdivision is required. The new CL points \({P_i}\left( {{x_i},{y_i},{z_i},{\alpha _i},{\beta _i},{\gamma _i}} \right) \) after interpolation can be expressed as:

$$\begin{aligned} {P_i} = {P_t} + \frac{{\left| {{{\overline{{P_{t + 1}} - P} }_t}} \right| }}{n} \cdot i \end{aligned}$$
(1)

where i represents the i-th point in the interpolation, \(n = \max \{ \frac{{Dis{t_{{P_t},{P_{t + 1}}}}}}{{ma{x_d}}},\frac{{Angl{e_{{P_t},{P_{t + 1}}}}}}{{ma{x_\alpha }}}\} \).

Fig. 3
figure 3

MRR calculation flow chart based on Dexel model

After interpolation, the tool Dexel model under the workpiece projection grid is constructed at each CL point. The Boolean difference operation is carried out to obtain the material removal volume. As shown on the right side of Fig. 3, Boolean operations at the grid are mainly divided into the following situations:

  1. (1)

    The tool and workpiece are not cut, and the workpiece Dexel is not updated;

  2. (2)

    Cutting occurs between the tool and the rear section of the workpiece, and the workpiece Dexel is up-dated to \(\{d^t_{max},d^w_{max}\} \) ;

  3. (3)

    Cutting occurs between the tool and the middle section of the workpiece, and the workpiece Dexel is updated to \(\{ d^w_{min},d^t_{min}\} \) and \(\{ d^t_{max},d^w_{max}\} \);

  4. (4)

    Cutting occurs between the tool and the front section of the workpiece, and the workpiece Dexel is updated to \(\{ d^w_{min},d^t_{min}\} \);

  5. (5)

    Cutting occurs between the tool and the whole section of the workpiece, and the corresponding Dexel of workpiece is deleted;

  6. (6)

    Same as case 1. The calculation formula is as follows:

$$\begin{aligned} \left\{ \begin{array}{ll} {{l_{d}} = 0,}&{}{d^t_{min}< d^t_{max}< d^w_{min}< d^w_{max}}\\ {{l_{d}} = d^t_{max} - d^w_{min},}&{}{d^t_{min}< d^w_{min}< d^t_{max}< d^w_{max}}\\ {{l_{d}} = d^t_{max} - d^t_{min},}&{}{d^w_{min}< d^t_{min}< d^t_{max}< d^w_{max}}\\ {{l_{d}} = d^t_{min} -d^w_{min},}&{}{d^w_{min}< d^t_{min}< d^w_{max}< d^t_{max}}\\ {{l_{d}} = d^w_{max} - d^w_{min},}&{}{d^t_{min}< d^w_{min}< d^w_{max}< d^t_{max}}\\ {{l_{d}} = 0,}&{}{d^t_{min}< d^t_{max}< d^w_{min} < d^w_{max}} \end{array} \right. \end{aligned}$$
(2)

where \( d^w_{min}\) and \(d^t_{min}\) respectively represent the near end value of the Dexel segment of the workpiece and the tool in the Z direction, \(d^w_{max}\) and \(d^t_{max}\) represent the far end value, \(l_d\) indicates the length of the cutting. In addition, assuming \(e_s\) is the error of approximating the surface with dexel units, which is related to the accuracy requirement of MRR simulation, the mesh partition accuracy of the workpiece \(W_work\) can be determined based on the minimum curvature radius \(R_s\) of the surface.

$$\begin{aligned} W_{work} = \sqrt{4 e_s R_s - 2 e_s^2} \end{aligned}$$
(3)

Assuming the radius of the tool is \(R_t\), the partition accuracy of the tool’s mesh is determined by

$$\begin{aligned} W_{tool} = 2R_t - 2\sqrt{R_t^2 - e_s^2} \end{aligned}$$
(4)

Then, the cutting volume of the workpiece can be obtained by the intersecting dexel length:

$$\begin{aligned} \Delta V = sl_x \cdot sl_y \cdot \sum {l_d} \end{aligned}$$
(5)

The cutting time can be obtained by the feed speed \({v_f}\) and the distance between two CL points \(\Delta s\) :

$$\begin{aligned} t = \frac{{\Delta s}}{{{v_f}}} \end{aligned}$$
(6)

Then, the MRR of the i-th CL point can be calculated by the following formula:

$$\begin{aligned} MR{R_i} = \frac{{\Delta V}}{t} = sl_x \cdot sl_y \cdot l_d \cdot \frac{{{v_f}}}{{\Delta s}} \end{aligned}$$
(7)

where \(\Delta V\) represents the material removal volume.

Fig. 4
figure 4

Traditional milling toolpath and corresponding critical region

Fig. 5
figure 5

Insert RVTR toolpath in different critical machining regions

2.2 Toolpath planning method for constant milling load

In this section, we propose a constant load toolpath planning method for complex free-form surface milling, building upon the previous constant load toolpath planning method in cavity milling [30]. This method is derived from the traditional contour parallel toolpath approach and incorporates a radius-varying trochoidal (RVTR) trajectory with constant cutting depth for processing the critical machining region. By implementing this method, we ensure that the cutting load remains within the prescribed limit, even when the MRR suddenly increases, thereby maintaining a high level of machining efficiency.

To begin with, the contour parallel toolpath for the freeform surface is generated, and the CL points sequence \(C{L_{list}} = \left\{ {c{l_1},c{l_2},...,c{l_n}} \right\} \) is obtained through uniform discretization. The MRR of surface milling is then calculated using the method described in Section 2.1. As depicted in Fig. 4, the MRR remains stable when the machining toolpath is a straight line (P1-P2). However, when the toolpath becomes a curve (P3-P4), the MRR fluctuates with the curvature. In extreme cases, such as at a corner (P5-P6), the MRR experiences a sudden increase. To address this issue and ensure a consistent MRR throughout the machining process, this study extends the previous work’s critical machining region extraction algorithm to accommodate freeform surface milling.

Fig. 6
figure 6

Case of toolpath planning method for constant milling load

Then, the MRR threshold calculation method based on OTSU is used to extract the set of CL points exceeding the set MRR value, as shown on the right side of Fig. 4. Assuming a threshold value \((M_{thr}\) is used to dichotomize the cutter locations in \(C{L_{list}}\) into two classes, including the critical machining region, \(C{L_{inc}}\{ \cup c{l_i},(M_{thr} \le MRR(i) \le M_{max}\} \) , and the class of the common machining region, \(C{L_{com}}\{ \cup c{l_i},0 \le MRR(i) \le (M_{thr}\} \) . The MRR threshold calculation satisfies the following formula:

$$\begin{aligned}{} & {} \begin{array}{ll} \sigma _B^2((M_{thr}) = {\rho _{inc}}((M_{thr}){[{\mu _{inc}}((M_{thr}) - {\mu _{list}}]^2}\\ + {\rho _{com}}((M_{thr}){[{\mu _{com}}((M_{thr}) - {\mu _{list}}]^2} \end{array}{} & {} \end{aligned}$$
(8)

where \({\mu _{inc}}(M_{thr})\) , \({\mu _{com}}((M_{thr})\) and \({\mu _{list}}\) represented the average MRR corresponding to \(C{L_{inc}}\) , \(C{L_{com}}\) and \(C{L_{list}}\) respectively, and \({\rho _{inc}}((M_{thr})\) and \({\rho _{com}}((M_{thr})\) are the probability of occurrence of each part. When \(\sigma _B^2((M_{thr})\) is the largest, the difference between the critical region and the common region is the largest, that is, the segmentation effect is the best, and then the \((M_{thr}\) is determined.

As depicted in Fig. 5, the critical region can be divided into three situations: the corner area, the innermost area, and the connection area. In the corner area, the central axis is generated for the region composed of the ring and its sub-ring. The portion within the critical region is then extracted as the guide line for the RVTR toolpath. In the innermost area, the ring corresponding to the critical region is used as the center axis for contour generation and as the guide line for the RVTR toolpath. In the connection area, the connecting straight line is offset to serve as the guide line for the RVTR toolpath. The RVTR toolpath can be calculated based on the movement of the instantaneous center point \(O(\theta )\) along the guide line.

$$\begin{aligned} \left\{ {\begin{array}{*{20}{c}} {{X_c}(\theta ) = O{{(\theta )}_x} + R(\theta ) \cdot \sin \theta }\\ {{Y_c}(\theta ) = O{{(\theta )}_y} + R(\theta ) \cdot \cos \theta } \end{array}} \right. \end{aligned}$$
(9)

where \(\theta \) is the rotation angle of the trochoidal path around the center point, \(R(\theta )\) is the instantaneous radius of the trochoidal path:

$$\begin{aligned} R(\theta ) = ({R_1} - {R_{t}})(1 - \frac{\theta }{{2\pi }}) + ({R_2} - {R_{t}})(1 - \frac{\theta }{{2\pi }}) \end{aligned}$$
(10)

where \({R_1}\) , \({R_2}\) are the starting and ending center points of a single trochoidal cycle, respectively; \({R_{t}}\) is the tool radius. In addition, the step of the variable radius cycloid is variable every cycle, and the step of each cycle is determined according to the principle of constant cutting depth.

Fig. 7
figure 7

Coordinate system of robot milling system

Traditional toolpath planning methods for freeform surfaces involve performing operations directly in 3D space using cross-section methods, projection methods, or geodesic-based methods. However, these methods face the following challenges: (1) Complex 3D geometric operations require high computational power, and (2) controlling the modes and parameters of tool paths in 3D space can be difficult. To address these challenges, this work introduces a mesh parameterization method based on conformal mapping to enhance the performance of toolpath planning for freeform surfaces [31]. The detailed process of toolpath planning is illustrated in Fig. 6. First, the 3D mesh model of the freeform surface is mapped to a 2D mesh model using conformal mapping. Then, by calculating the MRR of the 3D mesh at the corresponding positions, the RVTR trajectory is inserted into the contour parallel trajectory within the 2D mesh model. Finally, toolpath planning for the freeform surface is achieved through parametric inverse mapping. By utilizing this method, the complexity of toolpath generation can be significantly reduced. Additionally, based on process requirements, it can be extended to incorporate various trajectory strategies in 2D space, such as spiral paths and fractal curve paths.

3 Robot stiffness matching and optimization

While the proposed machining toolpath in Section 2 ensures stable cutting forces, it may involve frequent changes in the feed direction and the direction of the cutting force. Previously, robot stiffness indicators were typically designed to address a specific force direction. However, given the frequent changes in force direction, there is a need for a new stiffness evaluation index and optimization method. There are two key issues to address: (1) Enhancing robot stiffness in regions with high Material Removal Rate (MRR). This can be achieved by leveraging the MRR prediction method proposed earlier. (2) Utilizing robot redundancy to achieve higher overall stiffness by dynamically adjusting robot posture changes over time. To enhance the performance of robot surface milling, this paper introduces a robot stiffness evaluation index that takes MRR matching into account. Additionally, the dynamic A* algorithm is employed to optimize the sequence of robot posture changes. This approach aims to improve robot surface milling performance by effectively managing stiffness and adapting to varying force directions.

3.1 Kinematics and redundancy of robotic surface machining

Figure 7 shows the robotic milling system in this work, including a KUKA industrial robot, an electrospindle, a milling tool, a worktable, and a workpiece. The robot base coordinate system {B} is set at the center of the robot base and is the world coordinate system. The robot end coordinate system {E} is charged at the center of the robot end flange. In addition, the electro-spindle and milling tool are mounted on the flange at the robot’s end through a fixture. The tool coordinate system {T} used for milling is defined at the tool center point, and it will be defined differently depending on the type of milling tool. The workpiece coordinate system {W} is determined at the origin of the workpiece model and should be fixed at an easily calibrated position. Generally speaking, the five-axis milling toolpath is defined in the workpiece coordinate system, including the tool position (CL) point \(\mathbf{{C}}{\mathbf{{L}}_w}\) , and the corresponding tool axis direction \({\mathbf{{D}}_w}\) . The tool location point \(\mathbf{{C}}{\mathbf{{L}}_b}\) and the tool axis direction vector \({\mathbf{{D}}_b}\) in the world coordinate system can be calculated by

$$\begin{aligned} \mathbf{{C}}{\mathbf{{L}}_b} = \mathbf{{T}}({x_w},{y_w},{z_w})\mathbf{{\textrm{M}}}({\alpha _w},{\beta _w},{\gamma _w})\mathbf{{C}}{\mathbf{{L}}_w} \end{aligned}$$
(11)
$$\begin{aligned} {\mathbf{{D}}_b} = \mathbf{{\textrm{M}}}({\alpha _w},{\beta _w},{\gamma _w}){\mathbf{{D}}_w} \end{aligned}$$
(12)

where \(\mathbf{{T}}({x_w},{y_w},{z_w})\) is the standard translation matrix along the vector \(({x_w},{y_w},{z_w})\) ; \(\mathbf{{\textrm{M}}}({\alpha _w},{\beta _w},{\gamma _w})\) is the rotation matrix for Euler angles of \(({\alpha _w},{\beta _w},{\gamma _w})\) . And

$$\begin{aligned} \mathbf{{\textrm{M}}}({\alpha _w},{\beta _w},{\gamma _w}) = {\mathbf{{R}}_z}({\gamma _w}){\mathbf{{R}}_y}({\beta _w}){\mathbf{{R}}_x}({\alpha _w}) \end{aligned}$$
(13)

where \({\mathbf{{R}}_x}({\alpha _w})\) is the rotation matrix of angle \({\alpha _w}\) around the x-axis; \({\mathbf{{R}}_y}({\beta _w})\) and \({\mathbf{{R}}_z}({\gamma _w})\) are defined similarly. As shown in Fig. 7, the position and the direction of the tool axis of the CL point in the five-axis machining are fixed, but to determine the CL point coordinate system {\(C{L_i}\)}, the angle of the redundant degrees of freedom of the robot is still missing. This redundancy is rotated around the tool axis vector, which corresponds to the rotation angle \({\gamma _t}\) of the redundancy of the robot. When the tool feeds along the machining toolpath, the {T} and the {\(C{L_i}\)} remain coincident. According to the parameters of the electric spindle and the tool, the transformation relationship \({}_E^B\mathbf{{T}}\) between the tool coordinate system and the robot end coordinate system can be determined, and the {E} can be determined. Then, the robot posture can be calculated through the robot’s inverse kinematics (IK) algorithm. Therefore, the robot pose at the determined CL point can be expressed as a function \({f_{pos}}({\gamma _t})\) of the redundancy angle \({\gamma _t}\).

3.2 The evaluation index of robot stiffness

Due to its insufficient rigidity, when the robot is subjected to a large cutting force during the milling process, obvious deformation errors will occur, resulting in a decrease in machining accuracy. For industrial robots, the force deformation error of the robot is mainly affected by the torsional stiffness of the gearbox and each joint drive shaft [32]. In robotic milling, the robot generally maintains good operability [33], so the most commonly used robot stiffness modeling method is the conventional stiffness model presented by [34]:

$$\begin{aligned} \mathbf{{K}} = {\mathbf{{J}}^{ - T}}{\mathbf{{K}}_\theta }{\mathbf{{J}}^{ - 1}} \end{aligned}$$
(14)
$$\begin{aligned} \mathbf{{C}} = {\mathbf{{K}}^{ - 1}} = \mathbf{{JK}}_\theta ^{ - 1}{\mathbf{{J}}^T} \end{aligned}$$
(15)

where \(\mathbf{{J}}\) is the Jacobian matrix of the robot. \(\mathbf{{C}}\) is the compliance matrix [35], which is the inverse of the stiffness matrix. By dividing the 66 matrix \(\mathbf{{C}}\) into four 33 sub-matrices, Eq. (13) could be written as

$$\begin{aligned} \left[ {\begin{array}{*{20}{c}} {{\mathbf{{\delta }}_{tran}}}\\ {{\mathbf{{\delta }}_{rot}}} \end{array}} \right] = \left[ {\begin{array}{*{20}{c}} {{\mathbf{{C}}_{tran}}}&{}{{\mathbf{{C}}_{cou}}}\\ {\mathbf{{C}}_{cou}^T}&{}{{\mathbf{{C}}_{rot}}} \end{array}} \right] \cdot \left[ {\begin{array}{*{20}{c}} {{\mathbf{{F}}_f}}\\ {{\mathbf{{M}}_t}} \end{array}} \right] \end{aligned}$$
(16)

where \({\mathbf{{\delta }}_{tran}}\) and \({\mathbf{{\delta }}_{rot}}\) represent the translational deformation of the EE and the rotational deformation of the EE, respectively. \({\mathbf{{F}}_f}\) is the force, while \({\mathbf{{M}}_t}\) is the torque applied to the EE. \({\mathbf{{C}}_{tran}}\) , \({\mathbf{{C}}_{rot}}\) and \({\mathbf{{C}}_{cou}}\) represent the force-translational compliance sub-matrix, torque-rotational compliance sub-matrix, and coupling compliance sub-matrix, respectively. In the author’s previous work [23], the joint stiffness matrix of the robot KUKA KR210 R2700 used in this paper has been identified, which is represented by a diagonal matrix, \({\mathbf{{K}}_\theta } = diag(1.892,2.887,3.242,0.101,0.138,0.128)\) (\(10^9\) Nmm/rad). In addition, the compliance coefficient of the robot in the surface normal direction (CCN) \({c_n}\) is proposed.

$$\begin{aligned} {c_n} = \mathbf{{e}}_n^T{\mathbf{{C}}_{tran}}{\mathbf{{e}}_n} \end{aligned}$$
(17)

where \({\mathbf{{e}}_n}\) represent the surface normal direction. In this evaluation index, only the influence of \({\mathbf{{C}}_{tran}}\) is considered. However, since the end effector is not coaxial with the robot end, and the force arm is long, the resulting torsion error of the robot end will cause a significant deformation of the CC point. The error of CL point caused by the EE error consists of two parts, which can be obtained by

$$\begin{aligned} {\mathbf{{\varepsilon }}_{cl}} = {\mathbf{{\delta }}_{tran}} + ( - \widehat{{\mathbf{{v}}_t}}){\mathbf{{\delta }}_{rot}} \end{aligned}$$
(18)

where \({\mathbf{{v}}_t} = {[{v_{tx}},{v_{ty}},{v_{tz}}]^T}\) represents the relative position vector between the robot flange and the robot EE in the end frame {E}, which is invariant during the machining process. \(\widehat{{\mathbf{{v}}_t}}\) is a skew-symmetric matrix deter-mined by the three components of \({\mathbf{{v}}_t}\) i.e.

$$\begin{aligned} \widehat{{\mathbf{{v}}_t}} = \left[ {\begin{array}{*{20}{c}} 0&{}{ - {v_{tz}}}&{}{{v_{ty}}}\\ {{v_{tz}}}&{}0&{}{ - {v_{tx}}}\\ { - {v_{ty}}}&{}{{v_{tx}}}&{}0 \end{array}} \right] \end{aligned}$$
(19)

Thus,the compliance coefficient and the stiffness index of the robot in the surface normal direction is corrected as

$$\begin{aligned} {c_n}\mathrm{{'}} = \mathbf{{e}}_n^T({\mathbf{{C}}_{tran}} - \widehat{{\mathbf{{v}}_t}}{} \mathbf{{C}}_{cou}^T){\mathbf{{e}}_n} = \mathbf{{e}}_n^T{\mathbf{{C}}_{tc}}{\mathbf{{e}}_n} \end{aligned}$$
(20)
$$\begin{aligned} {S_n} = \frac{1}{{{c_n}\mathrm{{'}}}} = \frac{1}{{\mathbf{{e}}_n^T{\mathbf{{C}}_{tc}}{\mathbf{{e}}_n}}} \end{aligned}$$
(21)

To evaluate the compatibility of the robot stiffness at the current machining position with the MRR, a stiffness matching index for surface milling is proposed:

$$\begin{aligned} {S_{match}} = \frac{{S_n}}{MRR_i} \end{aligned}$$
(22)

3.3 Optimization algorithm for robot posture

It can be seen from Section 3.2 that the stiffness evaluation index is a function of the robot posture, and at the determined CC point, it is a function \({S_n}({\gamma _t})\) of the redundant angle \({\gamma _t}\).

Previous methods for optimizing robot stiffness have either focused on an overall optimal redundant angle for all CC points or performed point-by-point optimization with constraints. However, these approaches have limitations. Fixed redundant angles may not maintain high stiffness, and starting from the posture with optimum stiffness may not guarantee optimal stiffness at each CC point due to kinematics constraints. This study proposes a method to optimize the redundant angle in a time series, considering collision, robot position/velocity, and singularity constraints. The goal is to achieve optimal stiffness by finding a suitable sequence of redundant angles that satisfies operational constraints while maximizing stiffness.

The constraints are constructed as follows:

  1. a)

    Collision-free constraint

Collision avoidance of robots usually uses the bounding box method to solve quickly. Suppose that each robot link is constructed as an oriented bounding box \({A_{ij}}\) , the workbench and parts in the positioner construct oriented bounding box a respectively \({A_p}\) and \({A_w}\) . Given the attitude combination, the total number of bounding box intersections is \({m_{all}}({\mathbf{{R}}_p},{\mathbf{{R}}_t},{\mathbf{{R}}_r})\) , determine whether the current attitude combination is feasible by judging the intersection:

$$\begin{aligned} {m_{all}} = \sum \nolimits _{i = 1}^n {m({A_{ij}},{A_p}) + m({A_{ij}},{A_w})} = 0 \end{aligned}$$
(23)

where \(m( \cdot )\) is the number of intersections of two bounding boxes, n represents the number of knife contacts, j=1,2,\(\dots \),6 is the number of connecting rods.

  1. b)

    Constraint of Manipulability

To improve the flexibility of the robot and avoid singularity, the manipulability index proposed in [36] is used here, which requires that the joints of the robot need to meet the following constraints:

$$\begin{aligned} \left\{ {\begin{array}{*{20}{c}} {{\kappa _{\max }} = \max ({\kappa _1},{\kappa _2},...,{\kappa _n}) \le {\kappa _0}}\\ {{\kappa _i} = \left\| {\mathbf{{J}}({\mathbf{{\theta }}_i})} \right\| \times \left\| {{\mathbf{{J}}^{ - 1}}({\mathbf{{\theta }}_i})} \right\| } \end{array}} \right. \end{aligned}$$
(24)

where \({\kappa _0}\) is the threshold value of the robotic manipulability. The robot joint coordinates are obtained by inverse kinematics solution according to the coordinates of the CL point in the world coordinate system:

$$\begin{aligned} {\mathbf{{\theta }}_i} = f_{ik}^{ - 1}(\mathbf{{cl}}_w^i) \end{aligned}$$
(25)
  1. c)

    Constraint of the Robot Joint

Robot kinematics constraints will limit the range of posture changes, which may lead to a situation where the desired posture cannot be reached. Therefore, in the process of posture optimization, the position constraints of robot joints should be considered

$$\begin{aligned} {\mathbf{{\theta }}_i} \in ({\mathbf{{\theta }}_{\min }},{\mathbf{{\theta }}_{\max }}) \end{aligned}$$
(26)

where \({\mathbf{{\theta }}_i} = {[{\theta _{i1}},{\theta _{i2}},{\theta _{i3}},{\theta _{i4}},{\theta _{i5}},{\theta _{i6}}]^T}\) represents the robot posture corresponding to the i-th CC point, that is, the joint angle. The rotation range of each joint of the robot \(({\mathbf{{\theta }}_{\min }},{\mathbf{{\theta }}_{\max }})\) can be obtained through official technical documents. Robot joints are also constrained by rotation speed:

$$\begin{aligned} \left| {{\mathbf{{\theta }}_i} - {\mathbf{{\theta }}_{i - 1}}} \right| \le \mathbf{{\omega }}\Delta t \end{aligned}$$
(27)

The maximum rotation speed of each joint \(\mathbf{{\omega }} = [{\dot{\theta }_1},{\dot{\theta }_2},{\dot{\theta }_3},\) \({\dot{\theta }_4},{\dot{\theta }_5},{\dot{\theta }_6}]^T\) can be obtained through official technical documents. \(\Delta t\) is the interval time between two adjacent discrete CC point, which can be calculated according to the feed speed and the distance between two points.

Fig. 8
figure 8

Graph structure for robot posture optimization

The optimization of the sequence of high-stiffness robot postures revolves around constructing a weighted directed graph data structure, denoted as G(V,E), for the candidate postures of the CC points as shown in Fig. 8. Each column represents a CC point, and the corresponding candidate point is a possible redundant angle. To improve the optimization effect, virtual start and end points are introduced, avoiding the impact of fixed start and end points. The weight between two vertices represents the reciprocal of the stiffness index of the robot at the latter candidate point. The alternative points must adhere to the constraints of collision-free, singularity-free, and robot joint limits. If a candidate point fails to meet the collision-free or singularity-free constraints, it is deleted. Similarly, if the joint change between two candidate points exceeds the robot’s speed constraint, they are not connected and the weight between them is considered infinite.

To obtain the optimal sequence of redundant angle changes for a robot with maximum stiffness while considering multiple constraints, this study utilizes the dynamic A* algorithm [37] on the graph data structure described earlier. The dynamic A* algorithm efficiently searches for the shortest path between the virtual start and end points, resulting in the robot posture sequence with the highest average stiffness. This algorithm only calculates the weights of necessary nodes during the path finding process, significantly reducing computation time. The specific details of the A* algorithm will not be discussed here, but its core lies in setting appropriate heuristic functions [38]. Figure 9 provides a schematic representation of the simulation effect of robot posture optimization.

Fig. 9
figure 9

The change of robot posture before and after optimization

Fig. 10
figure 10

Robot milling system, including the industrial robot, laser tracker, and milling force measurement system

4 Experiment

In this work, the milling platform is constructed based on the KR210 industrial robot and a workpiece positioner with a dual rotary axis, as shown in Fig. 10. The spindle mounted in the robot is ELTE TMA6 17/4 HSK-F63, and its maximum speed can reach 18000 rpm. In general, it is helpful to tilt the spindle axis concerning the last axis of the robot to avoid singularity. The material of the workpiece is 6061 aluminum alloy. The robot has been calibrated in advance according to the Ref. [39], reducing the influence of robot positioning ac-curacy on the experiment. As shown in Fig. 10, the laser tracker used for calibration in this work is API Radian. Besides, an API active target is used to measure the robot’s translational deformation and rotational deformation at one time. The force measuring system uses a quartz four-component dynamometer, Kistler 9257A, which can sample the cutting forces at a frequency of 2 kHz. In addition, optical 3D surface profiler of CHOTEST was used for surface quality detection, with a morphology repeatability accuracy of 0.1nm.

Fig. 11
figure 11

Experimental data of robot milling cases

4.1 Validation of the MRR simulation method

In order to demonstrate the effectiveness of the proposed MRR simulation method, a cutting experiment was conducted to compare the predicted MRR and the cutting force in robotic milling. A ball end milling cutter with a 6mm radius was used in the following cases. The feed speed was set to 1 mm/s, and the spindle speed was set to 9000 rpm.

In Case 1, the radial depth of cut (RDC) remained at 3mm, while the axial depth of cut (ADC) gradually increased from 3mm to 8mm. Figure 11(a, b) illustrates the MRR simulation and actual cutting force. It can be observed that the trend of the MRR is consistent with the change in cutting force, and variations in ADC result in proportional changes in the cutting force. In Case 2, the ADC remained at 3mm while the RDC varied from 3mm to 6mm and then back to 3mm. The MRR simulation and actual cutting force are shown in Fig. 11(c, d). When the cutting depth suddenly changes, there is significant fluctuation in the cutting force due to the uneven MRR. The change in RDC caused by the alteration in cutting force is not entirely proportional due to the influence of the tool shape, but it can be considered to have a strong linear relationship. In Case 3, the linear toolpath was processed three times at feed speeds of 1mm/s, 1.5mm/s, and 2mm/s with a constant depth of cut. As depicted in Fig. 11(e, f), when the speed remains constant, the cutting force remains stable, but an increase in speed leads to a non-proportional increase in cutting force. In Case 4, a contour parallel toolpath was employed to machine a surface, and the MRR and cutting force were tested, as shown in Fig. 11(g, h). The line spacing of the machining toolpath was set to 1.5mm, and the axial cutting depth was set to 2mm. The axial direction of the tool was always perpendicular to the clamping plane. This case did not consider the robot’s redundancy angle changes, and its angle remained fixed as a collision-free angle. It can be observed that the MRR fluctuates widely and changes frequently. The maximum MRR value reached 14.09 (\(\text {mm}^{3}/\text {s}\)). In this case, since the machining toolpath was processed from inside to outside, the innermost ring (C1 region in the figure) experienced full-edge cutting, resulting in the highest MRR. Conversely, the outermost ring (C3 region in the figure) had a relatively lower MRR due to less remaining material. The remaining areas (C2) accounted for the majority of the cutting time, and the MRR varied regularly as the toolpath transitioned from the common region to the critical region. It can be observed that there are obvious corresponding relationships between the C1-3 regions.

Fig. 12
figure 12

The change of robot stiffness along CC points

Fig. 13
figure 13

Experiment result: (a) MRR variation of the constant load toolpath; (b) Force variation of the contour parallel toolpath; (c) Force variation of the constant load toolpath;(d) Constant load milling toolpath of a freeform surface;(e) Surface quality at sampling points of the contour parallel toolpath; (f) Surface quality at sampling points of the constant load toolpath

4.2 Validation of the stiffness optimization results

To verify the effectiveness of the robot stiffness optimization method in Section 3.3 for the entire surface, simulation contrast experiments are conducted in this section. The toolpath shown in Fig. 4 is used in surface milling. The robot postures before optimization are determined according the default setting of the robot offline programming software, that is, the principle of keeping the redundant angle fixing. In addition, the direction of the tool axis is consistent with the normal direction of the surface in this method.

Figure 12 shows the distribution of robot stiffness as a function of robot posture and machining point motion. It can be seen that the stiffness matching index exhibits certain periodic characteristics as the machining points change, and gradually shortens. The reason is that the machining toolpath is a spiral motion from the outer ring to the inner ring, and the toolpath gradually becomes shorter. Among them, some small dark blue areas appear in the figure, which are caused by the constraint effect on this position and the inability to calculate the stiffness value. Before posture change sequence optimization, the rotation angle remains constant at 0 degrees, and at this point, the minimum stiffness matching index reaches 130.2 (\(N\cdot s/mm^4\)), while the average value is 372.5 (\(N\cdot s/mm^4\)). The maximum range of stiffness matching index that can be theoretically achieved is from 387.9(\(N\cdot s/mm^4\)) to 835.6(\(N\cdot s/mm^4\)), with an average of 566.2 (\(N\cdot s/mm^4\)). The green line indicates the change of robot posture along CC points after using redundant angle optimization. After posture change sequence optimization, the stiffness matching index value is range from 386.4 to 823.5 (\(N\cdot s/mm^4\)), while the average value is 532.3 (\(N\cdot s/mm^4\)). It can be observed that due to the constraints of robot motion, there is a minor difference between the optimized stiffness index and the maximum value that can be theoretically achieved. However, the optimization is considered effective as the values are very close.

Table 1 Cutting parameters for surface milling
Table 2 Cutting parameters for surface milling

4.3 Experimental validations of the optimization results

In this case, the constant milling load toolpath is used to carry out robot machining experiments on the same workpiece as in Section 4.1. First, according to the MRR simulation and threshold segmentation algorithm, the critical machining region of the workpiece is identified, and the optimal segmentation threshold is obtained as \((M_{thr}\)=8.03 (\(m{m^3}/s\)) . Then, based on the RVTR toolpath planning method, the trajectory fusion is carried out in the part of the contour parallel toolpath where the MRR exceeds the threshold \((M_{thr}\) to obtain the constant load milling toolpath, as shown in Fig. 13(a). It is worth noting that the force direction of the position where the trochoid toolpath is added changes quickly and periodically. Therefore, in the process of optimizing the robot posture at this time, the trochoid toolpath is considered as a whole in this work, and the posture optimization is not carried out internally. The posture change effect at this time is basically consistent with that without the trochoid toolpath added in Fig. 12.

According to the MRR simulation method, the MRR change of the constant load milling toolpath is obtained, as shown in Fig. 13(b). With the constant load toolpath, the MRR is well controlled, the average MRR is reduced to 6.03 (\(m{m^3}/s\)), and the maximum MRR is reduced to 9.71 (\(m{m^3}/s\)), which is 31.09\(\%\) lower than the contour parallel toolpath. In addition, the C1 region avoids full edge cutting, and by controlling the radial cutting depth of the RVTR toolpath, its MRR is consistent with that of the C2 region.

In the actual cutting experiments, the process parameters such as tool radius, line spacing, and axial cutting depth were set the same as in Section 4.1. However, when the feed speed of the contour parallel toolpath and the constant load toolpath are the same, the constant load toolpath consumes more time. Hence, this experiment compares the changes in cutting forces between the two methods by adjusting the speed of the contour parallel toolpath to ensure that the total processing time is the same for both methods. The cutting parameters are shown in Table 1. However, since the constant load toolpath and the contour parallel toolpath exhibit inconsistent cutting forces and feed time, it becomes difficult to intuitively compare their advantages and disadvantages. Therefore, in this experiment, the feed speed of the constant load toolpath is adjusted to match the total processing time of the contour parallel toolpath, and then the changes in cutting forces are compared. In actual processing, there are several factors that affect the processing time, including robot posture, robot joint velocity, and the connection form between two CL points, among others. Therefore, there may be slight differences in the actual processing time. As depicted in Fig. 13(c), it shows the distribution of the robot’s surface milling force, which was measured using a dynamometer. The maximum cutting force is 51.94 N, and the average cutting force is 11.90 N. It should be noted that the average value of the cutting force is relatively small due to the presence of CC points without cutting. As presented in Table 2 and Fig. 13(d), compared with the previous optimization case, the peak value of the cutting force is well controlled, and the fluctuation of the cutting force is significantly reduced. In the optimized case, the maximum cutting force is 35.29 N, and the average cutting force is 8.94 N, which is reduced by about 30\(\%\). It can be observed that the constant load toolpath planning method proposed in this study can decrease the maximum cutting force and improve machining quality while ensuring machining efficiency. Furthermore, if the maximum cutting force is taken as the limit, the method described in this study can be utilized for surface milling with higher efficiency. The machined surfaces before and after the optimization are shown in Fig. 14. Subsequently, we utilized a white light interferometer to examine the machining quality before and after optimization, as depicted in Fig. 13 (e, f). Due to the presence of residual height in milling, it can impact the measurement results of roughness. Hence, we conducted sampling measurements on the valleys of the milling traces, taking a total of 10 positions on the surface and averaging the values. As can be observed, the surface texture is not as prominent as before the optimization. This is due to the stable cutting force and improved rigidity, which reduced the vibrations during the robot machining process. The results revealed that after optimization, the Ra decreased from 0.710\(\mu m\) to 0.263\(\mu m\), and the Rz decreased from 3.599\(\mu m\) to 1.833\(\mu m\).

Fig. 14
figure 14

Machined surfaces of two optimization case

5 Conclusions

In robotic milling for freeform surfaces, cutting force and robot stiffness are essential factors affecting machining quality. A stable cutting force can improve efficiency, prolong tool life, and reduce vibration in robot surface milling. Additionally, enhancing robot stiffness can further improve its ability to resist cutting forces and enhance surface milling performance. This study proposes a method for constant load toolpath planning and stiffness-based robot posture optimization in robot freeform surface milling.

To begin, a new calculation method for MRR in surface milling is proposed based on the Dexel model. Subsequently, a constant load toolpath planning method for freeform surfaces is introduced. This method combines the conformal mapping algorithm, threshold segmentation algorithm, and RVTR toolpath based on the MRR simulation of the milling process. Furthermore, to further improve robot surface milling performance, an optimization model of robot stiffness matching, considering multiple constraints, is proposed. The model searches for the optimal sequence of robot posture changes using the dynamic A* algorithm. Simulation and experimental results demonstrate that the proposed method can improve robot stiffness, lower cutting load within the same processing time, and enhance surface processing quality.