📄 drivebot.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 drivebot</title> <meta name="keywords" content="drivebot"> <meta name="description" content="DRIVEBOT Drive a graphical robot"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="generator" content="m2html © 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> > <a href="index.html">.</a> > drivebot.m</div><!--<table width="100%"><tr><td align="left"><a href="./index.html"><img alt="<" border="0" src="./left.png"> Master index</a></td><td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="./right.png"></a></td></tr></table>--><h1>drivebot</h1><h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="./up.png"></a></h2><div class="box"><strong>DRIVEBOT Drive a graphical robot</strong></div><h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="./up.png"></a></h2><div class="box"><strong>function drivebot(a,b) </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">DRIVEBOT Drive a graphical robot DRIVEBOT(ROBOT) DRIVEBOT(ROBOT, Q) Drive a graphical robot by means of a slider panel. If no graphical robot exists one is created in a new window. Otherwise all graphical robots are 'driven'. If Q is specified it is used as the initial joint angle, otherwise it is taken from one of the existing graphical robots. SEE ALSO: ROBOT/PLOT, ROBOT</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)"><li><a href="fkine.html" class="code" title="function t = fkine(robot, q)">fkine</a> FKINE Forward robot kinematics for serial link manipulator</li></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">%DRIVEBOT Drive a graphical robot</span>0002 <span class="comment">%</span>0003 <span class="comment">% DRIVEBOT(ROBOT)</span>0004 <span class="comment">% DRIVEBOT(ROBOT, Q)</span>0005 <span class="comment">%</span>0006 <span class="comment">% Drive a graphical robot by means of a slider panel.</span>0007 <span class="comment">%</span>0008 <span class="comment">% If no graphical robot exists one is created in a new window. Otherwise</span>0009 <span class="comment">% all graphical robots are 'driven'.</span>0010 <span class="comment">%</span>0011 <span class="comment">% If Q is specified it is used as the initial joint angle, otherwise</span>0012 <span class="comment">% it is taken from one of the existing graphical robots.</span>0013 <span class="comment">%</span>0014 <span class="comment">% SEE ALSO: ROBOT/PLOT, ROBOT</span>0015 0016 <span class="comment">% Copyright (C) 2001-2008, by Peter I. Corke</span>0017 <span class="comment">%</span>0018 <span class="comment">% This file is part of The Robotics Toolbox for Matlab (RTB).</span>0019 <span class="comment">%</span>0020 <span class="comment">% RTB is free software: you can redistribute it and/or modify</span>0021 <span class="comment">% it under the terms of the GNU Lesser General Public License as published by</span>0022 <span class="comment">% the Free Software Foundation, either version 3 of the License, or</span>0023 <span class="comment">% (at your option) any later version.</span>0024 <span class="comment">%</span>0025 <span class="comment">% RTB is distributed in the hope that it will be useful,</span>0026 <span class="comment">% but WITHOUT ANY WARRANTY; without even the implied warranty of</span>0027 <span class="comment">% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>0028 <span class="comment">% GNU Lesser General Public License for more details.</span>0029 <span class="comment">%</span>0030 <span class="comment">% You should have received a copy of the GNU Leser General Public License</span>0031 <span class="comment">% along with RTB. If not, see <http://www.gnu.org/licenses/>.</span>0032 0033 <a name="_sub0" href="#_subfunctions" class="code">function drivebot(a,b)</a>0034 bgcol = [135 206 250]/255;0035 0036 <span class="keyword">if</span> isstr(a)0037 <span class="comment">% drivebot(name, j), graphical callback function</span>0038 name = a; <span class="comment">% name of the robot</span>0039 j = b; <span class="comment">% joint index</span>0040 <span class="comment">%disp(name)</span>0041 rh = findobj(<span class="string">'Tag'</span>, name);0042 <span class="comment">%disp(rh)</span>0043 handles = get(gco, <span class="string">'Userdata'</span>);0044 scale = handles{3};0045 <span class="keyword">for</span> r=rh',0046 rr = get(r, <span class="string">'UserData'</span>);0047 q = rr.q;0048 <span class="keyword">if</span> isempty(q),0049 q = zeros(1,rr.n);0050 <span class="keyword">end</span>0051 <span class="keyword">if</span> gco == handles{1},0052 <span class="comment">% get value from slider</span>0053 q(j) = get(gco, <span class="string">'Value'</span>) / scale(j);0054 set(handles{2}, <span class="string">'String'</span>, num2str(scale(j)*q(j)));0055 <span class="keyword">else</span>0056 <span class="comment">% get value from text box</span>0057 q(j) = str2num(get(gco, <span class="string">'String'</span>)) / scale(j);0058 set(handles{1}, <span class="string">'Value'</span>, q(j));0059 <span class="keyword">end</span>0060 rr.q = q;0061 set(r, <span class="string">'UserData'</span>, rr);0062 plot(rr, q)0063 <span class="keyword">end</span>0064 0065 <span class="comment">% compute and display the T6 pose</span>0066 t6 = <a href="fkine.html" class="code" title="function t = fkine(robot, q)">fkine</a>(rr, q);0067 h3 = get(findobj(<span class="string">'Tag'</span>, <span class="string">'T6'</span>), <span class="string">'UserData'</span>);0068 <span class="keyword">for</span> i=1:3,0069 set(h3(i,1), <span class="string">'String'</span>, sprintf(<span class="string">'%.3f'</span>, t6(i,4)));0070 set(h3(i,2), <span class="string">'String'</span>, sprintf(<span class="string">'%.3f'</span>, t6(i,3)));0071 <span class="keyword">end</span>0072 <span class="keyword">else</span>0073 <span class="comment">% drivebot(r, q)</span>0074 <span class="comment">% drivebot(r, 'deg')</span>0075 r = a;0076 scale = ones(r.n,1);0077 0078 n = r.n;0079 width = 300;0080 height = 40;0081 minVal = -pi;0082 maxVal = pi; 0083 0084 qlim = r.qlim;0085 <span class="keyword">if</span> isempty(qlim),0086 qlim = [minVal*ones(r.n,1) maxVal*ones(r.n,1)];0087 <span class="keyword">end</span>0088 0089 <span class="keyword">if</span> nargin < 2,0090 q = zeros(1,n);0091 <span class="keyword">else</span>0092 <span class="keyword">if</span> isstr(b),0093 <span class="keyword">if</span> strncmp(b, <span class="string">'deg'</span>, 3),0094 disp(<span class="string">'** in degree mode'</span>)0095 L = r.link;0096 <span class="keyword">for</span> i=1:r.n,0097 <span class="keyword">if</span> L{i}.sigma == 0,0098 scale(i) = 180/pi;0099 <span class="keyword">end</span>0100 <span class="keyword">end</span>0101 <span class="keyword">end</span>0102 <span class="keyword">else</span>0103 q = b;0104 <span class="keyword">end</span>0105 <span class="keyword">end</span>0106 t6 = <a href="fkine.html" class="code" title="function t = fkine(robot, q)">fkine</a>(r, q);0107 fig = figure(<span class="string">'Units'</span>, <span class="string">'pixels'</span>, <span class="keyword">...</span>0108 <span class="string">'Position'</span>, [0 -height width height*(n+2)], <span class="keyword">...</span>0109 <span class="string">'Color'</span>, bgcol);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -