Hello,
How can I control the gripper joint to rotate more than 360 degrees in one direction at a time? Instead of allowing it to quickly reach the target pose through the shortest path. Because I want to simulate the action of tightening the screw, I will provide how many turns the gripper should rotate (a double type variable, such as 3.51 turns) and the final coordinates of the end of the gripper (xyz).
Use the ZMQ Remote API.
Thank you for your answer.
Control the joint to rotate more than 360 degrees
Re: Control the joint to rotate more than 360 degrees
If you don't need to use a cyclic joint, simply selecting a joint range larger than 2*pi is enough to make the joint turn more than 1 full revolution when setting a large enough target position (via sim.setJointTargetPosition).
If instead you are forced to used a cyclic joint, the solution is to use a joint callback.
Besides a few limitations of cyclic joint objects, namely:
You simply have to track when the joint position crosses from pi to -pi (or vice-versa) and add (subtract) 2*pi to the joint position value.
Here's a complete example (script attached to joint object):
If instead you are forced to used a cyclic joint, the solution is to use a joint callback.
Besides a few limitations of cyclic joint objects, namely:
- the joint position can be set/get only in the -pi ... pi range
- the joint target position can be set/get only in the -pi ... pi range
- the joint error used in the joint callback is also normalized in a similar way
You simply have to track when the joint position crosses from pi to -pi (or vice-versa) and add (subtract) 2*pi to the joint position value.
Here's a complete example (script attached to joint object):
Code: Select all
function sysCall_init()
sim = require 'sim'
handle = sim.getObject '.'
-- e.g.: set target pos at 3.51 turns
-- (we don't use sim.setJointTargetPosition because modulo 2*pi truncation)
targetPos = math.pi * 2 * 3.51
lastPos = sim.getJointPosition(handle)
posOffset = 0 -- for fixing the joint position value as well
end
function sysCall_joint(inData)
local pos = inData.pos
if lastPos * pos < 0 and math.abs(pos - lastPos) >= math.pi * 2 * 0.8 then
-- crossed pi/-pi pos value:
if pos > lastPos then
posOffset = posOffset - 2 * math.pi
else
posOffset = posOffset + 2 * math.pi
end
end
lastPos = pos
if inData.mode == sim.jointmode_dynamic then
local err = targetPos - pos - posOffset
local ctrl = err * 20
return {
vel = math.max(-inData.maxVel, math.min(inData.maxVel, ctrl)),
force = inData.maxForce
}
end
end
Re: Control the joint to rotate more than 360 degrees
Hello,
Thank you very much for your answer. But I still have a question: the screw tightening motion requires the robotic arm end to rotate while moving downwards. When using sim.moveToConfig, I can only configure the joint position (rotation angle) of the last joint of the robotic arm, but I cannot know the joint positions of other joints, only the position of the robotic arm end moving downwards.
If I use sim.moveToPose, I cannot rotate the robotic arm more than 360 degrees at once.
Thank you again for your help!
Thank you very much for your answer. But I still have a question: the screw tightening motion requires the robotic arm end to rotate while moving downwards. When using sim.moveToConfig, I can only configure the joint position (rotation angle) of the last joint of the robotic arm, but I cannot know the joint positions of other joints, only the position of the robotic arm end moving downwards.
If I use sim.moveToPose, I cannot rotate the robotic arm more than 360 degrees at once.
Thank you again for your help!
Re: Control the joint to rotate more than 360 degrees
It is correct to use sim.moveToConfig.
You can use a 1-dimensional config, starting from
To interpolate between 2 joint positions you can use and similarly for 3D position.
To interpolate between two poses you can use
You can use a 1-dimensional config, starting from
{0}
, ending in {1}
, which would be the parameter for interpolation between an initial and a final config/position/pose.To interpolate between 2 joint positions you can use
Code: Select all
(1 - config[1]) * initialJointPos + config[1] * finalJointPos
To interpolate between two poses you can use
Code: Select all
sim.getPathInterpolatedConfig({x1,y1,z1,qx1,qy1,qz1,qw1,x2,y2,z2,qx2,qy2,qz2,qw2}, {0, 1}, config[1])
Re: Control the joint to rotate more than 360 degrees
Thank you.
But I still don't quite understand. What does config[1] represent? And I'm afraid I can't fully know the initial and final joint positions of the robotic arm.
If I use pose for interpolation, can I specify how many turns the gripper of the robotic arm should rotate to reach the target pose?
But I still don't quite understand. What does config[1] represent? And I'm afraid I can't fully know the initial and final joint positions of the robotic arm.
If I use pose for interpolation, can I specify how many turns the gripper of the robotic arm should rotate to reach the target pose?
Re: Control the joint to rotate more than 360 degrees
config[1]
is the numeric parameter that goes from 0 to 1