MAGIKS  1.1
Manipulator General Inverse Kinematic Solver
 All Classes Namespaces Files Functions Variables Pages
task_point.py
Go to the documentation of this file.
1 ## @file: task_point.py
2 # @brief: This module provides a class representing the reference poisition of an endeffector and the desired value for it.
3 # @author Nima Ramezani Taghiabadi
4 #
5 # PhD Researcher
6 # Faculty of Engineering and Information Technology
7 # University of Technology Sydney (UTS)
8 # Broadway, Ultimo, NSW 2007, Australia
9 # Phone No. : 04 5027 4611
10 # Email(1) : nima.ramezani@gmail.com
11 # Email(2) : Nima.RamezaniTaghiabadi@uts.edu.au
12 # @version 4.0
13 #
14 # Last Revision: 11 January 2015
15 
16 import numpy, math
17 
18 from packages.nima.robotics.kinematics.jacobian import jacobian as jaclib
19 from packages.nima.mathematics.algebra import vectors_and_matrices as vecmat
20 from packages.nima.mathematics.geometry import metric, trajectory as trajlib
21 
22 class Task_Point() :
23  '''
24  refernce point only for introducing an endeffector position
25 
26  reference_position == Reference Position + Target Point for this reference position + actual position for this point
27 
28  "reference_position" is a class or data structure containing properties by which a point in the task space of a chained link manipulator is defined.
29 
30  TASK POSITION is RELATIVE to the "FRAME" of the link,
31  the "FRAME" of the link is determined via DH parameters and the zero configuration
32  '''
33 
34  def __init__(self, config_settings, link_point_list):
35  '''
36  link_point_list == WEIGHTING
37 
38  Create and define the default values for class properties
39  '''
40  self.config_settings = config_settings
41 
42  # "lp" is a list of link points. The position of reference position is defined by a linear combination of the listed link points.
43  self.lp = link_point_list
44 
45  self.clear_error()
46  # "rd" represents the desired position for the reference position with respect to the ground coordinate system
47  self.rd = None
48 
49  self.H = None
50 
51  self.geometric_jacobian = jaclib.Geometric_Jacobian(self.config_settings)
52 
53  self.error_jacobian = jaclib.Error_Jacobian(self.config_settings)
54 
55  # "error" is an instance of class "Position_Metric" which represents the error between the desired and actual positions of the reference point
56  self.error = metric.Position_Metric()
57 
58  def clear_error():
59  self.error.clear()
60  self.error_jacobian.clear()
61 
63  # "ra" represents the position vector of the reference position with respect to the ground coordinate system.
64  self.ra = None
65  self.geometric_jacobian.clear()
66  self.clear_error()
67 
68  def __str__(self):
69  s = " Actual Position (mm): " + vecmat.vector_to_str(1000*(self.position())) + "\n"
70  s += " Desired Position (mm): " + vecmat.vector_to_str(1000*(self.rd)) + "\n"
71  s += " Position Error (mm): " + vecmat.vector_to_str(1000*(self.error.value)) + "\n"
72  return(s)
73 
74  def set_target(self, rd):
75  assert len(rd) == 3
76  self.rd = rd
77  self.clear_error()
78 
79  def set_transfer_matrices(self, H):
80  len_H = len(H)
81  assert len_H == self.config_settings.DOF, genpy.err_str(__name__, self.__class__.__name__,'set_transfer_matrices', 'The number of given transfer_matrices is: '+str(len_H)+' which does not match the settings DOF ('+str(self.config_settings.DOF)+')')
82  self.H = H
83  self.clear_position()
84 
85  def set_analytic_jacobian(self, analytic_jacobian):
86  self.analytic_jacobian = analytic_jacobian
87  self.geometric_jacobian.clear()
88  self.error_jacobian.clear()
89 
90  def position(self):
91  if self.ra == None:
92  self.ra = numpy.zeros((3))
93  for j in range(0, len(self.lp)):
94  x = numpy.dot(self.H[self.lp[j].ln], vecmat.extend_vector(self.lp[j].pv))
95  self.ra = self.ra + self.lp[j].w * x[0:3]
96  return self.ra
97