本文整理汇总了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