pantor / ruckig

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

Expression for array subscript out of range #12

Closed Linjackffy closed 3 years ago

Linjackffy commented 3 years ago

I found an expression when using ruckig. My platform is VS2017 and it run in debug mode.

The lines caused the expression are: https://github.com/pantor/ruckig/blob/d68b71ac7324ad10efffa844093890ba10dca304/include/ruckig/trajectory.hpp#L78-L83

In my opinion, i < 2 should check before p.t_brakes[i] since p.t_brakes[i] is a array of size 2.

Below is the test case I used:

    Ruckig<6> otg{ 0.001 };
    InputParameter<6> input;
    OutputParameter<6> output;

    // Set input parameters
    input.max_velocity = { 1.2, 1.2, 1.2, 0.6, 0.6, 0.6 };
    input.max_acceleration = { 4.0, 4.0, 4.0, 1.5, 1.5, 1.5 };
    input.max_jerk = { 100.0, 100.0, 100.0, 40.0, 40.0, 40.0 };

    input.current_position = { 0.0, -0.1, 0.12, 0.0, 0.3, 0.05 };
    input.current_velocity = { 2., 0.0, 0.2, 0.0, 0.0, 0.0 };
    input.current_acceleration = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

    input.target_position = { 10.0, 0.52, 0.55, 0.0, -0.13, 0.24 };
    input.target_velocity = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
    input.target_acceleration = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };

Looking forward to your reply!

pantor commented 3 years ago

Hi! Thanks for catching this exception. While it doesn't occur on my setup, it should be fixed now in the latest commit.