Skip to content
dee6600Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NN-Ikine: Neural-Network Inverse Kinematics for 3-DOF Arms

Can a neural network learn a robot arm's inverse kinematics (IK) by copying a numerical solver? This repo has the original project (MATLAB Robotics Toolbox + Keras) for two textbook 3-DOF arms, plus a follow-up technical report that checks how well it actually works and what fixes it.

Short answer: the baseline network looks good on paper (74% Keras "accuracy") but its hand lands a median of ~4% of the arm's reach from the target, and misses by more than half the reach on the worst 5% of targets. Most of that error comes from the training labels, not the network. With consistent, exact labels and a sine/cosine output, the same network is 43Γ— more accurate at the median and ~200Γ— more accurate on the hardest targets. Used as a warm start, it cuts the numerical solver's iterations by 3.5Γ— and always returns the intended solution.

πŸ“„ Paper: paper/main.pdf (IEEE two-column) Β· paper/main_long.pdf (10-page extended version) 🎞️ Original project: slides Β· video demo Β· course write-up


The robots

Arm Joints Notes
RRR (anthropomorphic) base yaw θ₁, shoulder ΞΈβ‚‚, elbow θ₃ aβ‚‚ = a₃ = 10 LU, reach 20 LU, up to 4 IK solutions per target
RPP (cylindrical) base yaw θ₁, vertical lift dβ‚‚, radial reach d₃ one solution per target, ~200 LU workspace

Both arms have closed-form IK, which makes them a clean testbed: every network answer can be checked against the exact solution.

Pipeline

 offline:  random targets ──► ikine (LM, ≀1000 iters) ──► (x,y,z) β†’ (q1,q2,q3) dataset ──► Keras MLP ──► model/*.h5
 online:   target [x y z] ──┬─► ikine ────────────► animate()
                            └─► MLP (via Python) ──► animate()   β†’ compare poses

Results

Baseline (original 2021 models)

Model Arm Keras acc. Median error p95 error Within 1 LU
model20000_rrr (test) RRR 74.1% 0.78 LU 10.92 LU 61.6%
model20000_rrr (train) RRR 97.3% 0.50 LU 2.14 LU 82.5%
model8000_rpp_rad (test) RPP 99.9% 2.11 LU 7.70 LU β€”

Keras's default 'accuracy' only checks which of the three outputs is largest, so it says almost nothing about IK error. One RPP model scores 91.4% while missing by a median of 148 LU.

Error CDF of the baseline RRR network and median error vs. target distance

Why it fails, and what fixes it

  • Inconsistent labels. ikine starts from all-zero joints and picks whichever of the four RRR solutions it converges to, so neighbouring targets get different solution types. The network ends up averaging them.
  • Unwrapped angles. The solver reports ΞΈ and ΞΈ + 2Ο€ as different answers.
  • Sampling bug. The RPP generator drew x from [0, 2Ο€] (an angle range), so the training data covers only ~14% of the base rotation.

Controlled study on the RRR arm (same network and inputs, only the labels and output format change):

Ablation over label types and scaling with dataset size

Median p95 Notes
Solver labels (baseline) 1.94 LU 21.9 LU p95 exceeds the arm's reach
Consistent exact labels, (cos, sin) output 0.045 LU 0.11 LU 43Γ— / 199Γ— better
Same, 30k samples 0.032 LU 0.068 LU 99.1% within 0.1 LU, 42% fewer params

Learned warm start for the solver

Starting guess for LM ikine Mean iterations Intended solution
All zeros (default) 15.8 39.5%
Baseline network 6.2 39.7%
Improved network 4.5 100%

Repository layout

.
β”œβ”€β”€ run_project/            # Ready-to-run demo: MATLAB scripts + trained models
β”‚   β”œβ”€β”€ rrr_3_link_toolbox.m    RRR IK with Robotics Toolbox ikine + animation
β”‚   β”œβ”€β”€ rrr_3_link_NN.m         RRR IK with the neural network (calls py_rrr.py)
β”‚   β”œβ”€β”€ rpp_toolbox.m           RPP IK with ikine + animation
β”‚   β”œβ”€β”€ rpp_NN.m                RPP IK with the neural network (calls py_rpp.py)
β”‚   β”œβ”€β”€ py_rrr.py, py_rpp.py    Keras inference bridges
β”‚   β”œβ”€β”€ model/                  Trained Keras .h5 models
β”‚   └── dataset/                MATLAB ↔ Python exchange files
β”œβ”€β”€ devlopment_project/     # Data generation, training, all trained checkpoints
β”‚   β”œβ”€β”€ gen.m, gen_rpp.m        Build datasets by running ikine on random targets
β”‚   β”œβ”€β”€ train.py                Train the Keras MLP
β”‚   β”œβ”€β”€ inferance.py            Ad-hoc predictions
β”‚   β”œβ”€β”€ train*.csv              Generated datasets
β”‚   └── model/                  All 7 trained models
β”œβ”€β”€ paper/                  # Technical report: analysis + improvements
β”‚   β”œβ”€β”€ main.tex, refs.bib      LaTeX source (IEEEtran)
β”‚   β”œβ”€β”€ code/                   Audit, controlled study, figures, tables (PyTorch/NumPy)
β”‚   β”œβ”€β”€ results/                Raw results (JSON / NPZ) and the improved model
β”‚   β”œβ”€β”€ figures/, tables/       Generated from results/
β”‚   └── README.md               Reproduction details
β”œβ”€β”€ Project_Presentaion.pdf # Original course presentation
└── VIDEO DEMONSTRATION.mp4 # Demo of both arms animating

Quick start

1. Run the original MATLAB demo

Requirements: MATLAB with Peter Corke's Robotics Toolbox, and Python 3 with numpy pandas scikit-learn tensorflow keras on your PATH.

cd run_project
rrr_3_link_toolbox   % enter [x y z], e.g. [1 4 9]; the arm animates to the ikine solution
rrr_3_link_NN        % same target, solved by the neural network
rpp_toolbox
rpp_NN

2. Reproduce the paper

No MATLAB or TensorFlow needed: ikcore.py includes a Python replica of ikine and reads the Keras weights straight from the .h5 files.

cd paper
python3 -m venv venv && venv/bin/pip install h5py numpy pandas scipy scikit-learn matplotlib torch
cd code
../venv/bin/python audit.py        # Part I: dataset audit + re-evaluation of all shipped models (~30 s)
../venv/bin/python improved.py     # Part II: controlled study, scaling, warm start, latency (~45 min on M1 Pro CPU)
../venv/bin/python figures.py && ../venv/bin/python make_tables.py
cd .. && tectonic --keep-intermediates main.tex

See paper/README.md for details.

Author

Durgesh S. Reddiyar (dreddiya@asu.edu). Originally built for MAE 547 Modeling and Control of Robots, Arizona State University, Fall 2021.

Citation

@techreport{reddiyar2026nnik,
  author      = {Durgesh S. Reddiyar},
  title       = {Learning Inverse Kinematics by Imitating a Numerical Solver:
                 Analysis and Improvements on Two 3-DOF Manipulators},
  institution = {Arizona State University},
  year        = {2026}
}

License

MIT

References

  • P. Corke, Robotics, Vision and Control, Springer. Robotics Toolbox for MATLAB.
  • B. Siciliano, L. Sciavicco, L. Villani, G. Oriolo, Robotics: Modelling, Planning and Control, Springer, 2009.
  • M. I. Jordan and D. E. Rumelhart, "Forward models: Supervised learning with a distal teacher," Cognitive Science, 1992.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages