From e1ba6e9736996446c684ac24dacda685af927d14 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 20 Sep 2016 23:19:03 -0700 Subject: [PATCH] add simple pybullet robotcontrol.py example --- examples/pybullet/robotcontrol.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/pybullet/robotcontrol.py diff --git a/examples/pybullet/robotcontrol.py b/examples/pybullet/robotcontrol.py new file mode 100644 index 000000000..e94d6d5ba --- /dev/null +++ b/examples/pybullet/robotcontrol.py @@ -0,0 +1,30 @@ +import pybullet as p +p.connect(p.GUI) #or p.SHARED_MEMORY or p.DIRECT + +p.loadURDF("plane.urdf") +p.setGravity(0,0,-10) +huskypos = [0,0,0.1] + +husky = p.loadURDF("husky/husky.urdf",huskypos[0],huskypos[1],huskypos[2]) +numJoints = p.getNumJoints(husky) +for joint in range (numJoints) : + print (p.getJointInfo(husky,joint)) +targetVel = 10 #rad/s +maxForce = 100 #Newton + +for joint in range (2,6) : + p.setJointMotorControl(husky,joint,p.VELOCITY_CONTROL,targetVel,maxForce) +for step in range (300): + p.stepSimulation() + +targetVel=-10 +for joint in range (2,6) : + p.setJointMotorControl(husky,joint,p.VELOCITY_CONTROL,targetVel,maxForce) +for step in range (400): + p.stepSimulation() + +p.getContactPointData(husky) + +p.disconnect() + +