fin_model.py
Go to the documentation of this file.
1 # Copyright (c) 2016 The UUV Simulator Authors.
2 # All rights reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 import rospy
17 import numpy as np
18 from tf_quaternion.transformations import quaternion_matrix
19 from uuv_gazebo_ros_plugins_msgs.msg import FloatStamped
20 
21 
22 class FinModel(object):
23  def __init__(self, index, pos, quat, topic):
24  self.id = index
25  self.pos = pos
26  self.quat = quat
27  self.topic = topic
28  self.rot = quaternion_matrix(quat)[0:3, 0:3]
29 
30  unit_z = self.rot[:, 2]
31  # Surge velocity wrt vehicle's body frame
32  surge_vel = np.array([1, 0, 0])
33  fin_surge_vel = surge_vel - np.dot(surge_vel, unit_z) / np.linalg.norm(unit_z)**2 * unit_z
34  # Compute the lift and drag vectors
35  self.lift_vector = -1 * np.cross(unit_z, fin_surge_vel) / np.linalg.norm(np.cross(unit_z, fin_surge_vel))
36  self.drag_vector = -1 * surge_vel / np.linalg.norm(surge_vel)
37 
38  self.pub = rospy.Publisher(self.topic, FloatStamped, queue_size=3)
39 
40  def publish_command(self, delta):
41  msg = FloatStamped()
42  msg.header.stamp = rospy.Time.now()
43  msg.data = delta
44  self.pub.publish(msg)
def __init__(self, index, pos, quat, topic)
Definition: fin_model.py:23


uuv_auv_control_allocator
Author(s): Musa Morena Marcusso Manhaes
autogenerated on Mon Jul 1 2019 19:39:09