00001 #!/usr/bin/python 00002 ################################################################# 00003 ##\file 00004 # 00005 # \note 00006 # Copyright (c) 2012 \n 00007 # Cardiff University \n\n 00008 # 00009 ################################################################# 00010 # 00011 # \note 00012 # Project name: Multi-Role Shadow Robotic System for Independent Living 00013 # \note 00014 # ROS stack name: srs 00015 # \note 00016 # ROS package name: srs_decision_making_interface 00017 # 00018 # \author 00019 # Author: Renxi Qiu, email: renxi.qiu@gmail.com 00020 # 00021 # \date Date of creation: Jan 2012 00022 # 00023 # \brief 00024 # Interface for SRS decision making 00025 # 00026 ################################################################# 00027 # 00028 # Redistribution and use in source and binary forms, with or without 00029 # modification, are permitted provided that the following conditions are met: 00030 # 00031 # - Redistributions of source code must retain the above copyright 00032 # notice, this list of conditions and the following disclaimer. \n 00033 # 00034 # - Redistributions in binary form must reproduce the above copyright 00035 # notice, this list of conditions and the following disclaimer in the 00036 # documentation and/or other materials provided with the distribution. \n 00037 # 00038 # This program is free software: you can redistribute it and/or modify 00039 # it under the terms of the GNU Lesser General Public License LGPL as 00040 # published by the Free Software Foundation, either version 3 of the 00041 # License, or (at your option) any later version. 00042 # 00043 # This program is distributed in the hope that it will be useful, 00044 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00045 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00046 # GNU Lesser General Public License LGPL for more details. 00047 # 00048 # You should have received a copy of the GNU Lesser General Public 00049 # License LGPL along with this program. 00050 # If not, see <http://www.gnu.org/licenses/>. 00051 # 00052 ################################################################# 00053 import roslib; roslib.load_manifest('srs_decision_making_interface') 00054 00055 from srs_decision_making_interface.srv import srs_dm_ui_interface 00056 import srs_decision_making_interface.msg as xmsg 00057 from std_msgs.msg import * 00058 import rospy 00059 import actionlib 00060 00061 #client = '' 00062 00063 def srs_decision_making_ui_interface_handle(req): 00064 global client 00065 _goal=xmsg.srs_actionGoal() 00066 _goal.action=req.action 00067 _goal.parameter=req.parameter 00068 _goal.priority=int(req.priority) 00069 _goal.json_parameters = req.json_parameters 00070 client.send_goal(_goal) 00071 return client.gh.comm_state_machine.action_goal.goal_id.id 00072 00073 def srs_decision_making_ui_interface(): 00074 00075 s = rospy.Service('srs_decision_making_ui_interface', srs_dm_ui_interface, srs_decision_making_ui_interface_handle) 00076 print "Ready to translate request from UI to ROS network." 00077 rospy.spin() 00078 00079 00080 00081 if __name__ == "__main__": 00082 rospy.init_node('srs_decision_making_ui_interface') 00083 global client 00084 client = actionlib.SimpleActionClient('srs_decision_making_actions', xmsg.srs_actionAction) 00085 client.wait_for_server() 00086 srs_decision_making_ui_interface()