petrikosk / rsruckig

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

ErrorExecutionTimeCalculation #9

Open v-morlock opened 2 months ago

v-morlock commented 2 months ago

Hi!

Do you have any ideas on why this code here fails with "ErrorExecutionTimeCalculation" or what I could do differently for it to work?


        let mut inp = InputParameter::<4>::new(None);

        inp.current_position = DataArrayOrVec::Heap(vec![
            3.0017279999860462,
            0.8910770000000000,
            -90.0000000000000000,
            0.2120000000000000,
        ]);
        inp.current_velocity = DataArrayOrVec::Heap(vec![
            0.0000000000000000,
            0.0000000000000000,
            0.0000000000000000,
            0.0000000000000000,
        ]);
        inp.current_acceleration = DataArrayOrVec::Heap(vec![
            0.0000000000000000,
            0.0000000000000000,
            0.0000000000000000,
            0.0000000000000000,
        ]);
        inp.target_position = DataArrayOrVec::Heap(vec![
            1.0954848240358788,
            1.3018323350364962,
            -90.0000000000000000,
            0.2170000000000000,
        ]);
        inp.target_velocity = DataArrayOrVec::Heap(vec![
            0.0000000000000000,
            0.0000000000000000,
            0.0000000000000000,
            0.0000000000000000,
        ]);
        inp.target_acceleration = DataArrayOrVec::Heap(vec![
            0.0000000000000000,
            0.0000000000000000,
            0.0000000000000000,
            0.0000000000000000,
        ]);
        inp.max_velocity = DataArrayOrVec::Heap(vec![
            1.7100000000000000,
            1.7100000000000000,
            216.0000000000000000,
            0.4000000000000000,
        ]);
        inp.max_acceleration = DataArrayOrVec::Heap(vec![
            3.6000000000000001,
            3.6000000000000001,
            1440.0000000000000000,
            1.0000000000000000,
        ]);
        inp.max_jerk = DataArrayOrVec::Heap(vec![
            27.0000000000000000,
            27.0000000000000000,
            2880.0000000000000000,
            20.0000000000000000,
        ]);

        let mut ruckig = Ruckig::<4, ThrowErrorHandler>::new(None, 0.0004);
        let mut traj = Trajectory::new(None);
        ruckig.calculate(&inp, &mut traj).unwrap();

Thanks, Valentin

v-morlock commented 2 months ago

When I change the jerk of the last DOF to something different, the error is gone...

petrikosk commented 2 months ago

Hi!

This is interesting. I ran your code against the original C++ Ruckig, from which this is ported, and got exactly the same error. I do not have adequate understanding of the Ruckig algorithm, so if you think this is an error, I would suggest contacting the author of the C++ version. Once the possible issue is fixed in original Ruckig, it will be updated here.

You will find the C++ version here: https://github.com/pantor/ruckig

Here is my C++ test code, which reproduces the error:

#include <iostream>
#include <ruckig/ruckig.hpp>

int main() {
    constexpr size_t DOFs {4};
    RuckigThrow<DOFs> otg {0.0004};
    InputParameter<DOFs> input;

    input.current_position = { 3.0017279999860462,
                               0.8910770000000000,
                               -90.0000000000000000,
                               0.2120000000000000 };

    input.current_velocity = { 0.0000000000000000,
                               0.0000000000000000,
                               0.0000000000000000,
                               0.0000000000000000 };

    input.current_acceleration = { 0.0000000000000000,
                                   0.0000000000000000,
                                   0.0000000000000000,
                                   0.0000000000000000 };

    input.target_position = { 1.0954848240358788,
                              1.3018323350364962,
                              -90.0000000000000000,
                              0.2170000000000000 };

    input.target_velocity = { 0.0000000000000000,
                              0.0000000000000000,
                              0.0000000000000000,
                              0.0000000000000000 };

    input.target_acceleration = { 0.0000000000000000,
                                  0.0000000000000000,
                                  0.0000000000000000,
                                  0.0000000000000000 };

    input.max_velocity = { 1.7100000000000000,
                           1.7100000000000000,
                           216.0000000000000000,
                           0.4000000000000000 };

    input.max_acceleration = { 3.6000000000000001,
                               3.6000000000000001,
                               1440.0000000000000000,
                               1.0000000000000000 };

    input.max_jerk = { 27.0000000000000000,
                       27.0000000000000000,
                       2880.0000000000000000,
                       20.0000000000000000 };

    Trajectory<DOFs> traj;

    try {

        otg.calculate(input, traj);
    }

    catch (const std::exception& e) {
        std::cout << "Caught exception: " << e.what() << std::endl;
    }
    catch (...) {
        std::cout << "Caught unknown exception" << std::endl;
    }

    return 0;
}