thruster_proportional.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
17 from thruster import Thruster
18 
19 
20 class ThrusterProportional(Thruster):
21  """This model corresponds to the linear relation between a function
22  abs(command)*command of the command input (usually the command angular
23  velocity) to the thrust force. A constant gain has to be provided.
24 
25 
26  > *Input arguments*
27 
28  * `index` (*type:* `int`): Thruster's ID.
29  * `topic` (*type:* `str`): Thruster's command topic.
30  * `pos` (*type:* `numpy.array` or `list`): Position vector
31  of the thruster with respect to the vehicle's frame.
32  * `orientation` (*type:* `numpy.array` or `list`): Quaternion
33  with the orientation of the thruster with respect to the vehicle's
34  frame as `(qx, qy, qz, qw)`.
35  * `axis` (*type:* `numpy.array`): Axis of rotation of the thruster.
36  * `gain` (*type:* `float`): Constant gain.
37  """
38  LABEL = 'proportional'
39 
40  def __init__(self, *args, **kwargs):
41  super(ThrusterProportional, self).__init__(*args)
42 
43  if 'gain' not in kwargs:
44  rospy.ROSException('Thruster gain not given')
45  self._gain = kwargs['gain']
46  rospy.loginfo('Thruster model:')
47  rospy.loginfo('\tGain=' + str(self._gain))
48 
49  def get_command_value(self, thrust):
50  """Compute the angular velocity necessary
51  for the desired thrust force.
52 
53  > *Input arguments*
54 
55  * `thrust` (*type:* `float`): Thrust force magnitude in N
56 
57  > *Returns*
58 
59  `float`: Angular velocity set-point for the thruster in rad/s
60  """
61  return numpy.sign(thrust) * \
62  numpy.sqrt(numpy.abs(thrust) / self._gain)
63 
64  def get_thrust_value(self, command):
65  """Computes the thrust force for the given angular velocity
66  set-point.
67 
68  > *Input arguments*
69 
70  * `command` (*type:* `float`): Angular velocity set-point for
71  the thruster in rad/s
72 
73  > *Returns*
74 
75  `thrust` (*type:* `float`): Thrust force magnitude in N
76  """
77  return self._gain * numpy.abs(command) * command


uuv_thruster_manager
Author(s): Musa Morena Marcusso Manhaes , Sebastian Scherer , Luiz Ricardo Douat
autogenerated on Thu Jun 18 2020 03:28:39