Gazebo | Ignition | Community
Ask Your Question
0

include model in world 2023

asked 2023-07-27 11:41:34 -0500

mjohannessen gravatar image

What is the procedure to add a custom model to a .world file (using Gazebo Fortress)? I installed Gazebo Fortress on Ubuntu 22.04 using the Fortress binary at https://gazebosim.org/docs. I also have ROS2 Humble installed. I've tried this for example:

 <include>
 <uri>model://fire_truck</uri>
 </include>

..using a model downloaded from https://github.com/osrf/gazebo_models.... But, I get an error that the file cannot be found.

After installation, neither GZ_SIM_RESOURCE_PATH or IGN_GAZEBO_RESOURCE_PATH are set. I tried setting those to [my package path]/models, but that's a no go. The docs seem to be all over the place on this issue and none of the demos have a local file for a uri as an example. I also tried using the same format to include a vehicle model in /opt/ros/humble/share/ros_gz_sim_demos/models/ which contains the vehicle model.sdf and model.config files. Also, if it matters, I not only had to install Fortress (binary) but the Garden binary because without Garden, the gz command could not be found.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-27 14:49:33 -0500

mjohannessen gravatar image

Figured it out. Here's the process:

$ ign gazebo --version
Ignition Gazebo, version 6.14.0
Copyright (C) 2018 Open Source Robotics Foundation.
Released under the Apache 2.0 License.

ROS2 - Humble. Using fire_station download from https://github.com/osrf/gazebo_models... which has a directory structure like this:

fire_station
--materials
--meshes
--model.config
--model.sdf

Add to .bashrc:

export IGN_GAZEBO_RESOURCE_PATH=<full path to your models directory>

in the launch.py file:

 robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        name='robot_state_publisher',
        output='both',
        parameters=[{
                'robot_description':Command(['xacro',' ', robot_description_file]),
                'use_sim_time': True
            }],
    )

    spawn = Node(
            package='ros_gz_sim', 
            executable='create',
            arguments=[
            '-name', 'mybot',
            '-topic', '/robot_description'],
            output='screen'
        )

        gazebo = ExecuteProcess(
            cmd=['ign', 'gazebo', world_sdf_file],
            output='screen'
        )
    ...

         return LaunchDescription([
             gazebo,
             spawn,
             ... others like starting rviz, joint_state_publisher_gui, ros_gz_bridge etc.
          ])

and in world_sdf_file:

<?xml version='1.0' encoding='ASCII'?>
<sdf version='1.6'>
  <world name='world_demo'>
...
<include>
      <uri>
        model://fire_station
      </uri>
    </include>
...
 </world>
</sdf>
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-07-27 11:41:34 -0500

Seen: 393 times

Last updated: Jul 27 '23