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

Bad output when trajectory duration is 0 #91

Closed fricher closed 2 years ago

fricher commented 2 years ago

Hi @pantor, is it undefined behavior to have the target state equal to the current state ? As you can see in the example below, out.new_position is completely wrong:

inp.control_interface = ruckig::ControlInterface::Position

inp.current_position = [0, -1.570796326794897, 1.570796326794897, 0, 1.570796326794897, 0]
inp.current_velocity = [0, 0, 0, 0, 0, 0]
inp.current_acceleration = [0, 0, 0, 0, 0, 0]
inp.target_position = [0, -1.570796326794897, 1.570796326794897, 0, 1.570796326794897, 0]
inp.target_velocity = [0, 0, 0, 0, 0, 0]
inp.target_acceleration = [0, 0, 0, 0, 0, 0]
inp.max_velocity = [0.1745329251994329, 0.1745329251994329, 0.1745329251994329, 0.1745329251994329, 0.1745329251994329, 0.1745329251994329]
inp.max_acceleration = [0.1745329251994329, 0.1745329251994329, 0.1745329251994329, 0.1745329251994329, 0.1745329251994329, 0.1745329251994329]
inp.max_jerk = [4, 4, 4, 4, 4, 4]

out.new_position = [0, 0, 0, 0, 5.048362769205857e-319, 0]
out.new_velocity = [0, 0, 0, 0, 4.881566207169852e-319, 0]
out.new_acceleration = [0, 0, 0, 0, 4.693821261750179e-319, 0]
out.time = [0.04]
out.calculation_duration = [6.908]

ruckig.validate_input returns true for this input.

Thanks for your help !

pantor commented 2 years ago

This bug should now be fixed by the latest commit. Thanks for catching this!