Rotation direction of joint problem using simxSetJointTargetPosition.

Typically: "How do I... ", "How can I... " questions
Post Reply
Meoow
Posts: 1
Joined: 16 Jul 2018, 02:31

Rotation direction of joint problem using simxSetJointTargetPosition.

Post by Meoow » 10 Sep 2018, 07:17

Hello,
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))


fferri
Posts: 209
Joined: 09 Sep 2013, 19:28

Re: Rotation direction of joint problem using simxSetJointTargetPosition.

Post by fferri » 10 Sep 2018, 16:39

You can customize the joint control loop by using a joint callback function.

Post Reply