multi_cm_dummy.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2014, PAL Robotics S.L.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 # * Redistributions of source code must retain the above copyright notice,
8 # this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 # * Neither the name of PAL Robotics S.L. nor the names of its
13 # contributors may be used to endorse or promote products derived from
14 # this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 # POSSIBILITY OF SUCH DAMAGE.
27 
28 import rospy
29 from controller_manager_tests import ControllerManagerDummy
30 from controller_manager_msgs.msg import ControllerState as CtrlState
31 from controller_manager_msgs.msg import HardwareInterfaceResources
32 from controller_manager_msgs.srv import ListControllersResponse, LoadController
33 
34 if __name__ == '__main__':
35  rospy.init_node('multi_cm_dummy')
36 
37  # Valid controller managers in different namespaces
38  cm_root = ControllerManagerDummy('/')
39  cm_foo1 = ControllerManagerDummy('/foo/robot/controller_manager1')
40  cm_foo2 = ControllerManagerDummy('/foo/robot/controller_manager2')
41  cm_default = ControllerManagerDummy()
42 
43  ctrl_list = [
44  CtrlState(name='foo_controller',
45  state='running',
46  type='foo_base/foo',
47  claimed_resources=[
48  HardwareInterfaceResources(
49  hardware_interface='hardware_interface::FooInterface',
50  resources=['one', 'two', 'three'])
51  ]),
52  CtrlState(name='bar_controller',
53  state='running',
54  type='bar_base/bar',
55  claimed_resources=[
56  HardwareInterfaceResources(
57  hardware_interface='hardware_interface::BarInterface',
58  resources=['four'])
59  ])
60  ]
61 
62  resp = ListControllersResponse()
63  resp.controller = ctrl_list
64  cm_default.list_ctrl_resp = resp
65 
66  # Partial controller manager ROS API: missing service
67  cm_incomplete = ControllerManagerDummy('/incomplete')
68  cm_incomplete.reload_libs.shutdown()
69 
70  # Partial controller manager ROS API: service with wrong type
71  cm_bad_type = ControllerManagerDummy('/bad_type')
72  cm_bad_type.unload_ctrl.shutdown()
73  cm_bad_type.unload_ctrl = rospy.Service('/bad_type/unload_controller',
74  LoadController, # NOTE: Wrong type
75  cm_bad_type._unload_ctrl_cb)
76 
77  rospy.spin()


controller_manager_tests
Author(s): Vijay Pradeep, Adolfo Rodriguez Tsouroukdissian
autogenerated on Mon Apr 20 2020 03:52:10