Can I do a kinematics redundancy by using inverse kinematics?
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Yiping Liu
2020-12-10
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 个评论
Yiping Liu
2020-12-17
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Code Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!