thruster_proportional.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
18 from thruster import Thruster
19 
20 
21 class ThrusterProportional(Thruster):
22  """This model corresponds to the linear relation between a function
23  abs(command)*command of the command input (usually the command angular
24  velocity) to the thrust force. A constant gain has to be provided.
25  """
26  LABEL = 'proportional'
27 
28  def __init__(self, *args, **kwargs):
29  super(ThrusterProportional, self).__init__(*args)
30 
31  if 'gain' not in kwargs:
32  rospy.ROSException('Thruster gain not given')
33  self._gain = kwargs['gain']
34  rospy.loginfo('Thruster model:')
35  rospy.loginfo('\tGain=' + str(self._gain))
36 
37  def get_command_value(self, thrust):
38  return numpy.sign(thrust) * \
39  numpy.sqrt(numpy.abs(thrust) / self._gain)
40 
41  def get_thrust_value(self, command):
42  """Computes the thrust force for the given command."""
43  return self._gain * numpy.abs(command) * command


uuv_thruster_manager
Author(s): Musa Morena Marcusso Manhaes , Sebastian Scherer , Luiz Ricardo Douat
autogenerated on Mon Jul 1 2019 19:39:26