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 jaxsim.api.references with functional resources to handle model references #96

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

diegoferigo
Copy link
Member

@diegoferigo diegoferigo commented Feb 29, 2024

This PR introduces helpers to manipulate the following inputs of a simulated model:

  • Joint force references: these are the torques (or linear forces) references synthesized by a joint controller from the user. They are not guaranteed to be the same as those actuated since there might be friction or other contributions e.g. for enforcing joint limits.
  • Link forces: these are the 6D forces applied to the origin ${}^W \mathbf{o}_{L_i}$ of each link frame $L_i$. The coordinates of the 6D forces are expressed in the active JaxSimModelReferences.velocity_representation.

📚 Documentation preview 📚: https://jaxsim--96.org.readthedocs.build//96/

@diegoferigo diegoferigo self-assigned this Feb 29, 2024
@diegoferigo diegoferigo force-pushed the feature/functional_references branch from 40a201c to 9ce8384 Compare March 1, 2024 11:44
@diegoferigo diegoferigo marked this pull request as ready for review March 1, 2024 11:46
Copy link
Collaborator

@flferretti flferretti left a comment

Choose a reason for hiding this comment

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

Thanks Diego, LGTM!

Could you please clarify where and how this should be used? In js.model.step or is it to be loaded in js.data.JaxsimModelData.state`?

@diegoferigo
Copy link
Member Author

Right now I'm just creating the storage. You can try the following for the moment:

import jaxsim.api as js
from jaxsim import integrators

model: js.model.JaxSimModel = ...
data: js.data.JaxSimModelData = ...

ref = js.references.JaxSimModelReferences.zero(
    model=model, velocity_representation=data.velocity_representation
)

ref = ref.set_joint_force_references(
    forces=jnp.ones(model.number_of_joints())[0:5],
    model=model,
    joint_names=model.joint_names()[0:5],
)

integrator: integrators.Integrator = ...
d = integrator.init(x0=data.state, t0=0.0, dt=0.001)

_ = js.model.step(
    model=model,
    data=data,
    integrator=integrator,
    integrator_state=d,
    joint_forces=ref.joint_force_references(),
    external_forces=ref.link_forces(),
)

@diegoferigo diegoferigo force-pushed the feature/functional_references branch from 9ce8384 to 18a034d Compare March 1, 2024 12:27
@flferretti
Copy link
Collaborator

Alright, thanks a lot for the explanation!

@diegoferigo diegoferigo merged commit 75f7257 into ami-iit:main Mar 1, 2024
11 checks passed
@diegoferigo diegoferigo deleted the feature/functional_references branch March 5, 2024 11:15
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.

None yet

2 participants