File tree Expand file tree Collapse file tree 2 files changed +3103
-0
lines changed
Expand file tree Collapse file tree 2 files changed +3103
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/python3
2+
3+ import sys
4+ import tempfile
5+ import numpy as np
6+
7+ N = 500
8+ XLIM = 42
9+ YLIM = 42
10+
11+ TREE_MODEL_URI = 'https://fuel.gazebosim.org/1.0/OpenRobotics/models/Pine Tree'
12+
13+ filename = tempfile .mkstemp ()[- 1 ]
14+
15+ if len (sys .argv ) > 1 :
16+ filename = sys .argv [1 ]
17+
18+ print (f'Output will be written to { filename } ' )
19+
20+
21+ xcoords = np .random .uniform (- XLIM , XLIM , N )
22+ ycoords = np .random .uniform (- YLIM , YLIM , N )
23+ yaws = np .random .uniform (- np .pi , np .pi , N )
24+
25+ trees = '''
26+ <!-- trees {-->'''
27+
28+ for i in range (N ):
29+ x = xcoords [i ]
30+ y = ycoords [i ]
31+ yaw = yaws [i ]
32+ raw_text = f'''
33+ <include>
34+ <uri>{ TREE_MODEL_URI } </uri>
35+ <name>tree_pine{ i } </name>
36+ <pose>{ x } { y } 0 0 0 { yaw } </pose>
37+ </include>
38+ '''
39+
40+ trees += raw_text
41+
42+ trees += '<!--}-->'
43+
44+ with open (filename , 'w' , encoding = 'utf-8' ) as f :
45+ f .write (trees )
46+
47+ print (f'Trees generated to { filename } , copy the content into your world file' )
You can’t perform that action at this time.
0 commit comments