gazebo_interface.py
Go to the documentation of this file.
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, gazebo_namespace):
00016     rospy.loginfo("waiting for service %s/spawn_gazebo_model"%gazebo_namespace)
00017     rospy.wait_for_service(gazebo_namespace+'/spawn_gazebo_model')
00018     try:
00019       spawn_gazebo_model = rospy.ServiceProxy(gazebo_namespace+'/spawn_gazebo_model', SpawnModel)
00020       resp = spawn_gazebo_model(model_name, model_xml, robot_namespace, initial_pose, reference_frame)
00021       print "spawn status: ", resp.status_message
00022       return resp.success
00023     except rospy.ServiceException, e:
00024       print "Service call failed: %s"%e
00025 
00026 def spawn_urdf_model_client(model_name, model_xml, robot_namespace, initial_pose, reference_frame, gazebo_namespace):
00027     rospy.loginfo("waiting for service %s/spawn_urdf_model"%gazebo_namespace)
00028     rospy.wait_for_service(gazebo_namespace+'/spawn_urdf_model')
00029     try:
00030       spawn_urdf_model = rospy.ServiceProxy(gazebo_namespace+'/spawn_urdf_model', SpawnModel)
00031       resp = spawn_urdf_model(model_name, model_xml, robot_namespace, initial_pose, reference_frame)
00032       print "spawn status: ", resp.status_message
00033       return resp.success
00034     except rospy.ServiceException, e:
00035       print "Service call failed: %s"%e
00036 
00037 def set_model_configuration_client(model_name, model_param_name, joint_names, joint_positions, gazebo_namespace):
00038     rospy.loginfo("waiting for service %s/set_model_configuration"%gazebo_namespace)
00039     rospy.wait_for_service(gazebo_namespace+'/set_model_configuration')
00040     try:
00041       set_model_configuration = rospy.ServiceProxy(gazebo_namespace+'/set_model_configuration', SetModelConfiguration)
00042       resp = set_model_configuration(model_name, model_param_name, joint_names, joint_positions)
00043       print "set model configuration status: ", resp.status_message
00044       return resp.success
00045     except rospy.ServiceException, e:
00046       print "Service call failed: %s"%e
00047 


gazebo
Author(s): Nate Koenig, Andrew Howard, with contributions from many others. See web page for a full credits llist.
autogenerated on Mon Oct 6 2014 12:15:20