[Python] Pybullet - Gripper is not able to Grasp Object

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I am using the Kinova Jaco robotic arm with the j2n6s300.urdf file and I simply want to grasp a mug from the side and live it up. However, the gripper is not able to pick up the mug. It seems that there is an "invisible" barrier between gripper fingers and mugs. If I lift the gripper the mug stays where it was.

    However, if I run the same code using the Franka Panda robot (slight adaptions with joints) I can lift the mug. What is my problem? Is it related to the urdf file?

    This is my code:

    import os
    import pybullet as pb
    import pybullet_data
    import math
    import time
    import pybullet_data as pd
    jaco_path = 'jaco_reza/j2n6s300.urdf'
    pb.connect(pb.GUI)
    path = pd.getDataPath()

    jaco_orientation_euler = [0,math.pi/2,0]
    jaco_orientation_quaternion = pb.getQuaternionFromEuler(jaco_orientation_euler)
    jacoUid = pb.loadURDF(os.path.join(jaco_path,), useFixedBase=True, basePosition=[-0.63,0,0.46], baseOrientation=jaco_orientation_quaternion)

    pos, ori = pb.getBasePositionAndOrientation(jacoUid)
    tableUid = pb.loadURDF(os.path.join(pybullet_data.getDataPath(), "table/table.urdf"),basePosition=[0.5,0,-0.66])

    mug_orientation_euler = [0,0,-math.pi/2]
    mug_orientation_quaternion = pb.getQuaternionFromEuler(mug_orientation_euler)

    mugUid = pb.loadURDF(os.path.join(pybullet_data.getDataPath(), "objects/mug.urdf"),basePosition=[0.148,0,-0.035], baseOrientation=mug_orientation_quaternion)

    pb.setGravity(0,0,-10)

    pb.resetDebugVisualizerCamera(
    cameraDistance=1.5,
    cameraYaw=0,
    cameraPitch=-20,
    cameraTargetPosition=[-0.15,0,0.1])

    # #init Jaco Position
    rest_poses = [0,0,0,1.5,1.4,1.5,0,1.5,3,0,0.5,0,0.5,0,0.5]
    for i in range(15):
    pb.resetJointState(jacoUid,i, rest_poses)


    fingerAngle = 0.7

    for i in range(180):
    pb.setJointMotorControl2(jacoUid,9,pb.POSITION_CONTROL,targetPosition=fingerAngle,force=2000)
    pb.setJointMotorControl2(jacoUid,11,pb.POSITION_CONTROL,targetPosition=fingerAngle,force=1000)
    pb.setJointMotorControl2(jacoUid,13,pb.POSITION_CONTROL,targetPosition=fingerAngle,force=1000)
    pb.stepSimulation()
    fingerAngle += 0.1 / 100.
    if fingerAngle > 2:
    fingerAngle = 2 #upper limit
    time.sleep(0.02)

    for i in range(20):
    print(pb.getJointState(jacoUid,4)[0])
    pb.setJointMotorControl2(jacoUid, 4,
    pb.POSITION_CONTROL,
    targetPosition=1)
    pb.stepSimulation()

    while True:
    pb.configureDebugVisualizer(pb.COV_ENABLE_SINGLE_STEP_RENDERING)
    pb.stepSimulation()



    I tried to change the .urdf file of the Kinova robotic but it was not working and I have the feeling that I am missing an important step.

    Continue reading...

Compartilhe esta Página