4 @file: cost_function.py
5 @brief: This module provides a class representing a cost function which can be used for a criterion in the jointspace or taskspace
6 @author: Nima Ramezani Taghiabadi
8 Faculty of Engineering and Information Technology
9 University of Technology Sydney
10 Broadway, Ultimo, NSW 2007
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
19 Last Revision: 09 August 2015
23 all_purposes = [
None,
'Main Task',
'Gradient Projection',
'Joint Damping']
24 all_input_refs = [
'Joint Values',
'Taskpoint Error',
'Taskframe Error']
31 def __init__(self, input_ref, purpose = None, weight = 1.0):
34 assert input_ref
in all_input_refs
35 assert purpose
in all_purposes
46 x = endeff.free_config(endeff.q)
48 tp = endeff.task_point[self.
ref_num]
49 H = endeff.transfer_matrices()
50 x = tp.error.value(tp.position(H), tp.rd)
52 assert False,
"Not Supported!"
53 return self.function.value(x)
57 x = endeff.free_config(endeff.q)
58 return self.function.gradient(x)
60 tp = endeff.task_point[self.
ref_num]
61 H = endeff.transfer_matrices()
62 x = tp.error.value(tp.position(H), tp.rd)
63 EJ = tp.error_jacobian(H, endeff.ajac)
64 return numpy.dot(EJ.T, self.function.gradient(x))
66 tf = endeff.task_frame[self.
ref_num]
67 H = endeff.transfer_matrices()
68 x = tf.error.value(tf.position(H), tf.rd)
69 EJ = tf.error_jacobian(H, endeff.ajac)
70 return numpy.dot(EJ.T, self.function.gradient(x))
72 assert False,
"Not Supported!"