Inverse kinematics and retargeting with frax.ik
frax.ik is a differential IK library, akin to mink and pink, but faster, compatible with automatic differentiation, and with more reliable constraint enforcement.
frax.ik is great for both online and offline IK problems. For example, applications include:
- Online: Real-time (>1,000 Hz) velocity control of robot manipulators, online teleoperation and retargeting of humanoid robots
- Offline: Batch processing and retargeting of trajectories and human motion data (>100,000 Hz)
frax.ik uses ElastiQP as the underlying QP solver for each differential IK step. This solver is always feasible, in the sense that it adds an (implicit) l1 relaxation on every inequality constraint. Check out the paper for more details!
Examples
[!NOTE] Remember to install from source with the
[examples]dependencies:pip install -e ".[examples]"
Humanoid Retargeting
frax.ik can churn through retargeting problems at extreme speeds (>100,000 FPS). For comparison, GMR's stated number is 70 FPS (on a threadripper, too).
LAFAN1: Retarget the entire dataset in 4 seconds on CPU:
LAFAN1 is a great place to get started with humanoid retargeting. The dataset (CC BY-NC-ND 4.0) is around 150 MB in size, and frax.ik processes it quickly (at over 100,000 FPS)
# If you haven't downloaded the dataset yet:
# python examples/ik/lafan1/download.py
python examples/ik/lafan1/retarget.py
(Timing numbers are from a i9-14900KF CPU. If you add the --self-collision-avoidance flag, it takes around 7 seconds. On my i7 laptop, it takes around 10 seconds)
Once that's done, run the following to take a look at the retargeted results in a viser viewer!
python examples/ik/lafan1/view.py
BONES-SEED
To fetch the data for BONES-SEED, you'll need to first agree to some terms and conditions: see the HuggingFace page for more details and instructions.
This dataset is significantly larger than LAFAN1 (>100 GB!), and it is a much higher framerate. Processing the full set takes roughly 1 hour on my desktop. If you've got the storage space on your computer, and don't mind a short wait, download the dataset and then run the following:
python examples/ik/bones_seed/retarget.py
As with the LAFAN1 demo, we have a script to show the results in a viser viewer:
python examples/ik/bones_seed/view.py
Currently, all humanoid examples are configured to use the Unitree G1, which is built-in to frax. If you would like to use a new robot, you'll need a URDF and a collision model: see our other docs for more details.
General IK problems
The best place to get started with frax.ik is in examples/ik/panda_interactive.py. Check out this file for a quick-start guide to how to define a set of IK tasks and constraints, and run the script to open up an interactive viewer for end-effector tracking!
python examples/ik/panda_interactive.py
Another interactive example is available in examples/ik/a2_interactive.py (quadruped IK with adjustable base pose and feet positions)
python examples/ik/a2_interactive.py
We also have a collision avoidance demo where a Panda tracks a pre-set trajectory and we enforce collision avoidance to an (interactive) external obstacle:
python examples/ik/panda_obstacle.py
For a more advanced example, we have a demo of how to set up a global IK problem with multiple samples parallelized across CPU devices:
python examples/ik/parallel_global_ik.py