Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added python example for non-realtime context #43

Merged
merged 6 commits into from
Jul 13, 2021

Conversation

mdhom
Copy link
Contributor

@mdhom mdhom commented Jul 6, 2021

As i was using this library in a non-realtime context, i wondered how to use it as the provided (python-)example only shows the usage with fixed time slots. I opened an issue to ask for the correct, intended way. With that help, i implemented this example along the original example.

It came up, that the constructor of Ruckig at the moment takes 2 parameters (number of DOFs, delta_time). In this scenario, the delta_time in my opinion is useless, that's why i'd provide a default value for this parameter. Does that make sense? A point of discussion here, maybe.

Thanks for reviewing, i'm happy for feedback and hope that i could contribute a very small piece to this great library.

@pantor
Copy link
Owner

pantor commented Jul 7, 2021

With the latest commit on the master branch, you can do something like:

from ruckig import InputParameter, OutputParameter, Ruckig, Trajectory

inp = InputParameter(3)
inp.current_position = [0.2, 0, -1]
inp.current_velocity = [0, 0.2, 0]
inp.current_acceleration = [0, 1, 0]
inp.target_position = [0, -1, -1]
inp.target_velocity = [0.2, 0, 0]
inp.target_acceleration = [0, 0.1, -0.1]
inp.max_velocity = [2, 1, 1]
inp.max_acceleration = [0.2, 2, 2]
inp.max_jerk = [3, 4, 5]

otg = Ruckig(3)
trajectory = Trajectory(3)

otg.calculate(inp, trajectory)

print(f'Trajectory duration: {trajectory.duration:0.4f} [s]')

new_state = trajectory.at_time(0.1)

Feel free to update your example accordingly.

Copy link
Owner

@pantor pantor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename the examples to position-online.py and position-offline.py?

@pantor pantor merged commit a299398 into pantor:master Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants