-
Notifications
You must be signed in to change notification settings - Fork 59
Description
I have try the track the orientation of the target sphere not just the position.
dv = kp_x * (sphere.position - x) + kd_x * dx I try to use this function to get the position control. It has a good performance. but when I add the orientation tracking using dw=kp_o* error_quaternion(sphere.orientation, quaternion_endeffector) + kd_o * do_d[0:3]
dq = Jp.dot(np.hstack((dv, dw))) but the performance of the tracking is not good.
the error_quaternion is
def error_quaternion(a, b):
q = a.copy()
p = b.copy()
x = q[0] * p[1] - q[1] * p[0] - q[2] * p[3] + q[3] * p[2]
y = q[0] * p[2] + q[1] * p[3] - q[2] * p[0] - q[3] * p[1]
z = q[0] * p[3] - q[1] * p[2] + q[2] * p[1] - q[3] * p[0]
return np.array([x, y, z])
do is error_quaternion_q(quaternion_endeffector, sphere.orientation) / dt
error_quaternion_q is
def error_quaternion_q(a, b):
q = a.copy()
p = b.copy()
w = q[0] * p[0] - q[1] * p[1] - q[2] * p[2] - q[3] * p[3]
x = q[0] * p[1] - q[1] * p[0] - q[2] * p[3] + q[3] * p[2]
y = q[0] * p[2] + q[1] * p[3] - q[2] * p[0] - q[3] * p[1]
z = q[0] * p[3] - q[1] * p[2] + q[2] * p[1] - q[3] * p[0]
return np.array([x, y, z, w])
