MAGIKS  1.1
Manipulator General Inverse Kinematic Solver
 All Classes Namespaces Files Functions Variables Pages
manipulator_geometry.py
Go to the documentation of this file.
1 # HEADER
2 '''
3 @file: manipulator_geometry.py
4 @brief: This module provides a class representing the positions and orientations of each of the links of a manipulator.
5  Includes list of relative and absolute transformation matrices and a method for calculating them from given configuration.
6 @author: Nima Ramezani Taghiabadi
7  PhD Researcher
8  Faculty of Engineering and Information Technology
9  University of Technology Sydney (UTS)
10  Broadway, Ultimo, NSW 2007, Australia
11  Mobile: 04 5027 4611
12  Email(1): Nima.RamezaniTaghiabadi@uts.edu.au
13  Email(2): nima.ramezani@gmail.com
14  Email(3): nima_ramezani@yahoo.com
15  Email(4): ramezanitn@alum.sharif.edu
16 @start date: February 2010
17 @version: 3.0
18 Last Revision: 11 August 2015
19 '''
20 '''
21 Changes from previous version:
22  1- function set_config_virtual() added
23 
24 '''
25 
26 # BODY
27 
28 import numpy, math
29 
30 
31 from magiks.jacobian import jacobian as jaclib
32 
33 from magiks.jointspace import manipulator_configuration
34 from math_tools.geometry import rotation
35 
36 ## @brief This class contains geometrical properties and dimensional settings of a chained-link manipulator.
37 # These settings mainly include the standard DH parameters by which the geometry of the manipulator is specified.
38 # These values are based on <em> Denavit Hartenberg </em> standrad representation.
39 # The transformation matrices are calculated based on this standard.
40 # If the joint is revoulte, the value of <tt> theta[i] </tt> is added to <tt> q[i] </tt> in the transformation matrix
41 # If the joint is prismatic, the value of <tt> d[i] </tt> is added by <tt> q[i] </tt> in the transformation matrix
43  ## The Class Constructor:
44  # @param nlink A positive integer specifying the number of links of the manipulator
45  # @param manip_name A character string specifying the name of a manipulator. Examples: \b PR2ARM or \b PA10
46  def __init__(self, nlink, manip_name):
47  self.name = manip_name
48  ## A positive integer containing the number of links of the manipulator
49  self.nlink = nlink
50 
51  ## A numpy vector containing the \f$ \theta \f$ values of the DH parameters
52  # If the proximal joint of the link is revoulte, the value of <tt> theta[i] </tt> is added to <tt> q[i] </tt> in the transformation matrix
53  self.theta = numpy.zeros((nlink))
54 
55  ## A numpy vector containing the \f$ \alpha \f$ values of the DH parameters
56  self.alpha = numpy.zeros((nlink))
57 
58  ## A numpy vector containing the \f$ a \f$ values of the DH parameters
59  self.a = numpy.zeros((nlink))
60 
61  ## A numpy vector containing the \f$ d \f$ values of the DH parameters
62  # If the joint is prismatic, the value of <tt> d[i] </tt> is added to <tt> q[i] </tt> in the transformation matrix
63  self.d = numpy.zeros((nlink))
64 
65 ## @brief This class contains a list of relative and absolute transfer matrices representing the forward kinematics of a manipulator.
66 #
67 class Manipulator_Geometry(manipulator_configuration.Manipulator_Configuration):
68 
69  ## The Class Constructor:
70  # @param config_settings An instance of class
71  # \link magiks.jointspace.manipulator_configuration.Manipulator_Configuration_Settings Manipulator_Configuration_Settings \endlink
72  # containing the configuration settings of the manipulator
73  # @param geo_settings An instance of class Manipulator_Geometry_Settings containing the geometric settings of the manipulator
74  def __init__(self, config_settings, geo_settings):
75  super(Manipulator_Geometry, self).__init__(config_settings)
76 
77  ## An instance of class Manipulator_Geometry_Settings
78  # containing geometry and dimensions of the manipulator in terms of DH parameters
79  self.geo_settings = geo_settings
80 
81  ## An instance of class
82  # \link magiks.jacobian.Analytic_Jacobian Analytic_Jacobian \endlink.
83  # This class contains a two-dimensional list of derivatives of absolute homogeneous transfer matrices with respect to each of the joints
84  self.ajac = jaclib.Analytic_Jacobian(self.config_settings)
85 
86  ## A list of homogeneous transformation matrices.
87  # <tt> T[i] </tt> represents <em> i-1 </em> to \a i transformation matrix. Elements of the list, are <tt> 4 X 4 </tt> matrices.
88  self.T = None
89 
90  ## A list of transformation matrices. <tt> H[i] </tt> represents ground (-1) to i transformation matrix. Elements of the list, are <tt> 4 X 4 </tt> matrices.
91  self.H = None
92 
93  ## This function is used to generate a string representing a set of selected object properties and their values.
94  # If the set of displayed parameters is not specified, property <tt> str_parameter_set </tt> will be used.
95  # @param parameter_set A set of parameters to be displayed in the generated string in abbreviation form
96  # @return A character string containing the object properties specified by argument <tt> parameter_set </tt> with their values
97  def __str__( self, parameter_set = None ) :
98  if parameter_set == None:
99  parameter_set = self.str_parameter_set
100  if parameter_set == []:
101  return ''
102  s = '\n'
103  s += 'Manipulator Configuration:' + '\n' + '\n'
104  for p in parameter_set:
105  value = self.parameter_value(p)
106  param = key_dic[p]
107  s += param + " "*(45-len(param)) + ': ' + value + '\n'
108  return s
109 
110  ## Use this function to get the current homogeneous transfer matrices of the manipulator.
111  # Values of the transfer matrices depend on the manipulator configuration.
112  # @return A list of homogeneous <tt> 4 X 4 </tt> matrices. The i-th element of the list represents the position and orientation of the i-th link.
113  def transfer_matrices(self):
114  if self.H == None:
115  geo = self.geo_settings
116  self.T = [numpy.eye(4) for i in range(0, geo.nlink) ]
117  self.H = [numpy.eye(4) for i in range(0, geo.nlink) ]
118 
119  if self.config_settings.prismatic[0]:
120  self.T[0] = rotation.DH_transfer_matrix(geo.theta[0], geo.alpha[0], geo.a[0], geo.d[0] + self.q[0])
121  else:
122  self.T[0] = rotation.DH_transfer_matrix(geo.theta[0] + self.q[0], geo.alpha[0], geo.a[0], geo.d[0])
123 
124  self.H[0] = self.T[0]
125 
126  for i in range(1, self.config_settings.njoint):
127 
128  if self.config_settings.prismatic[i]:
129  self.T[i] = rotation.DH_transfer_matrix(geo.theta[i], geo.alpha[i], geo.a[i], geo.d[i] + self.q[i])
130  else:
131  self.T[i] = rotation.DH_transfer_matrix(geo.theta[i] + self.q[i], geo.alpha[i], geo.a[i], geo.d[i])
132 
133  self.H[i] = numpy.dot(self.H[i-1], self.T[i])
134 
135  self.ajac.H = self.H
136  return self.H
137 
138 # \cond
139 
140  def set_config_virtual(self, qvrd):
141  if super(Manipulator_Geometry, self).set_config_virtual(qvrd):
142  self.T = None
143  self.H = None
144  self.ajac.clear()
145  return True
146  else:
147  return False
148 
149  def set_config(self, qd):
150  if super(Manipulator_Geometry, self).set_config(qd):
151  self.T = None
152  self.H = None
153  self.ajac.clear()
154  return True
155  else:
156  return False
157 
158 # \endcond
159 
geo_settings
An instance of class Manipulator_Geometry_Settings containing geometry and dimensions of the manipula...
This class contains geometrical properties and dimensional settings of a chained-link manipulator...
nlink
A positive integer containing the number of links of the manipulator.
a
A numpy vector containing the values of the DH parameters.
theta
A numpy vector containing the values of the DH parameters If the proximal joint of the link is revou...
def transfer_matrices
Use this function to get the current homogeneous transfer matrices of the manipulator.
alpha
A numpy vector containing the values of the DH parameters.
def __str__
This function is used to generate a string representing a set of selected object properties and their...
T
A list of homogeneous transformation matrices.
This class contains a list of relative and absolute transfer matrices representing the forward kinema...
d
A numpy vector containing the values of the DH parameters If the joint is prismatic, the value of d[i] is added to q[i] in the transformation matrix.