set_scalar_parameter.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright (c) 2016 The UUV Simulator Authors.
3 # All rights reserved.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 import rospy
17 import sys
18 from uuv_gazebo_ros_plugins_msgs.srv import SetFloat
19 
20 
21 if __name__ == '__main__':
22  print('Set scalar parameter, namespace=' + rospy.get_namespace())
23  rospy.init_node('set_thrusters_states')
24 
25  if rospy.is_shutdown():
26  rospy.ROSException('ROS master not running!')
27 
28  services = ['set_fluid_density', 'set_added_mass_scaling',
29  'set_damping_scaling', 'set_volume_scaling',
30  'set_volume_offset', 'set_added_mass_offset',
31  'set_linear_damping_offset', 'set_nonlinear_damping_offset',
32  'set_linear_forward_speed_damping_offset']
33 
34  assert rospy.has_param('~service_name')
35  assert rospy.has_param('~data')
36 
37  service_name = rospy.get_param('~service_name')
38  assert service_name in services, 'Possible service names are=' + str(services)
39 
40  data = rospy.get_param('~data')
41 
42  rospy.wait_for_service(service_name, timeout=30)
43 
44  fcn = rospy.ServiceProxy(service_name, SetFloat)
45  print('Set scalar parameter, service=%s, data=%.2f' % (service_name, data))
46  output = fcn(data)
47  if output.success:
48  print('Parameter set successfully')
49  else:
50  print('Error setting scalar parameter')
51  print(output.message)
52  print('Leaving node...')


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