0
$\begingroup$

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.

$\endgroup$
0

1 Answer 1

1
$\begingroup$

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

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.