Yes, write some code to scan the list of contacts in mjData.contact. Each contact contains the ids of the two participating geoms.