From 9a9aa5e9e7c52f8b6e59f123b043049ab1a87a66 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 6 Jan 2018 13:43:07 -0800 Subject: [PATCH] example of joint motor with friction --- .../examples/jointFrictionAndMotor.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/pybullet/examples/jointFrictionAndMotor.py diff --git a/examples/pybullet/examples/jointFrictionAndMotor.py b/examples/pybullet/examples/jointFrictionAndMotor.py new file mode 100644 index 000000000..5ecba00bd --- /dev/null +++ b/examples/pybullet/examples/jointFrictionAndMotor.py @@ -0,0 +1,26 @@ +import pybullet as p +import time + +p.connect(p.GUI) +door=p.loadURDF("door.urdf") + +#linear/angular damping for base and all children=0 +p.changeDynamics(door,-1,linearDamping=0, angularDamping=0) +for j in range (p.getNumJoints(door)): + p.changeDynamics(door,j,linearDamping=0, angularDamping=0) + print(p.getJointInfo(door,j)) + + +frictionId = p.addUserDebugParameter("jointFriction",0,20,10) +torqueId = p.addUserDebugParameter("joint torque",0,20,5) + +while (1): + frictionForce = p.readUserDebugParameter(frictionId) + jointTorque = p.readUserDebugParameter(torqueId) + #set the joint friction + p.setJointMotorControl2(door,1,p.VELOCITY_CONTROL,targetVelocity=0,force=frictionForce) + #apply a joint torque + p.setJointMotorControl2(door,1,p.TORQUE_CONTROL,force=jointTorque) + p.stepSimulation() + time.sleep(0.01) + \ No newline at end of file