Skip to content

Commit 7f90245

Browse files
author
Erwin Coumans
committed
tune scaling factors a bit
1 parent fdb97cf commit 7f90245

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

data/surge_hands/surge_hand_manual_control.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pybullet_data
88

9-
use_real_hardware = False
9+
use_real_hardware = True
1010
if use_real_hardware:
1111
import serial
1212

@@ -27,7 +27,6 @@
2727

2828
#collision tweak
2929
#p.setPhysicsEngineParameter(enableSAT=1)
30-
3130
p.resetDebugVisualizerCamera(cameraDistance=1.0, cameraYaw=128, cameraPitch=-28, cameraTargetPosition=[-0.5,-0.4,-0.3])
3231

3332
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0)
@@ -43,7 +42,6 @@
4342
#robot = p.loadURDF("surge_v13_hand_right_pybullet.urdf", useMaximalCoordinates=False, useFixedBase=True, flags=flags)
4443

4544
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 1)
46-
gravId = p.addUserDebugParameter("gravity", -10, 10, -10)
4745
jointIds = []
4846
paramIds = []
4947

@@ -63,8 +61,8 @@
6361
joint_name_to_hw_scaling[b"Middle_MCP_Joint"]=1.0
6462
joint_name_to_hw_scaling[b"Ring_MCP_Joint"]=1.0
6563
joint_name_to_hw_scaling[b"Pinky_MCP_Joint"]=1.0
66-
joint_name_to_hw_scaling[b"Metacarpal_Joint"]=0.25
67-
joint_name_to_hw_scaling[b"Thumb_Joint"]=0.25
64+
joint_name_to_hw_scaling[b"Metacarpal_Joint"]=0.4
65+
joint_name_to_hw_scaling[b"Thumb_Joint"]=0.3
6866

6967

7068
joint_index_to_name={}
@@ -141,15 +139,14 @@
141139
paramIds.append(p.addUserDebugParameter(jointName.decode("utf-8"), 0, 1.92, 0))
142140

143141
print("coupled_child_joints=",coupled_child_joints)
144-
p.setRealTimeSimulation(1)
145142

146143
while (1):
147-
p.setGravity(0, 0, p.readUserDebugParameter(gravId))
148144
for i in range(len(paramIds)):
149145

150146
c = paramIds[i]
151-
targetPos = p.readUserDebugParameter(c)
152-
if i in joint_index_to_name:
147+
try:
148+
targetPos = p.readUserDebugParameter(c)
149+
if i in joint_index_to_name:
153150
deg = int(math.degrees(targetPos))
154151
#print(joint_name_to_hw[joint_index_to_name[i]], deg)
155152

@@ -165,15 +162,17 @@
165162
response = ser.read(ser.inWaiting()) # Read all available data
166163
#print("Response:", response.decode(errors='ignore')) # Decode and print response
167164

168-
finger_force= 100 #Newton
169-
p.setJointMotorControl2(robot, jointIds[i], p.POSITION_CONTROL, targetPos, force=finger_force)
170-
if jointIds[i] in coupled_parent_to_child:
171-
distal_to_proximal_scaling=0.7 #you can also use a position-dependent non-linear function here
165+
finger_force= 100 #Newton
166+
p.setJointMotorControl2(robot, jointIds[i], p.POSITION_CONTROL, targetPos, force=finger_force)
167+
if jointIds[i] in coupled_parent_to_child:
168+
distal_to_proximal_scaling=0.65 #you can also use a position-dependent non-linear function here
172169
p.setJointMotorControl2(robot, coupled_parent_to_child[jointIds[i]], p.POSITION_CONTROL, targetPos*distal_to_proximal_scaling, force=finger_force)
173-
170+
except(e):
171+
print(e)
172+
174173
contacts = p.getContactPoints()
175174
num_contacts = len(contacts)
176175
if (num_contacts):
177176
print("num_contacts=", num_contacts)
178-
179-
time.sleep(0.01)
177+
p.stepSimulation()
178+
time.sleep(1./240.)

0 commit comments

Comments
 (0)