world.py
Go to the documentation of this file.
1 # Gazebo world changer
2 
3 import xml.etree.ElementTree as ET
4 
5 from string import Template
6 
7 WORLD_INCLUDE = Template('''
8  <include>
9  <uri>model://${model_name}</uri>
10  <pose>${x} ${y} ${z} ${roll} ${pitch} ${yaw}</pose>
11  </include>
12 ''')
13 
14 def load_world(world_file):
15  '''
16  Load Gazebo world as an ElementTree object
17  '''
18  return ET.parse(world_file)
19 
20 
21 def add_model(world, model_name, x, y, z, roll, pitch, yaw, index=0):
22  '''
23  Create and add an element to the world
24  '''
25  world_elem = world.find('world')
26  model_elem = ET.fromstring(WORLD_INCLUDE.substitute(
27  model_name=model_name,
28  x=x,
29  y=y,
30  z=z,
31  roll=roll,
32  pitch=pitch,
33  yaw=yaw
34  ))
35  model_elem.tail = '\n '
36  world_elem.insert(index, model_elem)
37  return world
38 
39 
40 def save_world(world, file):
41  '''
42  Save the world to file-like object
43  '''
44  return world.write(file)
def load_world(world_file)
Definition: world.py:14
def add_model(world, model_name, x, y, z, roll, pitch, yaw, index=0)
Definition: world.py:21
def save_world(world, file)
Definition: world.py:40


clover_simulation
Author(s): Alexey Rogachevskiy, Andrey Ryabov, Arthur Golubtsov, Oleg Kalachev, Svyatoslav Zhuravlev
autogenerated on Mon Feb 28 2022 22:08:36