I'm confused about the interpretation of mj_ray() arguments. I'm making a bunch of assumptions I'd like to verify here: I'm assuming flg_static should be either 0 or 1, and if 0, geoms which are direct children of the worldbody are excluded I'm assuming bodyexclude is interpreted as a (non-world) body to exclude from collision -- I'm also assuming that -1 is a valid body id if I don't want to exclude any I'm assuming geomgroup, if it is not NULL, must be of length mjNGROUP (like it is mjvOption) It seems these are reasonable assumptions to make -- I'd like to just make sure I'm not relying on undefined behavior here. Copying from the book: Ray collisions Ray collision functionality was added in MuJoCo 1.50. This is a new collision detection module that uses analytical formulas to intersect a ray (p + x*v, x>=0) with a geom, where p is the origin of the ray and v is the vector specifying the direction. All functions in this family return the distance to the nearest geom surface, or -1 if there is no intersection. Note that if p is inside a geom, the ray will intersect the surface from the inside which still counts as an intersection. mj_ray mjtNum mj_ray(const mjModel* m,const mjData* d,const mjtNum* pnt,const mjtNum* vec,const mjtByte* geomgroup, mjtByte flg_static,int bodyexclude,int* geomid); Intersect ray (pnt+x*vec, x>=0) with visible geoms, except geoms in bodyexclude. Return geomid and distance (x) to nearest surface, or -1 if no intersection. geomgroup, flg_static are as in mjvOption; geomgroup==NULL skips group exclusion.
Update: geomgroup is not behaving as expected. I have the following model: <mujoco> <worldbody> <geom name="A" type="sphere" size=".1" pos="1 0 0" group="3" rgba="1 0 0 1"/> <body name="M" pos="0 0 0"> <body name="N" pos="0 0 0"> <geom name="B" type="sphere" size=".1" pos="3 0 0" rgba="0 1 0 1"/> </body> <geom name="C" type="sphere" size=".1" pos="5 0 0" group="4" rgba="0 0 1 1"/> </body> </worldbody> </mujoco> What happens geomgroup = [1, 1, 1, 1, 1] causes ray collisions with all 3 geoms (expected) geomgroup = [0, 0, 0, 1, 1] excludes geom "B" (expected) geomgroup = [1, 0, 0, 0, 1] excludes no geoms (UNEXPECTED -- I expected this to exclude geom "A") geomgroup = [1, 0, 0, 1, 0] excludes no geoms (UNEXPECTED -- I expected this to exclude geom "C")