As widely analyzed, the approximations made in the simple inverse kinematics solution are not accurate enough to meet the requirements for the SCU (Superconducting Undulator).

To enhance the overall accuracy of the solution, two approaches are followed:

Error function

This approach aims to improve the accuracy of the inverse kinematics (IK) by identifying an error function that models the IK errors as a function of the quadrupole orientation and position. By determining this ideal function for all degrees of freedom, we can apply corrections to the IK solution, thereby increasing its accuracy.

Concept

  1. Error Mapping:

    • Map the joint space at specific positions.

    • Compute the error between the actual quadrupole position and the desired position.

  2. Multidimensional Matrix:

    • For each degree of freedom (DOF), create a multidimensional matrix of size m×n×u×v×w where:

      • m is the number of sampled positions on the x-axis.

      • n is the number of sampled positions on the y-axis.

      • u, v, and ware the number of sampled positions for pitch, roll, and yaw, respectively.

  3. Optimization:

    • Execute an optimization algorithm to find the coefficients of an arbitrarily defined error function that minimizes the error function's error.

Implementation Steps

  1. Initialization:

    • Define simulation parameters and geometric properties.
    • Set test positions for all DOFs.
  2. Simulation Loop:

    • Iterate over all combinations of test positions.
    • For each combination, solve the inverse kinematics.
    • Run the simulation model and capture the output.
    • Calculate the average positions and orientations.
    • Store the results for analysis.
  3. Optimization:

    • Use the collected data to optimize the error function.
    • Apply the optimized error function to correct the IK solution.

This algorithm is repeated two times: one to find an error function that corrects for X and Y and then a final one that computes the fine error for pitch roll and yaw.

Sequence

The sequence of the scripts to execute is:

Feedforward neural network

The previously employed error function approach used an optimization algorithm to find the coefficients of a predefined polynomial equation that minimized the prediction error. While effective and compatible with requirements, this method struggled to model all small nonlinearities present in the system, particularly in real-world applications.

To address the limitations of the polynomial approach, the idea is to use a feedforward neural network to learn both the direct and inverse kinematics of the system. This method leverages a large dataset of random actuator positions and corresponding quadrupole positions/orientations to train the neural network.

Procedure

  1. Data Generation:

    • Randomly generate a large set of actuator positions within their stroke limits.
    • Explore the entire configuration space using a Monte Carlo method to sample the whole reachable space.
  2. Data Collection:

    • Position all actuators at each specific configuration.
    • Measure the position and orientation of the quadrupole, either in simulation or using an interferometer for the real system.
    • Repeat this process for all N configurations to build a comprehensive dataset.
  3. Neural Network Training:

    • Use the collected dataset to train a feedforward neural network.
    • Train two models: one for direct kinematics (actuator positions to quadrupole position/orientation) and one for inverse kinematics (quadrupole position/orientation to actuator positions).
  4. Runtime Application:

    • Load the trained neural network models.
    • Use the models at runtime based on the specific necessity: direct kinematics for determining the quadrupole position/orientation from actuator positions, and inverse kinematics for determining actuator positions from the desired quadrupole position/orientation.

Benefits

  • Nonlinearity Handling: Neural networks excel at modeling complex, nonlinear relationships, improving accuracy over polynomial methods.
  • Adaptability: The model can be retrained with new data to adapt to changes in the system or environment.
  • Efficiency: Once trained, neural networks can provide real-time predictions, crucial for dynamic applications.

By employing feedforward neural networks, the system can achieve higher accuracy in modeling both direct and inverse kinematics, effectively handling the nonlinearities present in real-world scenarios. This approach not only meets the requirements but also offers flexibility and adaptability for future system modifications.

Sequence

The sequence of the scripts to execute is:

  • NN data generator: This script generates the dataset used in during the training phase
  • NN training: This scripts trains both networks (direct and inverse kin) for the selected datasets
  • Space explorer NN: This script explore the space and computes the inverse kinematics error as for the previous approach

Comparison

Both approaches solve the problem of computing an accurate inverse kinematic function. However, there is a winner in terms of simplicity, flexibility and generality. But first let's have a look at the results 

image-2024-6-21_10-10-6.pngError function correction

The first plot represents the error for the quadrupole position (X and Y) computed with the analytical solution of the inverse kinematics, the second represents the same error but with inverse kinematics based on the optimized error function and, finally, the third one is the one based on the feedforward neural network

image-2024-6-21_10-10-55.pngimage-2024-6-21_15-14-4.png

These plots are the same as before except for the fact that these represent the orientation errors.

Both the error function optimization and the feedforward NN show almost the same performances for the position while, on the orientation side, the feedforward nn outperforms if compared with the other.

For this reason and for the fact is capable of modeling uncaught behavior defined in the function error, the Feedforward NN is the favourite approach to solve this problem.


  • No labels