nbv_sim/controllers.py

21 lines
443 B
Python
Raw Normal View History

import numpy as np
class CartesianPoseController:
def __init__(self, model):
self.model = model
2021-03-12 14:55:42 +01:00
# self.x_d = x0
def set_target(self, pose):
2021-03-12 14:55:42 +01:00
self.x_d = pose.translation
def update(self, q, dq):
2021-03-12 14:55:42 +01:00
t = self.model.pose(q).translation
J = self.model.jacobian(q)[:3, :]
J_pinv = np.linalg.pinv(J)
2021-03-12 14:55:42 +01:00
err = 2.0 * (self.x_d - t)
cmd = np.dot(J_pinv, err)
return cmd