16 from __future__
import print_function
20 from dynamic_reconfigure.server
import Server
21 from geometry_msgs.msg
import Accel
22 from geometry_msgs.msg
import Wrench
23 from rospy.numpy_msg
import numpy_msg
27 print(
'AccelerationControllerNode: initializing node')
40 'thruster_manager/input', Wrench, queue_size=1)
42 if not rospy.has_param(
"pid/mass"):
43 raise rospy.ROSException(
"UUV's mass was not provided")
45 if not rospy.has_param(
"pid/inertial"):
46 raise rospy.ROSException(
"UUV's inertial was not provided")
48 self.
mass = rospy.get_param(
"pid/mass")
49 self.
inertial = rospy.get_param(
"pid/inertial")
57 numpy.hstack((self.
mass*numpy.identity(3), numpy.zeros((3, 3)))),
69 msg.accel.linear.x, msg.accel.linear.y, msg.accel.linear.z))
70 torque = numpy.array((
71 msg.accel.angular.x, msg.accel.angular.y, msg.accel.angular.z))
72 force_torque = numpy.hstack((force, torque)).transpose()
75 force_msg.force.x = force[0]
76 force_msg.force.y = force[1]
77 force_msg.force.z = force[2]
79 force_msg.torque.x = torque[0]
80 force_msg.torque.y = torque[1]
81 force_msg.torque.z = torque[2]
83 self.pub_gen_force.publish(force_msg)
90 linear = numpy.array((msg.linear.x, msg.linear.y, msg.linear.z))
91 angular = numpy.array((msg.angular.x, msg.angular.y, msg.angular.z))
92 accel = numpy.hstack((linear, angular)).transpose()
95 force_torque = self.mass_inertial_matrix.dot(accel)
98 force_msg.force.x = force_torque[0]
99 force_msg.force.y = force_torque[1]
100 force_msg.force.z = force_torque[2]
102 force_msg.torque.x = force_torque[3]
103 force_msg.torque.y = force_torque[4]
104 force_msg.torque.z = force_torque[5]
106 self.pub_gen_force.publish(force_msg)
108 if __name__ ==
'__main__':
109 print(
'starting AccelerationControl.py')
110 rospy.init_node(
'acceleration_control')
115 except rospy.ROSInterruptException:
116 print(
'caught exception')
def accel_callback(self, msg)
def force_callback(self, msg)