petrikosk / rsruckig

Rust port of Ruckig trajectory generator
https://ruckig.com
MIT License
5 stars 4 forks source link

add duration test #4

Closed oroulet closed 6 months ago

oroulet commented 7 months ago

That test fails. Is that normal? Looks like the duration input is ignored

oroulet commented 6 months ago

Maybe I was not clear and I should have flagged it but that MR was to show a problem. It was not to be merged ,,,;-)

petrikosk commented 6 months ago

I see... I ran the same test against the C++ version or Ruckig and the test passes:

TEST_CASE("test_min_duration") {
    constexpr size_t DOFs {1};
    RuckigThrow<DOFs> otg {0.005};
    InputParameter<DOFs> input;

    input.current_position[0] = 0.0;
    input.current_velocity[0] = 0.0;
    input.current_acceleration[0] = 0.0;

    input.target_position[0] = 1.0;
    input.target_velocity[0] = 1.0;
    input.target_acceleration[0] = 1.0;

    input.max_velocity[0] = 1.0;
    input.max_acceleration[0] = 2.0;
    input.max_jerk[0] = 3.0;

    input.minimum_duration = std::nullopt;
    input.synchronization = Synchronization::None;

    Trajectory<1> traj;
    auto result = otg.calculate(input, traj);
    CHECK( result == Result::Working );

    Trajectory<1> traj_min_duration;
    input.minimum_duration = 5.0;

    result = otg.calculate(input, traj_min_duration);
    CHECK( result == Result::Working );

    CHECK( traj_min_duration.get_duration() > traj.get_duration() );
    CHECK( traj_min_duration.get_duration() >= doctest::Approx(5.0) );
}

I will investigate this. The merge can stay there as such test should pass. I will let you know when there is a fix.

Thank you for pointing out the issue.