Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug after decreasing maximum velocity #146

Closed
cesarmoreno1991 opened this issue Nov 6, 2022 · 2 comments
Closed

Bug after decreasing maximum velocity #146

cesarmoreno1991 opened this issue Nov 6, 2022 · 2 comments

Comments

@cesarmoreno1991
Copy link

Hi,

I found a bug if the maximum velocity is decreased. Please find this simple example:

#include <iostream>
#include <ruckig/ruckig.hpp>
using namespace ruckig;
int main() {
    // Create instances: the Ruckig OTG as well as input and output parameters
    const double cycleTime_s = 0.002;
    Ruckig<1> otg {cycleTime_s};  // control cycle
    InputParameter<1> input;
    OutputParameter<1> output;

    // Set input parameters
    input.control_interface = ControlInterface::Position;
    input.current_position = {0.0};
    input.current_velocity = {0.0};
    input.current_acceleration = {0.0};

    input.target_position = {1.2};
    input.target_velocity = {0.0};
    input.target_acceleration = {0.0};

    input.max_velocity = {0.55};
    input.max_acceleration = {1.0};
    input.max_jerk = {2.0};

    // Generate the trajectory within the control loop
    bool velocityChangeDone = false;
    double time_s = 0.0;
    while( otg.update( input, output ) == Result::Working ) {
        auto& p = output.new_position;
        auto& v = output.new_velocity;
        auto& a = output.new_acceleration;
        // Change maximum velocity after 1.5 seconds
        if( !velocityChangeDone && time_s > 1.5 )
	{
            input.max_velocity = {0.10};
            velocityChangeDone = true;
        }

        time_s += cycleTime_s;
        std::cout << time_s << ";" << p[0] << ";" << v[0] << ";" << a[0] << std::endl;

        output.pass_to_input(input);
    }
}

After the velocity change is done, there is a really weird behavior of the system. Could you please check it?

Thanks in advance.
Regards,
Cesar

@fxd0h
Copy link

fxd0h commented Nov 8, 2022

I'm facing the same problem while trying to use ruckig community ed. for a joystick jogger (servoing) with jerk limited motion. It act weird if the max velocity is decreased.
Attached cesar's program output plotted values.

ruckigReport1

@pantor
Copy link
Owner

pantor commented Dec 14, 2022

This seems in line with the current implementation that Ruckig will brake as fast as possible to stay within the limits.

When reducing max_velocity limit below current_velocity, the trajectory will de-accelerate until the velocity limit is reached exactly, however then it can only ramp-up the acceleration slowly due to the jerk limitation. Therefore, an overshoot in the velocity occurs.

This relates to the soft constraints issue (#45) so that Ruckig will brake to stay on the velocity limit afterwards.

@pantor pantor closed this as completed Dec 14, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants