基于逆运动学的二维路径跟踪

介绍:

这个例子展示了如何使用inverseKinematics类计算简单的2D机械手的逆运动学。该机器人是一种简单的2自由度平面机械臂,具有转动关节,通过将刚体组装成一个rigidBodyTree对象来生成。在二维平面上创建一个圆形轨迹,并将其作为指向逆运动学求解器的点。求解器计算所需的关节位置来实现这一轨迹。最后,对机器人进行动画化处理,以显示实现圆形轨迹的机器人构型。

如何构建机器人:

创建一个rigidBodyTree对象和刚体及其相关关节。指定每个刚体的几何属性,并将其添加到机器人中。

首先:

robot = rigidBodyTree('DataFormat','column','MaxNumBodies',3);

指定机器人手臂的手臂长度

L1 = 0.3;
L2 = 0.3;

然后描述机器人关节:

body = rigidBody('link1');
joint = rigidBodyJoint('joint1', 'revolute');
setFixedTransform(joint,trvec2tform([0 0 0]));
joint.JointAxis = [0 0 1];
body.Joint = joint;
addBody(robot, body, 'base');

然后在描述机器人末端执行器与固定关节

body = rigidBody('tool');
joint = rigidBodyJoint('fix1','fixed');
setFixedTransform(joint, trvec2tform([L2, 0, 0]));
body.Joint = joint;
addBody(robot, body, 'link2');

查看机器人的属性:

showdetails(robot)

接下来描述机器人的运动轨迹

定义一个圆形跟踪轨迹

这个圆在xy平面上,半径为0.15

t = (0:0.2:10)'; % Time
count = length(t);
center = [0.3 0.1 0];
radius = 0.15;
theta = t*(2*pi/t(end));
points = center + radius*[cos(theta) sin(theta) zeros(size(theta))];

逆运动学求解过程:

q0 = homeConfiguration(robot);
ndof = length(q0);
qs = zeros(count, ndof);
ik = inverseKinematics('RigidBodyTree', robot);
weights = [0, 0, 0, 1, 1, 0];
endEffector = 'tool';

跟踪轨迹:

qInitial = q0; % Use home configuration as the initial guess
for i = 1:count
    % Solve for the configuration satisfying the desired end effector
    % position
    point = points(i,:);
    qSol = ik(endEffector,trvec2tform(point),weights,qInitial);
    % Store the configuration
    qs(i,:) = qSol;
    % Start from prior solution
    qInitial = qSol;
end

绘图可视化:

figure
show(robot,qs(1,:)');
view(2)
ax = gca;
ax.Projection = 'orthographic';
hold on
plot(points(:,1),points(:,2),'k')
axis([-0.1 0.7 -0.3 0.5])

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值