This MATLAB script trains feedforward neural networks to model the direct and inverse kinematics of a system. The script uses a large dataset of random actuator positions and corresponding quadrupole positions/orientations to train the networks. The trained models are then saved for later use.

Location

The script is located in project_root/NN_inverse_kin

  • NN_training.m: Execute the training

Script's description

  1. Initialization:

    • The script begins by clearing all variables and determining the full path of the current script.
    • Paths for the dataset and specific filenames are defined.
    • Dates for the training and test datasets are specified.
  2. Data Loading:

    • The script lists all files in the dataset directory and filters out those that are not directories.
    • It then loads the specified training and test data files for both joint and actuator positions.
  3. Data Preparation:

    • The script calculates the size of the training and test datasets.
    • It pre-allocates arrays for storing the training and test data.
    • Data from the loaded files is then populated into these arrays.
  4. Training Parameters:

    • The script specifies the training parameters, including the training function, data division ratios, and number of epochs.
    • The chosen training function is Bayesian Regularization (trainbr), which is suitable for challenging problems.
  5. Training the Direct Kinematics Network:

    • The training data is transposed to match the expected input format for the neural network.
    • A fitting network (fitnet) is created with the specified hidden layer size and training function.
    • The network's data division parameters are set for training, validation, and testing.
    • The network is trained using the training data, and its performance is evaluated.
    • The trained network is saved with a filename that includes the current date and performance.
  6. Training the Inverse Kinematics Network:

    • The roles of input and target data are swapped for training the inverse kinematics network.
    • Similar to the direct kinematics, a fitting network is created and trained.
    • The performance of the trained inverse kinematics network is evaluated.
    • The trained network is saved with a filename that includes the current date and performance.

This script automates the process of training feedforward neural networks to model the direct and inverse kinematics of a system using a large dataset of random positions. The main steps include initializing parameters, loading and preparing data, training the networks, evaluating their performance, and saving the trained models for future use.

Neural network description

Neural Network Type: Feedforward Neural Network (FNN)

A feedforward neural network (FNN) is an artificial neural network where connections between the nodes do not form a cycle. It is a straightforward type of neural network primarily used for pattern recognition and regression tasks. In this script, we use a feedforward neural network to model both the direct and inverse kinematics of a system.

Why Feedforward Neural Networks?

Feedforward neural networks are suitable for this application because they possess the universal approximation property, meaning they can approximate a wide variety of functions given sufficient data and network complexity. This makes them ideal for modeling the complex, nonlinear relationships inherent in kinematic systems. FNNs are flexible and adaptable, capable of learning from large datasets and adjusting to various input-output mappings, which is essential for capturing the nuanced behaviors of the system's kinematics.

In terms of computational efficiency, FNNs are advantageous once trained, as they provide real-time predictions. This is crucial for applications requiring fast and responsive kinematic calculations. Moreover, FNNs' compatibility with large datasets enables them to improve their predictive accuracy by leveraging extensive simulated data, allowing the network to learn the intricate details of the system’s kinematics.

Network Architecture

The feedforward neural network used in this application consists of the following layers:

  1. Input Layer: This layer receives the input data. For direct kinematics, the input is the actuator positions, and for inverse kinematics, the input is the quadrupole position and orientation.
  2. Hidden Layer(s): The network has one hidden layer consisting of 40 neurons. The hidden layer is responsible for capturing the complex relationships between inputs and outputs. The number of neurons in the hidden layer is chosen based on the complexity of the problem and the amount of data available.
  3. Output Layer: This layer produces the output data. For direct kinematics, the output is the quadrupole position and orientation, and for inverse kinematics, the output is the actuator positions.

Application to Kinematics

For direct kinematics, the objective is to predict the quadrupole position and orientation from given actuator positions. The input consists of actuator positions (joint positions), and the output is the quadrupole position and orientation (simulated results). The direct kinematics problem involves mapping the joint space to the task space, a task well-suited for regression problems handled by FNNs.

For inverse kinematics, the goal is to predict the actuator positions needed to achieve a desired quadrupole position and orientation. The input in this case is the quadrupole position and orientation, while the output is the actuator positions. The inverse kinematics problem involves mapping the task space back to the joint space, another regression task that benefits from the capabilities of FNNs.

In summary, the feedforward neural network is an appropriate choice for modeling the kinematics of this system due to its ability to handle complex, nonlinear mappings, its adaptability to large datasets, and its computational efficiency in providing real-time predictions. These characteristics make FNNs well-suited for both direct and inverse kinematics modeling in this application.

The training converged very rapidly (10 mins) 

The network architecture


  • No labels