Closed JewelryForge closed 1 month ago
By the way, I'm confused by this code segment
Does it just mean
if (!bodies.empty()) {
return bodies[0]->NextChild(NULL, child->elemtype, true);
}
or a mistake?
Hi, I'm about to push out the option to do breadth-first iteration. Incidentally I was already working on it while you opened the bug :)
By the way, I'm confused by this code segment
Does it just mean
if (!bodies.empty()) { return bodies[0]->NextChild(NULL, child->elemtype, true); }
or a mistake?
The next child can be in bodies[0]
or in another body of bodies
. The other body is not a child of body[0]
so how would you reach it?
Thank you for your hard work! I'm sorry I do not understand what you mean by
The next child can be in
bodies[0]
or in another body ofbodies
. The other body is not a child ofbody[0]
so how would you reach it?
I want to express that the two code segments may be equivalent because the function returns in the first iteration of the for-loop if the bodies
is not empty. So the for-loop does not have effect and can be simplified to a if sentense.
Oh I see what you mean. I will take a look, thank you.
Intro
Hi!
I am a MuJoCo user working on legged locomotion.
My setup
latest MuJoCo 8a825e6050e88b113db03b2cd102e5cb711d4c61 C API OS: Ubuntu 24.04
What's happening? What did you expect?
After revision ae4987026c9d9a8bfc590c0865cc6bb6db2980be,
mjs_firstElement
andmjs_nextElement
can be used to iterate all elements of the whole mjSpec with the specified type recursively.Take the following code as an example. In my opinion, it should output
However, the latest MuJoCo outputs an incomplete result:
Additionally, I wonder if it would be better if the elements are searched depth-first, in the same order as the compiled
mjModel
. It may output the below result in this example.Steps for reproduction
Change the directory of mujoco_menagerie to the actual directory below and run the below code.
Minimal model for reproduction
mujoco_menagerie/unitree_go2/go2.xml can be used for reproduction.
Code required for reproduction
Confirmations