I have created an Object using Blender and was able to add the Add to the Path File in Ros Humble Gazebo it worked, how to open the same SDF file using Python Launch file.
1 Answer
$\begingroup$
$\endgroup$
Solution: Steps to Follow:
1.Create a Models Folder in your Directory(package file) and store the sdf file there. I have created a single Folder named Box inside the Models File
- Models
- Box
- model.config
- model.sdf
- meshes(folder)
- mesh1.dae
- mesh2.stl
- mesh3.stl
- Box
a. Model.config file
<?xml version="1.0"?>
<model>
<name>Box</name>
<version>1.0</version>
<sdf version='1.6'>model.sdf</sdf>
<author>
<name>name</name>
<email>[email protected]</email>
</author>
<description>This is a box</description>
b. model.sdf
<?xml version="1.0" ?>
<sdf version="1.5">
<model name="Box">
<pose>0 0 0 0 0 0</pose>
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<mesh>
<uri>model://box/meshes/mesh1.dae</uri>
<scale>0.25 0.25 0.25</scale>
</mesh>
</geometry>
</collision>
<visual name="visual">
<geometry>
<mesh>
<uri>model://box/meshes/mesh1.dae</uri>
<scale>0.25 0.25 0.25</scale>
</mesh>
</geometry>
</visual>
</link>
c. How to use the Launch File in python
spawn_entity = Node(package='gazebo_ros',
executable='spawn_entity.py',
name="spawn_sdf_entity",
arguments=[ '-entity','Box','-file', LaunchConfiguration('sdf_model'),
'-x','1.0',
'-y','1.0',
'-z', '0.0',
'-R','0.0',
'-P','0.0',
'-Y','0.0'
], output='screen')
return LaunchDescription([
sdf_model,
spawn_entity,
])
I hope this will be useful for everyone!!
SYSTEM:
ROS2 Humble Linux ubuntu 22