Can I do a kinematics redundancy by using inverse kinematics?

3 views (last 30 days)
Ranatchai Laosiripong
Ranatchai Laosiripong on 9 Dec 2020
Commented: Yiping Liu on 17 Dec 2020
Are there any ways to do Inverse kinematic and get something like this?
what constrait do I need to add?
I tried to do something like this, but it doesn't well succeed
lbr = importrobot('iiwa14.urdf');
lbr.DataFormat = 'row';
initialguess = lbr.homeConfiguration;
gripper = 'iiwa_link_ee_kuka';
link1 = 'iiwa_link_1';
count = 1;
gik = generalizedInverseKinematics('RigidBodyTree',lbr,'ConstraintInputs',{'pose','orientation','joint'});
poseConst = constraintPoseTarget(gripper);
poseConst.TargetTransform = trvec2tform([0.5 0.5 0.4])*eul2tform([0 0 -pi]);
jointConst = constraintJointBounds(lbr);
maxJointChange = deg2rad(10);
orientationConst = constraintOrientationTarget(link1);
min = -70;
max = 70;
for i = min:10:max
if i == min
jointConst.Weights = zeros(size(jointConst.Weights));
orientationConst.TargetOrientation = eul2quat([deg2rad(i) 0 0]);
qs(count,:) = gik(initialguess,poseConst,orientationConst,jointConst);
initialguess = qs(count,:);
count = count+1;
else
jointConst.Weights = ones(size(jointConst.Weights))*0.25;
jointConst.Bounds = [qs(count-1,:)' - maxJointChange, qs(count-1,:)' + maxJointChange];
orientationConst.TargetOrientation = eul2quat([deg2rad(i) 0 0]);
orientation.Weights = ones(size(orientationConst.Weights))*0.25;
qs(count,:) = gik(initialguess,poseConst,orientationConst,jointConst);
initialguess = qs(count,:);
count = count+1;
end
end
framesPerSecond = 5;
r = rateControl(framesPerSecond);
for i = 1:count-1
show(lbr,qs(i,:),'PreservePlot',false);
% show(lbr,qs(i,:));
drawnow
waitfor(r);
end

Answers (1)

Yiping Liu
Yiping Liu on 10 Dec 2020
You sould not use orientationTarget for link1.
Try something like below (You only need pose and joint constraints)
lbr = importrobot('iiwa14.urdf');
lbr.DataFormat = 'row';
initialguess = lbr.homeConfiguration;
gripper = 'iiwa_link_ee_kuka';
link1 = 'iiwa_link_1';
count = 1;
gik = generalizedInverseKinematics('RigidBodyTree',lbr,'ConstraintInputs',{'pose','joint'});
poseConst = constraintPoseTarget(gripper);
poseConst.TargetTransform = trvec2tform([0.5 0.5 0.4])*eul2tform([0 0 -pi]);
jointConst = constraintJointBounds(lbr);
maxJointChange = deg2rad(10);
min = -70;
max = 70;
for i = min:5:max
if i == min
qs(count,:) = gik(initialguess,poseConst,jointConst);
initialguess = qs(count,:);
count = count+1;
else
bounds = jointConst.Bounds;
bounds(1,:) = [initialguess(1) + 0.025, bounds(1,2)];
jointConst.Bounds = bounds;
qs(count,:) = gik(initialguess,poseConst,jointConst);
initialguess = qs(count,:);
count = count+1;
end
end
for i = 1:count-1
if i == 1
ax = show(lbr,qs(i,:),'PreservePlot',false);
view(ax, 80, 36);
else
show(lbr,qs(i,:),'PreservePlot',false, 'Parent', ax);
end
drawnow
hold on
end
  6 Comments
Yiping Liu
Yiping Liu on 17 Dec 2020
I just tested the script in 2020b release and I get exactly the same result shown above. Maybe some internal files in your MATLAB installation got corrupted? I would suggest you start a tech support case regarding this issue.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!