I use the python API function simxSetJointTargetPosition to set a potion of joint. When the angle to be set is smaller than 180 degree(pi), the joint rotates anticlockwise, while the angle bigger than pi(180 degree) the joint rotates clockwise. I wonder know how can I keep it rotates just in one direction(clockwise or anticlockwise)? I use the joint as a motor to drive the wheel of robot and want to control it by setting position.
looking forward to your reply. Thank you!
Code: Select all
motors_postion_to_set = [ [1/4*math.pi,3/4*math.pi,1/4*math.pi,3/4*math.pi,1/4*math.pi,3/4*math.pi], #第一个状态
[1/2*math.pi,3/2*math.pi,1/2*math.pi,3/2*math.pi,1/2*math.pi,3/2*math.pi], #第二个状态
[3/2*math.pi,1/2*math.pi,3/2*math.pi,1/2*math.pi,3/2*math.pi,1/2*math.pi], #第三个状态
[7/4*math.pi,5/4*math.pi,7/4*math.pi,5/4*math.pi,7/4*math.pi,5/4*math.pi] #第四个状态
] #将要设定的电机位置值
def set_all_positon(posture):
for i in range(6):
vrep.simxSetJointTargetPosition(clientID,motor_handle[i],motors_postion_to_set[posture][i],vrep.simx_opmode_oneshot)
print('电机位置:',vrep.simxGetJointPosition(clientID,motor_handle[0],vrep.simx_opmode_blocking))