MAGIKS  1.1
Manipulator General Inverse Kinematic Solver
 All Classes Namespaces Files Functions Variables Pages
function_library.py
Go to the documentation of this file.
1 
2 # HEADER
3 '''
4 @file: function_library.py
5 @brief: This module provides a library of functions used in manipulator kinematic contrl
6 @author: Nima Ramezani Taghiabadi
7  PhD Researcher
8  Faculty of Engineering and Information Technology
9  University of Technology Sydney
10  Broadway, Ultimo, NSW 2007
11  Room No.: CB10.03.512
12  Phone: 02 9514 4621
13  Mobile: 04 5027 4611
14  Email(1): Nima.RamezaniTaghiabadi@student.uts.edu.au
15  Email(2): nima.ramezani@gmail.com
16  Email(3): nima_ramezani@yahoo.com
17  Email(4): ramezanitn@alum.sharif.edu
18 @version: 2.0
19 Last Revision: 23 August 2015
20 '''
21 
22 '''
23 Changes from last version:
24  1- a new task cost function added: Liegeois_Midrange_Deviance() used for Jacobian Nullspace Gradient Projection to avoid joint limits as a second-priority cost function
25 
26 '''
27 # BODY
28 
29 from math_tools.algebra import functions as flib
30 import math, numpy as np
31 
32 class Zghal_Function(flib.Function):
33  '''
34  '''
35  def __init__(self, xl, xh):
36  '''
37  '''
38  n = len(xl)
39  assert n == len(xh), "\n Error from Zghal_Function.__init__(): \n \n Given vectors do not match"
40  self.xl = xl
41  self.xh = xh
42  self.rng = (xh - xl)**2
43 
44  def value(self, x):
45  den = 4.0*(self.xh - x)*(x - self.xl)
46  return sum(self.rng/den)
47 
48  def gradient(self, x):
49  den = (self.xh - x)**2
50  den *= 4*(x - self.xl)**2
51  num = 2*x - self.xh - self.xl
52  num *= self.rng
53  return num/den