in mujoco_py/mjsim.pyx [0:0]
def ray(self, pnt, vec, include_static_geoms=True, exclude_body=-1, group_filter=None):
"""
Cast a ray into the scene, and return the first valid geom it intersects.
pnt - origin point of the ray in world coordinates (X Y Z)
vec - direction of the ray in world coordinates (X Y Z)
include_static_geoms - if False, we exclude geoms that are children of worldbody.
exclude_body - if this is a body ID, we exclude all children geoms of this body.
group_filter - a vector of booleans of length const.NGROUP
which specifies what geom groups (stored in model.geom_group)
to enable or disable. If none, all groups are used
Returns (distance, geomid) where
distance - distance along ray until first collision with geom
geomid - id of the geom the ray collided with
If no collision was found in the scene, return (-1, None)
NOTE: sometimes self.forward() needs to be called before self.ray().
See self.ray_fast_group() and self.ray_fast_nogroup() for versions of this call
with more stringent type requirements.
"""
cdef mjtNum distance
cdef mjtNum[::view.contiguous] pnt_view = pnt
cdef mjtNum[::view.contiguous] vec_view = vec
if group_filter is None:
return self.ray_fast_nogroup(
np.asarray(pnt, dtype=np.float64),
np.asarray(vec, dtype=np.float64),
1 if include_static_geoms else 0,
exclude_body)
else:
return self.ray_fast_group(
np.asarray(pnt, dtype=np.float64),
np.asarray(vec, dtype=np.float64),
np.asarray(group_filter, dtype=np.uint8),
1 if include_static_geoms else 0,
exclude_body)