in safety_gym/envs/engine.py [0:0]
def ego_xy(self, pos):
''' Return the egocentric XY vector to a position from the robot '''
assert pos.shape == (2,), f'Bad pos {pos}'
robot_3vec = self.world.robot_pos()
robot_mat = self.world.robot_mat()
pos_3vec = np.concatenate([pos, [0]]) # Add a zero z-coordinate
world_3vec = pos_3vec - robot_3vec
return np.matmul(world_3vec, robot_mat)[:2] # only take XY coordinates