Home > arte3.2.0 > tools > draw_link.m

draw_link

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function draw_link(robot, i, T)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   DRAW_LINK(ROBOT, I, T) 

   Draws the I link of the robot according to the transformation matrix T,
   where:
   ROBOT is the current object storing the robot parameters. The graphical
   representation of the robot is stored in the variables 
   robot.graphical.link{1}.v --> robot base
   robot.graphical.link{2}.v --> link 1...

   If the robot has graphics the variable robot.graphical.has_graphics
   must be set.

   I is the current link number being drawn.

   T is the global transformation that relates the base reference system
   of the robot with the link's reference system.

   If the variable robot.graphical.draw_axes is set, the reference system
   associated with link i is drawn with arrows X (red), Y (green), Z (blue)

    See also DRAWROBOT3D, ANIMATE

   Author: Arturo Gil. Universidad Miguel Hernández de Elche.
   email: arturo.gil@umh.es date:   05/02/2012
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %   DRAW_LINK(ROBOT, I, T)
0003 %
0004 %   Draws the I link of the robot according to the transformation matrix T,
0005 %   where:
0006 %   ROBOT is the current object storing the robot parameters. The graphical
0007 %   representation of the robot is stored in the variables
0008 %   robot.graphical.link{1}.v --> robot base
0009 %   robot.graphical.link{2}.v --> link 1...
0010 %
0011 %   If the robot has graphics the variable robot.graphical.has_graphics
0012 %   must be set.
0013 %
0014 %   I is the current link number being drawn.
0015 %
0016 %   T is the global transformation that relates the base reference system
0017 %   of the robot with the link's reference system.
0018 %
0019 %   If the variable robot.graphical.draw_axes is set, the reference system
0020 %   associated with link i is drawn with arrows X (red), Y (green), Z (blue)
0021 %
0022 %    See also DRAWROBOT3D, ANIMATE
0023 %
0024 %   Author: Arturo Gil. Universidad Miguel Hernández de Elche.
0025 %   email: arturo.gil@umh.es date:   05/02/2012
0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0027 
0028 % Copyright (C) 2012, by Arturo Gil Aparicio
0029 %
0030 % This file is part of ARTE (A Robotics Toolbox for Education).
0031 %
0032 % ARTE is free software: you can redistribute it and/or modify
0033 % it under the terms of the GNU Lesser General Public License as published by
0034 % the Free Software Foundation, either version 3 of the License, or
0035 % (at your option) any later version.
0036 %
0037 % ARTE is distributed in the hope that it will be useful,
0038 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0039 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0040 % GNU Lesser General Public License for more details.
0041 %
0042 % You should have received a copy of the GNU Leser General Public License
0043 % along with ARTE.  If not, see <http://www.gnu.org/licenses/>.
0044 function draw_link(robot, i, T)
0045 
0046 if robot.graphical.has_graphics
0047     %Now draw points
0048     %obtain arm points
0049     V=robot.graphical.link{i}.v;
0050     V(:,4) = ones(length(V),1); %homogeneous coordinates
0051     
0052     %transform points according to current coordinates
0053     V = (T*V')';
0054     V  = V(:,1:3);
0055     %set robot.graphical.color to add a desired color to your robot
0056     draw_patch(robot.graphical.link{i}.f,V,robot.graphical.color, robot.graphical.draw_transparent);
0057 end

Generated on Fri 03-Jan-2014 12:20:01 by m2html © 2005