24 from uuv_control_interfaces
import DPControllerBase
50 super(TutorialDPController, self).
__init__(self)
69 self.
_Kp = np.zeros(shape=(6, 6))
70 self.
_Kd = np.zeros(shape=(6, 6))
71 self.
_Ki = np.zeros(shape=(6, 6))
73 self.
_int = np.zeros(shape=(6,))
80 if rospy.get_param(
'~Kp'):
81 Kp_diag = rospy.get_param(
'~Kp')
83 self.
_Kp = np.diag(Kp_diag)
86 raise rospy.ROSException(
'For the Kp diagonal matrix, 6 coefficients are needed')
89 if rospy.get_param(
'~Kd'):
90 diag = rospy.get_param(
'~Kd')
92 self.
_Kd = np.diag(diag)
93 print 'Kd=\n', self.
_Kd 96 raise rospy.ROSException(
'For the Kd diagonal matrix, 6 coefficients are needed')
98 if rospy.get_param(
'~Ki'):
99 diag = rospy.get_param(
'~Ki')
101 self.
_Ki = np.diag(diag)
102 print 'Ki=\n', self.
_Ki 105 raise rospy.ROSException(
'For the Ki diagonal matrix, 6 coefficients are needed')
116 self.
_int = np.zeros(shape=(6,))
125 if not self.odom_is_init:
137 tau = np.dot(self.
_Kp, self.error_pose_euler) + np.dot(self.
_Kd, self._errors[
'vel']) + \
143 self.publish_control_wrench(tau)
145 if __name__ ==
'__main__':
157 print(
'Tutorial - DP Controller')
158 rospy.init_node(
'tutorial_dp_controller')
163 except rospy.ROSInterruptException:
164 print(
'caught exception')
def _reset_controller(self)
def update_controller(self)