Can I do a kinematics redundancy by using inverse kinematics?

조회 수: 11 (최근 30일)
Ranatchai Laosiripong
Ranatchai Laosiripong 2020년 12월 9일
댓글: Yiping Liu 2020년 12월 17일
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

답변 (1개)

Yiping Liu
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
Ranatchai Laosiripong
Ranatchai Laosiripong 2020년 12월 17일
Your qs is running quite smooth like you said.
I use 2020b version. It's really weird that I get different result from you.
Yiping Liu
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 CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by