Skip to content

Python: add relpose attribute to MjModel.eq() #1157

@Jesperoka

Description

@Jesperoka

mujoco python bindings version 2.3.7

I found myself creating a function like:

import mujoco
import numpy as np

def set_weld_relpose(model: mujoco.MjModel, pos: np.ndarray, quat: np.ndarray, name: str):
        pos_idx, quat_idx = 3, 6 
        data = model.eq(name).data  
        data[pos_idx:pos_idx+3] = np.copy(pos) 
        data[quat_idx:quat_idx+4] = np.copy(quat) 

to programmatically change the relpose of a weld equality.

It would be nice if there was an attribute, similar to

model.eq(name).active
model.eq(name).solimp
model.eq(name).solref

so one could do

my_relpose = np.array([0, 0, 0, 1, 0, 0, 0])
model.eq("my_weld").relpose = my_relpose

and also so it doesn't break if the data attribute changes in the future.

For all i know there might be a good reason not to add this, and if there already is a nicer way to do it I would love to know!

I tried changing model.qpos0 to achieve the same as well, but I didn't get it to work and found it a bit unintuitive.

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions