38 import roslib; roslib.load_manifest(
'rcprg_gazebo_utils')
46 from std_msgs.msg
import ColorRGBA
52 import tf_conversions.posemath
as pm
63 return 'ar_marker_{}cm_{}'.format(size_cm, marker_id)
66 return 'ar_marker_{}cm.dae'.format(size_cm)
69 return 'MarkerData_{}.png'.format(marker_id)
72 return '<?xml version="1.0"?>\n' +\
74 ' <name>AR Marker {}cm {}</name>\n'.format(size_cm, marker_id) +\
75 ' <version>1.0</version>\n' +\
76 ' <sdf version="1.5">model.sdf</sdf>\n' +\
78 ' <name>Dawid Seredynski</name>\n' +\
79 ' <email>dawid.seredynski(at)gmail.com</email>\n' +\
82 ' AR marker {}cm {}.\n'.format(size_cm, marker_id) +\
83 ' </description>\n' +\
87 return '<?xml version="1.0" ?>\n' +\
88 '<sdf version="1.5">\n' +\
90 ' <link name="link">\n' +\
91 ' <gravity>false</gravity>\n' +\
93 ' <pose>0 0 0 0 0 0</pose>\n' +\
94 ' <mass>0.01</mass>\n' +\
96 ' <ixx>0.000079</ixx>\n' +\
99 ' <iyy>0.000079</iyy>\n' +\
101 ' <izz>0.000025</izz>\n' +\
104 ' <visual name="visual">\n' +\
105 ' <pose>0 0 0 0 0 0</pose>\n' +\
108 ' <uri>model://{}/meshes/{}</uri>\n'.format(
118 return '<?xml version="1.0" encoding="utf-8"?>\n' +\
119 '<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n' +\
121 ' <contributor>\n' +\
122 ' <author>Blender User</author>\n' +\
123 ' <authoring_tool>Blender 2.91.0 commit date:2020-11-25, commit time:08:34, hash:0f45cab862b8</authoring_tool>\n' +\
124 ' </contributor>\n' +\
125 ' <created>2021-05-19T08:11:01</created>\n' +\
126 ' <modified>2021-05-19T08:11:01</modified>\n' +\
127 ' <unit name="meter" meter="1"/>\n' +\
128 ' <up_axis>Z_UP</up_axis>\n' +\
130 ' <library_effects>\n' +\
131 ' <effect id="Material_002-effect">\n' +\
132 ' <profile_COMMON>\n' +\
133 ' <newparam sid="markerdata_png-surface">\n' +\
134 ' <surface type="2D">\n' +\
135 ' <init_from>markerdata_png</init_from>\n' +\
138 ' <newparam sid="markerdata_png-sampler">\n' +\
140 ' <source>markerdata_png-surface</source>\n' +\
143 ' <technique sid="common">\n' +\
146 ' <color sid="emission">0 0 0 1</color>\n' +\
149 ' <texture texture="markerdata_png-sampler" texcoord="Cylinder-mesh-map-0"/>\n' +\
151 ' <index_of_refraction>\n' +\
152 ' <float sid="ior">1</float>\n' +\
153 ' </index_of_refraction>\n' +\
156 ' </profile_COMMON>\n' +\
158 ' <effect id="Material_001-effect">\n' +\
159 ' <profile_COMMON>\n' +\
160 ' <technique sid="common">\n' +\
163 ' <color sid="emission">0 0 0 1</color>\n' +\
166 ' <color sid="diffuse">0.512 0.512 0.512 1</color>\n' +\
168 ' <index_of_refraction>\n' +\
169 ' <float sid="ior">1</float>\n' +\
170 ' </index_of_refraction>\n' +\
173 ' </profile_COMMON>\n' +\
175 ' </library_effects>\n' +\
176 ' <library_images>\n' +\
177 ' <image id="markerdata_png" name="markerdata_png">\n' +\
180 ' </library_images>\n' +\
181 ' <library_materials>\n' +\
182 ' <material id="Material_002-material" name="Material_002">\n' +\
183 ' <instance_effect url="#Material_002-effect"/>\n' +\
185 ' <material id="Material_001-material" name="Material_001">\n' +\
186 ' <instance_effect url="#Material_001-effect"/>\n' +\
188 ' </library_materials>\n' +\
189 ' <library_geometries>\n' +\
190 ' <geometry id="Cylinder-mesh" name="Cylinder">\n' +\
192 ' <source id="Cylinder-mesh-positions">\n' +\
193 ' <float_array id="Cylinder-mesh-positions-array" count="24">-0.5 -0.5 -0.5 -0.5 0.5 -0.5 0.5 0.5 -0.5 0.5 -0.5 -0.5 -0.5 -0.5 0.5 -0.5 0.5 0.5 0.5 0.5 0.5 0.5 -0.5 0.5</float_array>\n' +\
194 ' <technique_common>\n' +\
195 ' <accessor source="#Cylinder-mesh-positions-array" count="8" stride="3">\n' +\
196 ' <param name="X" type="float"/>\n' +\
197 ' <param name="Y" type="float"/>\n' +\
198 ' <param name="Z" type="float"/>\n' +\
200 ' </technique_common>\n' +\
202 ' <source id="Cylinder-mesh-normals">\n' +\
203 ' <float_array id="Cylinder-mesh-normals-array" count="18">-1 0 0 0 1 0 1 0 0 0 -1 0 0 0 -1 0 0 1</float_array>\n' +\
204 ' <technique_common>\n' +\
205 ' <accessor source="#Cylinder-mesh-normals-array" count="6" stride="3">\n' +\
206 ' <param name="X" type="float"/>\n' +\
207 ' <param name="Y" type="float"/>\n' +\
208 ' <param name="Z" type="float"/>\n' +\
210 ' </technique_common>\n' +\
212 ' <source id="Cylinder-mesh-map-0">\n' +\
213 ' <float_array id="Cylinder-mesh-map-0-array" count="72">0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.9998999 9.998e-5 0.9999001 0.9998999 1.00099e-4 0.9998999 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9.998e-5 1.0001e-4 0.9998999 9.998e-5 1.00099e-4 0.9998999</float_array>\n' +\
214 ' <technique_common>\n' +\
215 ' <accessor source="#Cylinder-mesh-map-0-array" count="36" stride="2">\n' +\
216 ' <param name="S" type="float"/>\n' +\
217 ' <param name="T" type="float"/>\n' +\
219 ' </technique_common>\n' +\
221 ' <vertices id="Cylinder-mesh-vertices">\n' +\
222 ' <input semantic="POSITION" source="#Cylinder-mesh-positions"/>\n' +\
224 ' <triangles material="Material_002-material" count="12">\n' +\
225 ' <input semantic="VERTEX" source="#Cylinder-mesh-vertices" offset="0"/>\n' +\
226 ' <input semantic="NORMAL" source="#Cylinder-mesh-normals" offset="1"/>\n' +\
227 ' <input semantic="TEXCOORD" source="#Cylinder-mesh-map-0" offset="2" set="0"/>\n' +\
228 ' <p>4 0 0 5 0 1 1 0 2 5 1 3 6 1 4 2 1 5 6 2 6 7 2 7 3 2 8 7 3 9 4 3 10 0 3 11 0 4 12 1 4 13 2 4 14 7 5 15 6 5 16 5 5 17 0 0 18 4 0 19 1 0 20 1 1 21 5 1 22 2 1 23 2 2 24 6 2 25 3 2 26 3 3 27 7 3 28 0 3 29 3 4 30 0 4 31 2 4 32 4 5 33 7 5 34 5 5 35</p>\n' +\
232 ' </library_geometries>\n' +\
233 ' <library_visual_scenes>\n' +\
234 ' <visual_scene id="Scene" name="Scene">\n' +\
235 ' <node id="Cylinder" name="Cylinder" type="NODE">\n' +\
236 ' <matrix sid="transform">{} 0 0 0 0 {} 0 0 0 0 {} 0 0 0 0 1</matrix>\n'.format(0.01*size_cm, 0.01*size_cm, 0.002) +\
237 ' <instance_geometry url="#Cylinder-mesh" name="Cylinder">\n' +\
238 ' <bind_material>\n' +\
239 ' <technique_common>\n' +\
240 ' <instance_material symbol="Material_002-material" target="#Material_002-material">\n' +\
241 ' <bind_vertex_input semantic="Cylinder-mesh-map-0" input_semantic="TEXCOORD" input_set="0"/>\n' +\
242 ' </instance_material>\n' +\
243 ' <instance_material symbol="Material_001-material" target="#Material_001-material">\n' +\
244 ' <bind_vertex_input semantic="Cylinder-mesh-map-0" input_semantic="TEXCOORD" input_set="0"/>\n' +\
245 ' </instance_material>\n' +\
246 ' </technique_common>\n' +\
247 ' </bind_material>\n' +\
248 ' </instance_geometry>\n' +\
250 ' </visual_scene>\n' +\
251 ' </library_visual_scenes>\n' +\
253 ' <instance_visual_scene url="#Scene"/>\n' +\
258 subprocess.call([
'rosrun',
'ar_track_alvar',
'createMarker',
'-s', str(size_cm), str(marker_id)],
263 path_in = path +
'/' + dir_name
268 print (
"Creation of the directory %s failed" % path)
271 print (
"Successfully created the directory %s " % path)
273 with open(path_in +
'/model.config',
'w')
as f:
276 with open(path_in +
'/model.sdf',
'w')
as f:
279 path_meshes = path_in +
'/meshes' 280 os.mkdir(path_meshes)
284 path_materials = path_in +
'/materials' 285 os.mkdir(path_materials)
288 if __name__ ==
"__main__":
290 for marker_id
in range(0, 35):
def getMarkerModelName(size_cm, marker_id)
def getMaterialFilename(marker_id)
def createMarkerGazeboModel(path, size_cm, marker_id)
def getMeshFilename(size_cm)
def generateSdf(size_cm, marker_id)
def generateMesh(size_cm, marker_id)
def generateModelConfig(size_cm, marker_id)
def createMaterialFile(path, size_cm, marker_id)