Since July of this year, I developed a Rust-based kinematics solver. I named it galaw, which is Tagalog for ‘motion’ or ‘movement’.
This was inspired by my master’s thesis work on developing a sampling-based retargeter to control humanoid robot hands. Because it was sampling based, I needed to compute forward kinematics (FK) of a robot fast. Really fast. Using JAX and MJX MuJoCo with an RTX 4090, I was able to make it work and have the algorithm run under 4ms. But this required a GPU. I wanted to see if I can make this work on a CPU.
The core principle of galaw is that kinematic computation is treated as a pure function: same inputs, same outputs, no hidden states. This opens the door to trivial parallelism, important for robotics nowadays. Building on this idea, I developed two APIs:
- galaw-runtime: parse any URDF/MJCF file at runtime for maximum flexibility
- galaw-generated: ahead-of-time code generated for a single robot for maximum performance.
I benchmarked this against C++ Pinocchio and k (a Rust kinematics crate) on four robots, CPU single-threaded (Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz). galaw comes out on top against both. The numbers below are the geometric mean across the robots, with the per-robot range in parentheses. Note that galaw-generated is specialized to one robot at compile time, so galaw-runtime is the fairer comparison. Also note that Pinocchio doesn’t come with a native IK solver, so IK was only compared against k, and the two solvers are different, so take the IK numbers as rough.
vs Pinocchio (C++)
| Operation | galaw-runtime | galaw-generated |
|---|
| FK | ~2.0× (1.6-2.5) | ~4.7× (3.5-6.3) |
| Jacobian | ~1.6× (1.5-1.7) | ~2.9× (2.0-4.5) |
vs k (Rust)
| Operation | galaw-runtime | galaw-generated |
|---|
| FK | ~3.7× (3.2-4.3) | ~8.9× (5.5-13.2) |
| Jacobian | ~22.6× (15.0-39.0) | ~41.4× (18.8-83.3) |
| IK | ~5.5× (1.3-26.3) | ~11.0× (3.1-45.9) |
Right now, this is at v0.4.0 and is in active development. I’m still building my way towards using this on a retargeting algorithm, but wanted to share this to the community. More features are on their way! If you find it interesting or useful, share and even join in!
🦀 crates.io: crates.io/crates/galaw
💻 GitHub: github.com/RobJMal/galaw