kinematic_prediction.py
Last modified: 2023-07-15
View on GitHubThis file contains functions for kinematic prediction in the RoboX system.
Main Flow Diagram
Explanation | Code |
---|---|
Ensure x and y have the same shape |
|
Ensure there are enough points for the chosen model degree |
|
Create the Vandermonde matrix |
|
Each column represents x raised to powers from 0 to model_degree |
|
Transpose of x_mat for matrix calculations |
|
Standard least squares regression |
|
Calculate coefficients using the normal equation: (X^T * X)^-1 * X^T * y |
|
Weighted least squares regression |
|
Create diagonal weight matrix |
|
Calculate coefficients using the weighted normal equation: |
|
(X^T * W * X)^-1 * X^T * W * y |
|
Create array of powers of predict_x for polynomial evaluation |
|
Evaluate the polynomial at predict_x using dot product |
|
Test the poly_predict function |
|
Perform a linear prediction (model_degree=1) at x=4.0 |
|