18 import tf.transformations
as trans
19 from uuv_gazebo_ros_plugins_msgs.msg
import FloatStamped
20 from std_msgs.msg
import Header
24 """Abstract function to all the thruster models avaialble. The instance 25 of a thruster model must use the factory method.""" 28 DEFAULT_AXIS=numpy.array([1, 0, 0, 0])
30 def __init__(self, index, topic, pos, orientation, axis=DEFAULT_AXIS):
31 """Thruster class constructor. 38 Name of the thruster's command topic. 40 3D position of the thruster with relation to the reference frame. 41 orientation: numpy.array 42 Quaternion with the orientation of the thruster with relation to 50 if pos
is not None and orientation
is not None:
54 thrust_body = trans.quaternion_matrix(orientation).dot(
55 axis.transpose())[0:3]
56 torque_body = numpy.cross(pos, thrust_body)
58 thrust_body, torque_body)).transpose()
72 for thruster
in Thruster.__subclasses__():
73 if model_name == thruster.LABEL:
74 return thruster(*args, **kwargs)
75 rospy.ROSException(
'Invalid thruster model')
78 """Convert desired thrust force to input command according to this 79 function. Overwrite this method to implement custom models.""" 83 """Computes the thrust force for the given command.""" 86 def get_curve(self, min_value, max_value, n_points):
87 """Sample the conversion curve and return the values.""" 88 if min_value >= max_value
or n_points <= 0:
90 input_values = numpy.linspace(min_value, max_value, n_points)
92 for value
in input_values:
94 return input_values.tolist(), output_values
97 """Convert the desired thrust force into angular velocity command 98 according using a gain.""" 107 output = FloatStamped()
108 output.header.stamp = rospy.Time.now()
110 self._command_pub.publish(output)
def get_curve(self, min_value, max_value, n_points)
def _update(self, thrust)
def create_thruster(model_name, args, kwargs)
def get_thrust_value(self, command)
def __init__(self, index, topic, pos, orientation, axis=DEFAULT_AXIS)
def publish_command(self, thrust)
def get_command_value(self, thrust)