18 from uuv_control_interfaces
import DPControllerBase
23 Singularity-free tracking controller 28 [1] O.-E. Fjellstad and T. I. Fossen, Singularity-free tracking of unmanned 29 underwater vehicles in 6 DOF, Proceedings of 1994 33rd IEEE Conference 30 on Decision and Control 31 [2] G. Antonelli, "Underwater Robots," Springer Tracts in Advanced Robotics, 35 _LABEL =
'Singularity-free tracking controller' 38 DPControllerBase.__init__(self,
True)
40 self._logger.info(
'Initializing: ' + self.
_LABEL)
42 self.
_Kd = np.zeros(shape=(6, 6))
44 if rospy.has_param(
'~Kd'):
45 coefs = rospy.get_param(
'~Kd')
47 self.
_Kd = np.diag(coefs)
49 raise rospy.ROSException(
'Kd coefficients: 6 coefficients ' 52 self._logger.info(
'Kd=\n' + str(self.
_Kd))
57 l = rospy.get_param(
'~lambda', [0.0])
60 self.
_delta[0:3, 0:3] = l[0] * np.eye(3)
62 self.
_delta[0:3, 0:3] = np.diag(l)
64 raise rospy.ROSException(
65 'lambda: either a scalar or a 3 element vector must be provided')
67 c = rospy.get_param(
'~c', [0.0])
70 self.
_delta[3:6, 3:6] = c[0] * np.eye(3)
72 self.
_delta[3:6, 3:6] = np.diag(c)
74 raise rospy.ROSException(
75 'c: either a scalar or a 3 element vector must be provided')
77 self._logger.info(
'delta=\n' + str(self.
_delta))
83 self._logger.info(self.
_LABEL +
' ready')
89 t = rospy.Time.now().to_sec()
93 error = np.hstack((self._errors[
'pos'], self.error_orientation_quat))
96 vel_r = self._reference[
'vel'] + np.dot(self.
_delta, error)
109 vel = self._vehicle_model.to_SNAME(self._vehicle_model.vel)
111 s = self._errors[
'vel'] + np.dot(self.
_delta, error)
116 sname_vel_r = self._vehicle_model.to_SNAME(vel_r)
117 sname_d_vel_r = self._vehicle_model.to_SNAME(d_vel_r)
118 self._vehicle_model._update_damping(vel)
119 self._vehicle_model._update_coriolis(vel)
120 self._vehicle_model._update_restoring(use_sname=
True)
122 self.
_tau = np.dot(self._vehicle_model.Mtotal, sname_d_vel_r) + \
123 np.dot(self._vehicle_model.Ctotal, sname_vel_r) + \
124 np.dot(self._vehicle_model.Dtotal, sname_vel_r) + \
125 self._vehicle_model.restoring_forces
128 self.publish_control_wrench(
129 self._vehicle_model.from_SNAME(self.
_tau) + np.dot(self.
_Kd, s))
136 if __name__ ==
'__main__':
137 rospy.init_node(
'rov_sf_controller')
142 except rospy.ROSInterruptException:
143 print(
'caught exception')
def update_controller(self)