Robotics System Toolbox —— 使用笔记1

环境: MATLAB R2019b

1. 机器人建模

第一种:导入法

  • step1:建议直接通过SolidWorks导出urdf文件
  • step2:导入urdf文件,robot_name = import('file_name.urdf')
  • step3:显示机器人,show(robot_name)

第二种:加载法(适合工具箱中已有机器人)
robot = loadrobot('kinovaGen3','DataFormat','row','Gravity',[0 0 -9.81]);

2. 设置当前关节配置并获取关节轴数

  • 设置当前关节配置:currentRobotJConfig = homeConfiguration(robot_name)
  • 获得关节轴数:numJoints = numel(currentRobotJConfig);

3. 查看并设置工具坐标系

在这里插入图片描述
endEffector = "EndEffector_Link";

4. 获取某一姿态下的齐次变换矩阵

  • tf = getTransform(tftree,targetframe,sourceframe)
  • tf = getTransform(tftree,targetframe,sourceframe,sourcetime)
  • tf = getTransform(___,“Timeout”,timeout)
  • tf = getTransform(bagSel,targetframe,sourceframe)
  • tf = getTransform(bagSel,targetframe,sourceframe,sourcetime)
    例:taskInit = getTransform(robot_name,jointInit,endEffector) %获取jointInit位姿下的到末端的齐次变换矩阵
    T07 = getTransform(robot_name,home,'link7') %获取home位姿下连杆坐标系7到基坐标系的齐次变换矩阵

5. 生成齐次变换矩阵

  • 指定齐次变换矩阵中的笛卡尔坐标部分: trvec2tform([x y z])
    在这里插入图片描述
  • 指定姿态,绕某一轴旋转多少度:axang2tform([0 0 1 pi/2]) %绕z轴旋转90度

绕哪个轴旋转,修改哪个轴为1 ,例如绕x轴旋转30度:`axang2tform([1 0 0 pi/6])’
在这里插入图片描述

	jointInit = currentRobotJConfig;
	taskInit = getTransform(robot,jointInit,endEffector);
	taskFinal = trvec2tform([0.4,0,0.6])*axang2tform([0 1 0 pi]);

6. 任务空间轨迹的生成

  • step1:求欧氏距离,distance = norm(tform2trvec(taskInit)-tform2trvec(taskFinal))

  • step2:根据行进距离和所需工具坐标的速度定义轨迹时间

    timeStep = 0.1;%秒,时间插值步长
    toolSpeed = 0.1;% m/s ,工具坐标速度
    initTime = 0;	% 起始时间
    finalTime = (distance/toolSpeed) - initTime;% 计算运行时间
    trajTimes = initTime:timeStep:finalTime;	% 插值时间
    timeInterval = [trajTimes(1); trajTimes(end)]; % 起始时间区间
    
  • step3:插值计算中间任务空间航路点

    [tforms,vel,acc] = transformtraj(T0,TF,时间区间,时间样本)
    [tforms,vel,acc] = transformtraj(T0,TF,tInterval,tSamples,Name,Value)

例:[taskWaypoints,taskVelocities] = transformtraj(taskInit,taskFinal,timeInterval,trajTimes)

返回的tforms是中间插值点的齐次变换矩阵形式,返回的速度和加速度是每个关节的关节速度和加速度

7. 逆运动学

  • ik = inverseKinematics

  • ik = inverseKinematics(Name,Value)

  • [configSol,solInfo] = ik(endeffector,pose,weights,initialguess)

  • step1:为机器人创建一个逆运动学对象

    ik = inverseKinematics('RigidBodyTree',robot);
    % rigidBodyTree根据关节之间的转换在机器人模型中指定机器人运动学约束。
    ik.SolverParameters.AllowRandomRestart = false;
    weights = [1 1 1 1 1 1];
    
  • step2:使用逆运动学计算初始和所需的关节配置

    initialGuess = wrapToPi(jointInit);
    jointFinal = ik(endEffector,taskFinal,weights,initialGuess);
    jointFinal = wrapToPi(jointFinal);
    

8. 关节空间插值

  • 使用三次多项式函数在它们之间进行插值以生成均匀间隔的关节配置的数组,使用B样条曲线生成平滑的轨迹

    ctrlpoints = [jointInit',jointFinal'];
    jointConfigArray = cubicpolytraj(ctrlpoints,timeInterval,trajTimes);
    jointWaypoints = bsplinepolytraj(jointConfigArray,timeInterval,1);
    

9.轨迹生成函数/simulink模块

函数说明
bsplinepolytraj使用B样条生成多项式轨迹
cubicpolytraj生成三阶多项式轨迹
quinticpolytraj生成五阶轨迹
rottraj生成方向旋转矩阵之间的轨迹
transformtraj在两个转换之间生成轨迹
trapveltraj生成具有梯形速度轮廓的轨迹
模块名称说明
Polynomial Trajectory通过航路点生成多项式轨迹
Rotation Trajectory生成两个方向之间的轨迹
Transform Trajectory在两个齐次变换之间生成轨迹
Trapezoidal Velocity Profile Trajectory使用梯形速度轮廓通过多个航路点生成轨迹

9. 坐标变换

函数说明
axang2quat将轴角旋转转换为四元数
axang2rotm将轴角旋转转换为旋转矩阵
axang2tform将轴角旋转转换为均匀变换
eul2quat将欧拉角转换为四元数
eul2rotm将欧拉角转换为旋转矩阵
eul2tform将欧拉角转换为均匀变换
quat2axang将四元数转换为轴角旋转
quat2eul将四元数转换为欧拉角
quat2rotm将四元数转换为旋转矩阵
quat2tform将四元数转换为齐次变换
quaternion创建一个四元数数组
rotm2axang将旋转矩阵转换为轴角旋转
rotm2eul将旋转矩阵转换为欧拉角
rotm2quat将旋转矩阵转换为四元数
rotm2tform将旋转矩阵转换为齐次变换
tform2axang将齐次变换转换为轴角旋转
tform2eul从齐次变换中提取欧拉角
tform2quat从齐次变换中提取四元数
tform2rotm从齐次变换中提取旋转矩阵
tform2trvec从齐次变换中提取平移向量
angdiff两个角度之间的差异
cart2hom将笛卡尔坐标转换为齐次坐标
hom2cart将齐次坐标转换为笛卡尔坐标
trvec2tform将平移向量转换为齐次变换

10. 逆运动学

https://ww2.mathworks.cn/help/robotics/inverse-kinematics.html

11. 碰撞检测

https://ww2.mathworks.cn/help/robotics/collision-detection.html

12. 机器人建模与仿真

https://ww2.mathworks.cn/help/robotics/modeling-and-simulation.html


参考文献:
https://ww2.mathworks.cn/help/robotics/examples/plan-and-execute-trajectory-kinova-gen3.html

https://ww2.mathworks.cn/help/robotics/index.html?s_tid=CRUX_lftnav

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值