pantor / ruckig

Motion Generation for Robots and Machines. Real-time. Jerk-constrained. Time-optimal.
https://ruckig.com
MIT License
728 stars 164 forks source link

Multi-DoF Ruckig produces zero outputs when the target position is very far #201

Closed Walid-Rovo closed 2 months ago

Walid-Rovo commented 2 months ago

When the difference between the values of InputParameter().current_position and InputParameter().target_position is large enough, Ruckig outputs zero new_ positions and velocities. This only occurs for DoF 2 (and perhaps with more DoFs too).

Test code:

from ruckig import Ruckig, InputParameter, OutputParameter

for target_position in range(1, int(1e6)):
    ruckig_otg = Ruckig(2, 0.01)
    ruckig_inp = InputParameter(2)
    ruckig_out = OutputParameter(2)

    ruckig_inp.max_velocity = [1.0, 1.0]
    ruckig_inp.max_acceleration = [1.0, 1.0]
    ruckig_inp.max_jerk = [1.0, 1.0]

    ruckig_inp.current_position = [0.0, 0.0]
    ruckig_inp.target_position = [target_position, target_position]
    ruckig_otg.update(ruckig_inp, ruckig_out)
    p0, p1 = ruckig_out.new_position
    v0, v1 = ruckig_out.new_velocity
    if v0 <= 1e-16:
        print(f"Hit bug at {target_position = }"
              f"\n{v0, v1 = }"
              f"\n{p0, p1 = }"
              )
        break

Output:

Hit bug at target_position = 7599
v0, v1 = (0.0, 0.0)
p0, p1 = (0.0, 0.0)

Nothing seems special about the output values close to 7599, so the change is adrupt.

Library installed from pip, version 1.1.1.

pantor commented 2 months ago

Please check the Result return type of the update method and take a look at the numerical limits section in the readme. Ruckig does have an upper bound of the trajectory duration.

Walid-Rovo commented 2 months ago

Very well, thank you!