Ruckig

raw JSON →
0.17.3 verified Fri May 01 auth: no python

Ruckig is a real-time motion generation library for robots and machines, providing instantaneous trajectory generation for up to 7 degrees of freedom. Current version 0.17.3, requires Python >=3.9. Released under the MIT license, with active development on GitHub.

pip install ruckig
error ImportError: cannot import name 'Ruckig' from 'ruckig'
cause Trying to import Ruckig directly with `import Ruckig` instead of `from ruckig import Ruckig`.
fix
Use from ruckig import Ruckig.
error TypeError: __init__() missing 1 required positional argument: 'dofs'
cause Creating a Ruckig instance without specifying the number of degrees of freedom.
fix
Pass DOF as an integer: Ruckig(1) for single-degree-of-freedom.
error ValueError: The input parameter vector size does not match the DOFs.
cause Setting a field (e.g., `current_position`) with a list of wrong length or a scalar.
fix
Ensure all field lists have length equal to DOF. For 1 DOF, use [value].
breaking In version 0.17.0, the method `calculate` now returns a `Result` enum instead of a boolean. Code checking for `True`/`False` will break.
fix Check for `Result.Working` or `Result.Finished` (see docs). For a quick fix, use `bool(result == Result.Working)` if you need a boolean.
deprecated The `Ruckig.set_max_*` methods are deprecated as of 0.17.0. Set limits directly via `InputParameter.max_velocity`, etc.
fix Replace `otg.set_max_velocity(1.0)` with `inp.max_velocity = [1.0]`.
gotcha All position, velocity, acceleration, and limit fields must be lists of floats (even for 1 DOF). Passing a scalar will raise an error.
fix Wrap scalars in a list: `inp.current_position = [0.0]`.
gotcha The first call to `calculate` often returns `Result.Working` even if the trajectory is trivial. You must call `calculate` repeatedly until it returns `Result.Finished`.
fix Use a loop: while (result := otg.calculate(inp, out)) == Result.Working: pass, or use an iterator.
breaking Python 3.8 support dropped in version 0.16.0.
fix Upgrade to Python >=3.9.

Basic example of generating a 1-DOF trajectory from current state to target.

from ruckig import Ruckig, InputParameter, OutputParameter, Result

# Create Ruckig instance (DOF=1)
otg = Ruckig(1)

# Set input parameters
inp = InputParameter(1)
inp.current_position = [0.0]
inp.current_velocity = [0.0]
inp.current_acceleration = [0.0]
inp.target_position = [1.0]
inp.target_velocity = [0.0]
inp.target_acceleration = [0.0]
inp.max_velocity = [1.0]
inp.max_acceleration = [1.0]
inp.max_jerk = [10.0]

out = OutputParameter(1)

result = otg.calculate(inp, out)
if result == Result.Working:
    print('Trajectory generated: {} steps'.format(out.trajectory.duration))
elif result == Result.Finished:
    print('Already at target.')
else:
    print('Invalid input.')