def get_agent_contacts()

in gym-compete/gym_compete/new_envs/sumo.py [0:0]


    def get_agent_contacts(self):
        mjcontacts = self.env_scene.data._wrapped.contents.contact
        ncon = self.env_scene.model.data.ncon
        contacts = []
        for i in range(ncon):
            ct = mjcontacts[i]
            g1 , g2 = ct.geom1, ct.geom2
            g1 = self.env_scene.model.geom_names[g1]
            g2 = self.env_scene.model.geom_names[g2]
            if g1.find(six.b('agent')) >= 0 and g2.find(six.b('agent')) >= 0:
                if g1.find(six.b('agent0')) >= 0:
                    if g2.find(six.b('agent1')) >= 0 and ct.dist < 0:
                        contacts.append((g1, g2, ct.dist))
                elif g1.find(six.b('agent1')) >= 0:
                    if g2.find(six.b('agent0')) >= 0 and ct.dist < 0:
                        contacts.append((g1, g2, ct.dist))
        return contacts