Code: Select all
import pybullet as p
import pybullet_data
import time
obstacles_coor=[[-5,10,2.5],[2,10,2.5],[10,10,2.5],[0,5,2.5],[-10,-5,2.5]]
physicsClient = p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
p.loadURDF('plane.urdf', [0,0,0])
p.setGravity(0,0,-10)
for obs in obstacles_coor:
p.loadURDF("cube.urdf",obs,globalScaling=0.5)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
obstacles_coor.pop()
cube=p.loadURDF("cube.urdf", [0,0,1])
def contactPoints():
contacts = p.getContactPoints(bodyA=cube, bodyB=obs)
for contact in contacts:
link_index = contact[5]
if link_index >= 0:
#p.removeBody(obstacles_coor[0])
#del(obstacles_coor.pop(0))
p.removeBody(obstacles_coor.pop(0))
for i in range(10000):
p.stepSimulation()
contactPoints()
time.sleep(1./240.)
Code: Select all
contacts = p.getContactPoints(bodyA=cube, bodyB=obs)
Code: Select all
Exception has occurred: TypeError
an integer is required (got type list)
File "C:\Users\AisyahJeff\niche_evo_single_species\old_model\test.py", line 60, in contactPoints
contacts = p.getContactPoints(bodyA=cube, bodyB=obs)
File "C:\Users\AisyahJeff\niche_evo_single_species\old_model\test.py", line 72, in <module>
contactPoints()