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

Add Feature to allow runtime changes to joint friction, damping, spring properties #449

Open
scpeters opened this issue Nov 15, 2022 · 10 comments
Labels
close the gap Features from Gazebo-classic enhancement New feature or request help wanted Extra attention is needed

Comments

@scpeters
Copy link
Member

Desired behavior

There are several joint parameters specified in //joint/axis*/dynamics such as friction, damping, spring_stiffness, and spring_reference. Several of these parameters are supported by the dartsim plugin when loading from an SDFormat file, but there is no Feature for changing these parameters at runtime. Related to #96 which requested the ability to set joint limits at runtime, resolved in #260.

Alternatives considered

Implementation suggestion

See #260

Additional context

@scpeters scpeters added the enhancement New feature or request label Nov 15, 2022
@scpeters scpeters added help wanted Extra attention is needed close the gap Features from Gazebo-classic labels Nov 15, 2022
@azeey azeey moved this to To do in Core development Jul 24, 2023
@francocipollone
Copy link

Hey there! One silly question. From what I've seen in the suggested implementation, adding this feature (and later implementation in gz-sim) shouldn't break api/abi, right? It should be able to easily backport it to fortress if needed, correct?

@scpeters
Copy link
Member Author

Hey there! One silly question. From what I've seen in the suggested implementation, adding this feature (and later implementation in gz-sim) shouldn't break api/abi, right? It should be able to easily backport it to fortress if needed, correct?

correct, adding this feature shouldn't break api/abi so we should be able to backport this to fortress, though I would prefer to start by adding it to the main branch and backporting from there

@yaswanth1701
Copy link

yaswanth1701 commented Oct 12, 2024

Hi @scpeters, Can I work on this feature ?

@scpeters
Copy link
Member Author

Can I work on this feature ?

Yes, @yaswanth1701 you may work on this feature. 😁

Please target Ionic for your initial work and let me know if you have questions

@yaswanth1701
Copy link

Sure.

@yaswanth1701
Copy link

Hi @scpeters, I was thinking to write the test cases for the implementation of set of features to check if everything works well. Should I implement the get methods too ? And check if after few simulation iterations, values remains the same ? if possible can you please suggest possible tests.

@scpeters
Copy link
Member Author

Hi @scpeters, I was thinking to write the test cases for the implementation of set of features to check if everything works well. Should I implement the get methods too ? And check if after few simulation iterations, values remains the same ? if possible can you please suggest possible tests.

yes, I think the get methods would be nice as well. The best test cases would use a physical expectation, for example, if you load a world with a pendulum initially at 90 degrees so that it would start oscillating as soon as the simulation starts; if you initialize the joint friction to a very high value, it should not move. then after a few steps, if you drop it to zero, it should start moving again. if you put it at a small value that allows some motion, it should decrease the total energy. that would be an ideal test, but it would be ok to just partially implement it

for joint damping, I would expect different levels of energy dissipation depending on the damping coefficient

for spring properties, you could start with a pendulum in a stable downward position then apply a spring stiffness with a reference position at 90 degrees and expect it to be pulled towards that reference position. if you add some damping, you can wait for it to come to an equilibrium and check the equilibrium point. you can also apply a constant effort or use a prismatic joint at an angle relative to the gravity vector in order to get a linear response instead of the nonlinear pendulum behavior

just some thoughts, please reach out if you want to discuss further

@yaswanth1701
Copy link

yaswanth1701 commented Nov 24, 2024

Hi @scpeters, I was thinking to write the test cases for the implementation of set of features to check if everything works well. Should I implement the get methods too ? And check if after few simulation iterations, values remains the same ? if possible can you please suggest possible tests.

yes, I think the get methods would be nice as well. The best test cases would use a physical expectation, for example, if you load a world with a pendulum initially at 90 degrees so that it would start oscillating as soon as the simulation starts; if you initialize the joint friction to a very high value, it should not move. then after a few steps, if you drop it to zero, it should start moving again. if you put it at a small value that allows some motion, it should decrease the total energy. that would be an ideal test, but it would be ok to just partially implement it

for joint damping, I would expect different levels of energy dissipation depending on the damping coefficient

for spring properties, you could start with a pendulum in a stable downward position then apply a spring stiffness with a reference position at 90 degrees and expect it to be pulled towards that reference position. if you add some damping, you can wait for it to come to an equilibrium and check the equilibrium point. you can also apply a constant effort or use a prismatic joint at an angle relative to the gravity vector in order to get a linear response instead of the nonlinear pendulum behavior

just some thoughts, please reach out if you want to discuss further

Thanks a lot for the suggestions Steve. I will start implementing these tests. Also, what should be the expected behaviour from the prismatic joint with constant force or gravity applied to it?

@scpeters
Copy link
Member Author

Thanks a lot for the suggestions Steve. I will start implementing these tests. Also, what should be the expected behaviour from the prismatic joint with constant force or gravity applied to it?

if the parent link of the prismatic joint is the world, then I would use Newton's 2nd law to equate the sume of forces on the child link (gravity and the joint force) with the child link's linear acceleration. You only need to consider the forces and acceleration in the direction of the prismatic joint axis.

dot(sum_of_child_link_forces, joint_axis) = mass * dot(child_link_linear_acceleration, joint_axis)
sum_of_child_link_forces = mass * gravity_vector + joint_force_on_child_link

The the gravity_vector is constant, and the joint_force_on_child_link depends on the parameters applied; in general it is:

joint_force_on_child_link =
    - spring_stiffness * (joint_position - spring_reference)
    - damping * joint_velocity
    - joint_friction * sign(joint_velocity)

With no stiffness or damping, I would expect two regimes of behavior for a child of a prismatic joint subject to joint friction:

  • when the joint friction is larger than mass * abs(dot(gravity_vector, joint_axis)), the child link should not move (joint_velocity = 0)
  • when the joint friction is smaller than mass * abs(dot(gravity_vector, joint_axis)), the child link will have constant linear acceleration along the joint axis, with two possible values depending on the joint_velocity direction compared to the gravity direction: child_link_linear_acceleration = dot(gravity_vector, joint_axis) joint_friction / mass * sign(joint_velocity)

I would use a similar approach to predict the behavior with spring and damping properties.

@yaswanth1701
Copy link

Thanks a lot for the detailed explanation Steve 😁. I will start with implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
close the gap Features from Gazebo-classic enhancement New feature or request help wanted Extra attention is needed
Projects
Status: To do
Development

No branches or pull requests

3 participants