I'm a beginner with Bullet and I'm trying to use it to detect collisions in an environment using industrial robots.
Everything seems to be working fine in small scale but if I try to scale up to the real size (the size of the models given by the robots constructor) I have problems with the forces to move the robots.
I'm receiving joint position updates from the simulation and for each update I'm using setJointMotorControl2() with the new position and then call stepSimulation() to move to it.
I tried to replicate the problem with a simple example. It moves one joint to a direction twice and then once in the opposite direction:
Code: Select all
import pybullet as p
import time
import pybullet_data
p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
txId = p.loadURDF("kuka_iiwa/model.urdf", [0, 0, 0], globalScaling=1, useFixedBase=True)
numJoints = p.getNumJoints(txId)
p.setGravity(0, 0, -10)
for i in range(numJoints):
p.resetJointState(txId, i, 0)
startTime = time.time()
increment = 0.2
position = 0.0
direction = [1, 1, -1]
max = len(direction)
count = 0
while 1:
currentTime = time.time()
t = currentTime - startTime
if t > 1.0:
startTime = currentTime
position += increment * direction[count % max]
count += 1
for i in range(numJoints):
p.setJointMotorControl2(bodyIndex=txId,
jointIndex=i,
controlMode=p.POSITION_CONTROL,
targetPosition=position if i == 1 else 0,
targetVelocity=0,
force=500000,
positionGain=1,
velocityGain=1)
p.stepSimulation()
time.sleep(1/240)
p.disconnect()
What is the best way to scale up ? Actually I'm doing 2 stepSimulation() for every movement but it hardly seems like a good solution. I have thought about scaling everything down but I have a lot of objects in my simulation and I would prefer to avoid it.