Location

The script is located in project_root/Optimization scripts

  • Coefficient_Calculator.m: Execute the optimization for X, Y, PITCH and ROLL

This MATLAB script computes the coefficients for error equations used to further compensate for the inverse kinematics error estimations. The script reads simulation results, calculates the errors, and then uses optimization techniques to find the best coefficients for error compensation functions.

Script's description

Steps Performed by the Script

  1. Initialization:

    • scriptFullPath, scriptFolder: Determine the full path and folder of the current script.
    • relativePath, fullPath: Define and construct the full path to the results CSV file. This is usually stored in project_root/Results
  2. Read Simulation Results:

    • Load the simulation results from the CSV file compensation_1.csv into a table sim_res.
  3. Compute Errors:

    • Calculate the error between the desired and measured values for each degree of freedom (x, y, pitch, roll, yaw) and store these in new columns in sim_res.
  4. Optimization for y Error Compensation:

    • Define an anonymous function fun that calculates the error for the y compensation function.
    • Initialize the optimization parameters params0.
    • Set optimization options for display, plotting, and tolerances.
    • Use fminsearch to find the best coefficients best_coeff_y for the y error compensation function.
    • Display the optimized mean square error for y.
  5. Error Estimation Check for y:

    • Iterate through each row of space_array.
    • Calculate and display the real and estimated errors for y using the optimized coefficients best_coeff_y.
  6. Optimization for x, yaw, and pitch Error Compensation:

    • Similar steps as for y are repeated for x, yaw, and pitch:
      • Define the anonymous function fun for each DOF.
      • Initialize the optimization parameters params0.
      • Set optimization options.
      • Use fminsearch to find the best coefficients for each DOF (best_coeff_x, best_coeff_yaw, best_coeff_pitch).

Explanation of Key Parts

  • Error Calculation: The script calculates the difference between the desired and measured positions/orientations to quantify the inverse kinematics errors.

  • Optimization: The fminsearch function is used to minimize the error function, which is defined as the difference between the real errors and the estimated errors based on the current coefficients. The optimization process iterates to find the best coefficients that minimize this difference.

  • Error Estimation: After finding the best coefficients, the script checks the accuracy of the error estimation by comparing the real and estimated errors for each configuration in space_array.

  • No labels