Main Page
Namespaces
Classes
Files
File List
scripts
set_gm_current_perturbation.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
from
__future__
import
print_function
17
import
rospy
18
import
sys
19
from
numpy
import
pi
20
from
uuv_world_ros_plugins_msgs.srv
import
*
21
22
if
__name__ ==
'__main__'
:
23
print(
'Starting current perturbation node'
)
24
rospy.init_node(
'set_gm_current_perturbation'
)
25
26
print(
'Programming the generation of a current perturbation'
)
27
if
rospy.is_shutdown():
28
print(
'ROS master not running!'
)
29
sys.exit(-1)
30
31
params = [
'component'
,
'mean'
,
'min'
,
'max'
,
'noise'
,
'mu'
]
32
values = dict()
33
for
p
in
params:
34
assert
rospy.has_param(
'~'
+ p)
35
values[p] = rospy.get_param(
'~'
+ p)
36
37
assert
values[
'component'
]
in
[
'velocity'
,
'horz_angle'
,
'vert_angle'
]
38
if
values[
'component'
] ==
'velocity'
:
39
assert
values[
'mean'
] > 0
40
else
:
41
values[
'min'
] *= pi / 180.0
42
values[
'max'
] *= pi / 180.0
43
values[
'mean'
] *= pi / 180.0
44
45
assert
values[
'min'
] < values[
'max'
]
46
assert
values[
'noise'
] >= 0
47
assert
values[
'mu'
] >= 0
48
49
rospy.wait_for_service(
50
'/hydrodynamics/set_current_%s_model'
% values[
'component'
],
51
timeout=30)
52
53
set_model = rospy.ServiceProxy(
54
'/hydrodynamics/set_current_%s_model'
% values[
'component'
],
55
SetCurrentModel)
56
57
if
set_model
(values[
'mean'
], values[
'min'
], values[
'max'
], values[
'noise'
],
58
values[
'mu'
]):
59
print(
'Model for <{}> set successfully!'
.format(values[
'component'
]))
60
else
:
61
print(
'Error setting model!'
)
srv
set_gm_current_perturbation.set_model
set_model
Definition:
set_gm_current_perturbation.py:53
uuv_control_utils
Author(s): Musa Morena Marcusso Manhaes
, Sebastian Scherer
, Luiz Ricardo Douat
autogenerated on Thu Jun 18 2020 03:28:47