本文整理匯總了Python中gazebo_msgs.srv.SpawnModel方法的典型用法代碼示例。如果您正苦於以下問題:Python srv.SpawnModel方法的具體用法?Python srv.SpawnModel怎麽用?Python srv.SpawnModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gazebo_msgs.srv
的用法示例。
在下文中一共展示了srv.SpawnModel方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: spawn_model
# 需要導入模塊: from gazebo_msgs import srv [as 別名]
# 或者: from gazebo_msgs.srv import SpawnModel [as 別名]
def spawn_model(model_name):
""" Spawns a model in front of the RGBD camera.
Args: None
Returns: None
"""
initial_pose = Pose()
initial_pose.position.x = 0
initial_pose.position.y = 1
initial_pose.position.z = 1
# Spawn the new model #
model_path = rospkg.RosPack().get_path('sensor_stick')+'/models/'
model_xml = ''
with open (model_path + model_name + '/model.sdf', 'r') as xml_file:
model_xml = xml_file.read().replace('\n', '')
spawn_model_prox = rospy.ServiceProxy('gazebo/spawn_sdf_model', SpawnModel)
spawn_model_prox('training_model', model_xml, '', initial_pose, 'world')
示例2: spawn_urdf
# 需要導入模塊: from gazebo_msgs import srv [as 別名]
# 或者: from gazebo_msgs.srv import SpawnModel [as 別名]
def spawn_urdf(name, description_xml, pose, reference_frame):
rospy.wait_for_service('/gazebo/spawn_urdf_model')
try:
spawn_urdf = rospy.ServiceProxy('/gazebo/spawn_urdf_model', SpawnModel)
resp_urdf = spawn_urdf(name, description_xml, "/", pose, reference_frame)
except rospy.ServiceException as e:
rospy.logerr("Spawn URDF service call failed: {0}".format(e))
示例3: spawn_sdf
# 需要導入模塊: from gazebo_msgs import srv [as 別名]
# 或者: from gazebo_msgs.srv import SpawnModel [as 別名]
def spawn_sdf(name, description_xml, pose, reference_frame):
rospy.wait_for_service('/gazebo/spawn_sdf_model')
try:
spawn_sdf = rospy.ServiceProxy('/gazebo/spawn_sdf_model', SpawnModel)
resp_sdf = spawn_sdf(name, description_xml, "/", pose, reference_frame)
except rospy.ServiceException as e:
rospy.logerr("Spawn SDF service call failed: {0}".format(e))
示例4: respawnModel
# 需要導入模塊: from gazebo_msgs import srv [as 別名]
# 或者: from gazebo_msgs.srv import SpawnModel [as 別名]
def respawnModel(self):
while True:
if not self.check_model:
rospy.wait_for_service('gazebo/spawn_sdf_model')
spawn_model_prox = rospy.ServiceProxy('gazebo/spawn_sdf_model', SpawnModel)
spawn_model_prox(self.modelName, self.model, 'robotos_name_space', self.goal_position, "world")
rospy.loginfo("Goal position : %.1f, %.1f", self.goal_position.position.x,
self.goal_position.position.y)
break
else:
pass