Torque control issue

Post Reply
anshul96
Posts: 2
Joined: Wed Jul 01, 2020 3:58 pm

Torque control issue

Post by anshul96 »

Hello, I am trying to control UR5 with Torque control but it doesn't seem to work, I have gone through tutorial and Example and used the same process but the result are not good. Please explain why?
I used follwoing code:

INTILIZATION
***************************************************************************

import pybullet as p
import time
import pybullet_data
import math
import numpy as np
import matplotlib.pyplot as plt

physicsClient = p.connect(p.GUI) # or p.DIRECT for non-graphical version
p.setAdditionalSearchPath(pybullet_data.getDataPath()) # optionally
p.setGravity(0, 0, -10) # describe gravity in (x,y,z)
planeId = p.loadURDF("plane.urdf")
base_Position = [0, 0, 1]
UR5Id = p.loadURDF(
## PUT THE URDF FILE PATH HERE, IN MY CASE = /home/anshul/Documents/pybulletproject/robot_movement_interface/dependencies/ur_description/urdf/ur5_robot.urdf
"/home/anshul/Documents/pybulletproject/robot_movement_interface/dependencies/ur_description/urdf/ur5_robot.urdf",
useFixedBase=1, basePosition=base_Position)


p.setRealTimeSimulation(0)
target_ori_euler = [-math.pi / 2, -math.pi / 2, 0]
target_ori_quaternion = p.getQuaternionFromEuler(target_ori_euler)

*********************************************************************************

PART WHERE I USED - setJointMotorControlArray COMMAND:

for i in range(1,7):
p.setJointMotorControl2(UR5Id, i,controlMode=p.VELOCITY_CONTROL, force=0) ##To disable the default Velocity/position control
print(p.getJointState(UR5Id, i))

p.setJointMotorControlArray(UR5Id,range(1,7) ,controlMode=p.TORQUE_CONTROL, forces=[240]*6)
p.stepSimulation())



OR -----
for i in range(1,7):
p.setJointMotorControl2(UR5Id, i,controlMode=p.VELOCITY_CONTROL, force=0) ####To disable the default Velocity/position control
print(p.getJointState(UR5Id, i))

for i in range(1,7):
p.setJointMotorControlArray(UR5Id,i ,controlMode=p.TORQUE_CONTROL, forces=[240 ]*6)
p.stepSimulation()
p.setTimeStep(1/240)
print(p.getJointStates(UR5Id, i))


WHEN I CHECK THE JOINT TORQUE APPLIED IT SHOWS THE FORCEs I APPLY IN VELOCITY CONTROL. Thanks for the help.
Anshul
Post Reply