mock_state_services.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Copyright 2019 Shadow Robot Company Ltd.
3 #
4 # This program is free software: you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the Free
6 # Software Foundation version 2 of the License.
7 #
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 # more details.
12 #
13 # You should have received a copy of the GNU General Public License along
14 # with this program. If not, see <http://www.gnu.org/licenses/>.
15 
16 import rospy
17 from moveit_msgs.srv import CheckIfRobotStateExistsInWarehouse as HasState
18 from moveit_msgs.srv import GetRobotStateFromWarehouse as GetState
19 from moveit_msgs.msg import RobotState
20 from moveit_msgs.srv import SaveRobotStateToWarehouse as SaveState
21 from moveit_msgs.srv import ListRobotStatesInWarehouse as ListState
22 
23 
25  resp = RobotState()
26  if req.name == "state1":
27  resp.joint_state.name = ["joint_test1", "joint_test2"]
28  resp.joint_state.position = [1.0, 2.0]
29  if req.name == "state2":
30  resp.joint_state.name = ["joint_test3", "joint_test4"]
31  resp.joint_state.position = [3.0, 4.0]
32  return resp
33 
34 
36  return True
37 
38 
40  states = {"state1", "state2"}
41  return states
42 
43 
45  if "state1" in req.name:
46  return True
47  else:
48  return False
49 
50 if __name__ == "__main__":
51  rospy.init_node('mock_services', anonymous=True)
52  s1 = rospy.Service('/get_robot_state', GetState, mock_get_state_callback)
53  s2 = rospy.Service('/has_robot_state', HasState, mock_has_state_callback)
54  s3 = rospy.Service('/list_robot_states', ListState, mock_list_state_callback)
55  s4 = rospy.Service('/save_robot_state', SaveState, mock_save_state_callback)
56  rospy.spin()


sr_robot_commander
Author(s): Andriy Petlovanyy
autogenerated on Wed Oct 14 2020 04:05:30