$search
00001 #! /usr/bin/env python 00002 # Wrappers around the services provided by rosified gazebo 00003 00004 import roslib; roslib.load_manifest('gazebo') 00005 00006 import sys 00007 import rospy 00008 import os 00009 00010 from gazebo_msgs.msg import * 00011 from gazebo_msgs.srv import * 00012 from geometry_msgs.msg import Point, Pose, Quaternion, Twist, Wrench 00013 00014 00015 def spawn_gazebo_model_client(model_name,model_xml,robot_namespace,initial_pose,reference_frame): 00016 rospy.loginfo("waiting for service spawn_gazebo_model") 00017 rospy.wait_for_service('/gazebo/spawn_gazebo_model') 00018 try: 00019 spawn_gazebo_model = rospy.ServiceProxy('/gazebo/spawn_gazebo_model',SpawnModel) 00020 resp = spawn_gazebo_model(model_name,model_xml,robot_namespace,initial_pose,reference_frame) 00021 rospy.loginfo("spawn status: %s",resp.status_message) 00022 return resp.success 00023 except rospy.ServiceException, e: 00024 rospy.logerr("Service call failed: %s",e) 00025 00026 def spawn_urdf_model_client(model_name,model_xml,robot_namespace,initial_pose,reference_frame): 00027 rospy.loginfo("waiting for service spawn_urdf_model") 00028 rospy.wait_for_service('/gazebo/spawn_urdf_model') 00029 try: 00030 spawn_urdf_model = rospy.ServiceProxy('/gazebo/spawn_urdf_model',SpawnModel) 00031 resp = spawn_urdf_model(model_name,model_xml,robot_namespace,initial_pose,reference_frame) 00032 rospy.loginfo("spawn status: %s",resp.status_message) 00033 return resp.success 00034 except rospy.ServiceException, e: 00035 rospy.logerr("Service call failed: %s",e) 00036 00037 def set_model_configuration_client(model_name,model_param_name,joint_names,joint_positions): 00038 rospy.loginfo("waiting for service set_model_configuration") 00039 rospy.wait_for_service('/gazebo/set_model_configuration') 00040 try: 00041 set_model_configuration = rospy.ServiceProxy('/gazebo/set_model_configuration',SetModelConfiguration) 00042 resp = set_model_configuration(model_name,model_param_name,joint_names,joint_positions) 00043 rospy.loginfo("set model configuration status: %s",resp.status_message) 00044 return resp.success 00045 except rospy.ServiceException, e: 00046 rospy.logerr("Service call failed: %s",e) 00047