robotcontrol.py 736 B

123456789101112131415161718192021222324252627282930
  1. import pybullet as p
  2. p.connect(p.GUI) #or p.SHARED_MEMORY or p.DIRECT
  3. p.loadURDF("plane.urdf")
  4. p.setGravity(0,0,-10)
  5. huskypos = [0,0,0.1]
  6. husky = p.loadURDF("husky/husky.urdf",huskypos[0],huskypos[1],huskypos[2])
  7. numJoints = p.getNumJoints(husky)
  8. for joint in range (numJoints) :
  9. print (p.getJointInfo(husky,joint))
  10. targetVel = 10 #rad/s
  11. maxForce = 100 #Newton
  12. for joint in range (2,6) :
  13. p.setJointMotorControl(husky,joint,p.VELOCITY_CONTROL,targetVel,maxForce)
  14. for step in range (300):
  15. p.stepSimulation()
  16. targetVel=-10
  17. for joint in range (2,6) :
  18. p.setJointMotorControl(husky,joint,p.VELOCITY_CONTROL,targetVel,maxForce)
  19. for step in range (400):
  20. p.stepSimulation()
  21. p.getContactPointData(husky)
  22. p.disconnect()