It'd be very convenient to be able to index into qpos/qvel and sensordata using the name of a body/data (e.g. through a function that returns a pointer to the start of the relevant sub-array in e.g. qpos). I looked in the API reference and I couldn't find anything that does this, although I may have missed it. Is this something that is implemented, or do we have to implement this ourselves if we want it? Thank you, Pedro DRL
bodyid = mj_name2id(model, mjOBJ_BODY, name) is the index of the body with a given name jntid = model->body_jntadr[bodyid] is the index of the first joint for that body model->jnt_qposadr[jntid] is the first position of that joint in the system qpos vector for indexing into qvel and qfrc, you need the dof_XXX arrays in mjModel. the first velocity index in this example is given by body_dofadr[bodyid], which equals jnt_dofadr[jntid]
d->ctrl corresponds to actuators. Each actuator has a description in mjModel containing the transmission type and transmission id. The id is the index of a joint, tendon or site depending on the transmission type. So if you want to know which actuator is acting on a given joint, you have to scan the list of actuators.