pantor / ruckig

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

ErrorSynchronizationCalculation error #129

Open fricher opened 2 years ago

fricher commented 2 years ago

Hello @pantor , ruckig fails to compute a trajectory from these parameters:

const double cycle_time = .004;

ruckig::Ruckig<6,true> ruckig(cycle_time);
ruckig::InputParameter<6> inp;
ruckig::Trajectory<6> traj;

inp.control_interface = ruckig::ControlInterface::Position;
inp.synchronization = ruckig::Synchronization::Phase;
inp.duration_discretization = ruckig::DurationDiscretization::Continuous;
inp.current_position = {1.635923973038584, -0.02664577603159074, 1.398772409994243, 0.7204359129215889, 0.7531949879258638, -0.3527181789404736};
inp.current_velocity = {0.5997002460539949, 0.657823987334049, 0.6544488698370342, 0.6534667437575569, 0.6578239873340388, 0.6578239873340486};
inp.current_acceleration = {-2.111156774102785, -4.363323129985824, -3.853477374887802, -4.32029086362776, -4.363323129985824, -4.363323129985824};
inp.target_position = {1.6863294690542, 0.02475975543627795, 1.450144052898067, 0.7716208457168268, 0.8046005193937291, -0.301312647472602};
std::ranges::fill(inp.target_velocity, 0);
std::ranges::fill(inp.target_acceleration, 0);
inp.target_velocity = {0, 0, 0, 0, 0, 0};
inp.max_velocity = {5.235987755982989, 3.926990816987241, 3.926990816987241, 6.649704450098396, 5.427973973702365, 8.587019919812102};
inp.max_acceleration = {4.363323129985824, 4.363323129985824, 4.363323129985824, 4.363323129985824, 4.363323129985824, 4.363323129985824};
inp.max_jerk = {43.63323129985824, 43.63323129985824, 43.63323129985824, 43.63323129985824, 43.63323129985824, 43.63323129985824};

auto result = ruckig.calculate(inp, traj);

The result:

[ruckig] error in step 2 in dof: 3 for t sync: 0.200762 input:
inp.current_position = [1.635923973038584, -0.02664577603159074, 1.398772409994243, 0.7204359129215889, 0.7531949879258638, -0.3527181789404736]
inp.current_velocity = [0.5997002460539949, 0.657823987334049, 0.6544488698370342, 0.6534667437575569, 0.6578239873340388, 0.6578239873340486]
inp.current_acceleration = [-2.111156774102785, -4.363323129985824, -3.853477374887802, -4.32029086362776, -4.363323129985824, -4.363323129985824]
inp.target_position = [1.6863294690542, 0.02475975543627795, 1.450144052898067, 0.7716208457168268, 0.8046005193937291, -0.301312647472602]
inp.target_velocity = [0, 0, 0, 0, 0, 0]
inp.target_acceleration = [0, 0, 0, 0, 0, 0]
inp.max_velocity = [5.235987755982989, 3.926990816987241, 3.926990816987241, 6.649704450098396, 5.427973973702365, 8.587019919812102]
inp.max_acceleration = [4.363323129985824, 4.363323129985824, 4.363323129985824, 4.363323129985824, 4.363323129985824, 4.363323129985824]
inp.max_jerk = [43.63323129985824, 43.63323129985824, 43.63323129985824, 43.63323129985824, 43.63323129985824, 43.63323129985824]

It seems to happen only when one or more dofs have an acceleration equal to their limit.

Thanks for your help !