⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtikdemo.html

📁 Robot tool box - provides many functions that are useful in robotics including such things as kinem
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"                "http://www.w3.org/TR/REC-html40/loose.dtd"><html><head>  <title>Description of rtikdemo</title>  <meta name="keywords" content="rtikdemo">  <meta name="description" content="RIKNDEMO Inverse kinematics demo">  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">  <meta name="robots" content="index, follow">  <link type="text/css" rel="stylesheet" href="../m2html.css"></head><body><a name="_top"></a><div><a href="../index.html">Home</a> &gt;  <a href="#">demos</a> &gt; rtikdemo.m</div><!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td><td align="right"><a href="index.html">Index for ./demos&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>--><h1>rtikdemo</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>RIKNDEMO Inverse kinematics demo</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="box"><strong>This is a script file. </strong></div><h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre class="comment">RIKNDEMO Inverse kinematics demo</pre></div><!-- crossreference --><h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>This function calls:<ul style="list-style-image:url(../matlabicon.gif)"></ul>This function is called by:<ul style="list-style-image:url(../matlabicon.gif)"></ul><!-- crossreference --><h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2><div class="fragment"><pre>0001 <span class="comment">%RIKNDEMO Inverse kinematics demo</span>0002 0003 <span class="comment">% Copyright (C) 1993-2002, by Peter I. Corke</span>0004 0005 <span class="comment">% $Log: not supported by cvs2svn $</span>0006 <span class="comment">% Revision 1.3  2002-04-02 12:26:49  pic</span>0007 <span class="comment">% Handle figures better, control echo at end of each script.</span>0008 <span class="comment">% Fix bug in calling ctraj.</span>0009 <span class="comment">%</span>0010 <span class="comment">% Revision 1.2  2002/04/01 11:47:17  pic</span>0011 <span class="comment">% General cleanup of code: help comments, see also, copyright, remnant dh/dyn</span>0012 <span class="comment">% references, clarification of functions.</span>0013 <span class="comment">%</span>0014 <span class="comment">% $Revision: 1.1 $</span>0015 figure(2)0016 echo on0017 <span class="comment">%</span>0018 <span class="comment">% Inverse kinematics is the problem of finding the robot joint coordinates,</span>0019 <span class="comment">% given a homogeneous transform representing the last link of the manipulator.</span>0020 <span class="comment">% It is very useful when the path is planned in Cartesian space, for instance</span>0021 <span class="comment">% a straight line path as shown in the trajectory demonstration.</span>0022 <span class="comment">%</span>0023 <span class="comment">% First generate the transform corresponding to a particular joint coordinate,</span>0024     q = [0 -pi/4 -pi/4 0 pi/8 0]0025     T = fkine(p560, q);0026 <span class="comment">%</span>0027 <span class="comment">% Now the inverse kinematic procedure for any specific robot can be derived</span>0028 <span class="comment">% symbolically and in general an efficient closed-form solution can be</span>0029 <span class="comment">% obtained.  However we are given only a generalized description of the</span>0030 <span class="comment">% manipulator in terms of kinematic parameters so an iterative solution will</span>0031 <span class="comment">% be used. The procedure is slow, and the choice of starting value affects</span>0032 <span class="comment">% search time and the solution found, since in general a manipulator may</span>0033 <span class="comment">% have several poses which result in the same transform for the last</span>0034 <span class="comment">% link. The starting point for the first point may be specified, or else it</span>0035 <span class="comment">% defaults to zero (which is not a particularly good choice in this case)</span>0036     qi = ikine(p560, T);0037     qi'0038 <span class="comment">%</span>0039 <span class="comment">% Compared with the original value</span>0040     q0041 <span class="comment">%</span>0042 <span class="comment">% A solution is not always possible, for instance if the specified transform</span>0043 <span class="comment">% describes a point out of reach of the manipulator.  As mentioned above</span>0044 <span class="comment">% the solutions are not necessarily unique, and there are singularities</span>0045 <span class="comment">% at which the manipulator loses degrees of freedom and joint coordinates</span>0046 <span class="comment">% become linearly dependent.</span>0047 pause <span class="comment">% any key to continue</span>0048 <span class="comment">%</span>0049 <span class="comment">% To examine the effect at a singularity lets repeat the last example but for a</span>0050 <span class="comment">% different pose.  At the `ready' position two of the Puma's wrist axes are</span>0051 <span class="comment">% aligned resulting in the loss of one degree of freedom.</span>0052     T = fkine(p560, qr);0053     qi = ikine(p560, T);0054     qi'0055 <span class="comment">%</span>0056 <span class="comment">% which is not the same as the original joint angle</span>0057     qr0058 pause <span class="comment">% any key to continue</span>0059 <span class="comment">%</span>0060 <span class="comment">% However both result in the same end-effector position</span>0061     fkine(p560, qi) - fkine(p560, qr)0062 pause <span class="comment">% any key to continue</span>0063     0064 <span class="comment">% Inverse kinematics may also be computed for a trajectory.</span>0065 <span class="comment">% If we take a Cartesian straight line path</span>0066     t = [0:.056:2];         <span class="comment">% create a time vector</span>0067     T1 = transl(0.6, -0.5, 0.0) <span class="comment">% define the start point</span>0068     T2 = transl(0.4, 0.5, 0.2)    <span class="comment">% and destination</span>0069     T = ctraj(T1, T2, length(t));     <span class="comment">% compute a Cartesian path</span>0070 0071 <span class="comment">%</span>0072 <span class="comment">% now solve the inverse kinematics.  When solving for a trajectory, the</span>0073 <span class="comment">% starting joint coordinates for each point is taken as the result of the</span>0074 <span class="comment">% previous inverse solution.</span>0075 <span class="comment">%</span>0076     tic0077     q = ikine(p560, T); 0078     toc0079 <span class="comment">%</span>0080 <span class="comment">% Clearly this approach is slow, and not suitable for a real robot controller</span>0081 <span class="comment">% where an inverse kinematic solution would be required in a few milliseconds.</span>0082 <span class="comment">%</span>0083 <span class="comment">% Let's examine the joint space trajectory that results in straightline</span>0084 <span class="comment">% Cartesian motion</span>0085     subplot(3,1,1)0086     plot(t,q(:,1))0087     xlabel(<span class="string">'Time (s)'</span>);0088     ylabel(<span class="string">'Joint 1 (rad)'</span>)0089     subplot(3,1,2)0090     plot(t,q(:,2))0091     xlabel(<span class="string">'Time (s)'</span>);0092     ylabel(<span class="string">'Joint 2 (rad)'</span>)0093     subplot(3,1,3)0094     plot(t,q(:,3))0095     xlabel(<span class="string">'Time (s)'</span>);0096     ylabel(<span class="string">'Joint 3 (rad)'</span>)0097 0098 pause <span class="comment">% hit any key to continue</span>0099     0100 <span class="comment">% This joint space trajectory can now be animated</span>0101     plot(p560, q)0102 pause <span class="comment">% any key to continue</span>0103 echo off</pre></div><hr><address>Generated on Sun 15-Feb-2009 18:09:29 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -