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

MjSpec: protocols for merging keyframes on attach #2102

Open
hartikainen opened this issue Sep 28, 2024 · 0 comments
Open

MjSpec: protocols for merging keyframes on attach #2102

hartikainen opened this issue Sep 28, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@hartikainen
Copy link
Contributor

hartikainen commented Sep 28, 2024

The feature, motivation and pitch

When attaching bodies from one spec to another, it would be convenient to have some configurability on how the keyframes are handled as a result of the attachment. For example, I often have a "home" keyframe in both the attachment source and target specs and it would be convenient to be have a single "home" keyframe in the target spec after the attachment.

There's obviously no general solution that would magically always do the right thing, but the API could provide some pre-defined protocols that can be passed in as an argument to e.g. the MjsFrame.attach_body. For example my use cases would be largely covered by something like:

  • MjsFrame.attach_body(..., "by-name"), which would merge all the keyframes with the same name.
    • Example: when specs have <key name="home" qpos="1"/> and <key name="home" qpos="2"/>, the result would be <key name="home" qpos="1 2"/>.
  • MjsFrame.attach_body(..., "by-index"), which would merge all the keyframes with the same index.
    • Example: when specs have <key qpos="1"/><key qpos="2"/> and <key qpos="3"/><key qpos="4"/>, the result would be <key qpos="1 3"/><key qpos="2 4"/>.

There are obviously some details that would have to be figured out before implementing these. For example, what would happen if two specs have different number of key elements when attaching with by-index. Or if one key has an attribute and the other one does not.

Alternatives

The keyframes can currently be merged manually using the C- or Python-API.

Additional context

No response

@hartikainen hartikainen added the enhancement New feature or request label Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant