I am using Pybullet for robotics research but I am having some issues with the joint state torque feedback.
When I use a hexapod model (we use this model in other simulators without issue) I consistently get a block of 0.0 as torque feedback from getJointState(s). In this case it is joints 9-13. I also observe some unrealistically large joint torques (e.g. 240) reported but I am less concerned about those as they are not persistent across all time. The zeros appear to be returned in any joint position and any control mode.
At first I thought it could be an issue with the urdf, but, all of the legs use the same parts and only some seemingly arbitrary subset of the joints have this problem.
I also observed that after enabling the enableJointForceTorqueSensor, I can get readings but the joint moment reported does not seem to have any relation to the joint state torque.
I have tried a few other hexapod models, which are not made from any of the same parts, and observed similar problems.
I have seen the same thing happen across multiple computers when running this script both in python2 and python3, and across multiple versions of pybullet. My system is Ubuntu 16.04 and is currently up to date with pybullet-3.0.4. I have attached the urdf and its stls in question, and code to reproduce the issue is below.
This problem is making it difficult for me to use pybullet for my research. Do you have any suggestions of what might be wrong?
Code: Select all
import pybullet as p import pybullet_data import os import numpy as np import time physicsClient = p.connect(p.GUI) p.resetSimulation() # remove all objects from the world and reset the world to initial conditions. p.configureDebugVisualizer(p.COV_ENABLE_GUI,0,physicsClientId=physicsClient) p.setGravity(0,0,-9.81) planeId = p.loadURDF(os.path.join(pybullet_data.getDataPath(), "plane100.urdf")) startPosition=[0,0,0.3] # high enough that nothing touches the ground startOrientationRPY = [0,0,0] startOrientation = p.getQuaternionFromEuler(startOrientationRPY) robotID = p.loadURDF( 'misc_urdf/m6.urdf', basePosition=startPosition, baseOrientation=startOrientation, flags= (p.URDF_MAINTAIN_LINK_ORDER | p.URDF_USE_SELF_COLLISION | p.URDF_ENABLE_CACHED_GRAPHICS_SHAPES)) # count all joints, including fixed ones num_joints_total = p.getNumJoints(robotID, physicsClientId=physicsClient) # create lists of the joint names, types, and which ones are actuated moving_joint_names =  moving_joint_inds =  moving_joint_types =  moving_joint_limits =  moving_joint_centers =  for j_ind in range(num_joints_total): j_info = p.getJointInfo(robotID, j_ind) if j_info != (p.JOINT_FIXED): moving_joint_inds.append(j_ind) moving_joint_names.append(j_info) moving_joint_types.append(j_info) j_limits = [j_info, j_info] j_center = (j_info + j_info)/2 if j_limits<=j_limits: j_limits = [-np.inf, np.inf] j_center = 0 moving_joint_limits.append(j_limits) moving_joint_centers.append(j_center) # set joint states to a standing up pose num_joints = len(moving_joint_names) for i in range(num_joints): center = moving_joint_centers[i] if i in [2,5,8]: addition = -np.pi/2 elif i in [11,14,17]: addition = np.pi/2 else: addition = 0 jind = moving_joint_inds[i] p.resetJointState( bodyUniqueId=robotID, jointIndex = jind, targetValue= center+addition, targetVelocity = 0 ) # enable joint sensors for j in moving_joint_inds: p.enableJointForceTorqueSensor(robotID, j, 1) # steps to take with no control input before starting up # This drops to robot down to a physically possible resting starting position for i in range(200): p.stepSimulation() joint_states = p.getJointStates(robotID, moving_joint_inds, physicsClientId=physicsClient) print('----------') print([j for j in joint_states]) # print out the joint moments too # print([j for j in joint_states]) # print([j for j in joint_states]) # print([j for j in joint_states]) time.sleep(0.01)