fin_model.py
Go to the documentation of this file.
1 # Copyright (c) 2016-2019 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 import rospy
16 import numpy as np
17 from tf_quaternion.transformations import quaternion_matrix
18 from uuv_gazebo_ros_plugins_msgs.msg import FloatStamped
19 
20 
21 class FinModel(object):
22  def __init__(self, index, pos, quat, topic):
23  self.id = index
24  self.pos = pos
25  self.quat = quat
26  self.topic = topic
27  self.rot = quaternion_matrix(quat)[0:3, 0:3]
28 
29  unit_z = self.rot[:, 2]
30  # Surge velocity wrt vehicle's body frame
31  surge_vel = np.array([1, 0, 0])
32  fin_surge_vel = surge_vel - np.dot(surge_vel, unit_z) / np.linalg.norm(unit_z)**2 * unit_z
33  # Compute the lift and drag vectors
34  self.lift_vector = -1 * np.cross(unit_z, fin_surge_vel) / np.linalg.norm(np.cross(unit_z, fin_surge_vel))
35  self.drag_vector = -1 * surge_vel / np.linalg.norm(surge_vel)
36 
37  self.pub = rospy.Publisher(self.topic, FloatStamped, queue_size=3)
38 
39  def publish_command(self, delta):
40  msg = FloatStamped()
41  msg.header.stamp = rospy.Time.now()
42  msg.data = delta
43  self.pub.publish(msg)
def __init__(self, index, pos, quat, topic)
Definition: fin_model.py:22


uuv_auv_control_allocator
Author(s): Musa Morena Marcusso Manhaes
autogenerated on Thu Jun 18 2020 03:28:21