include model in world 2023
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/tree/master/fire_truck. But, I get an error that the file cannot be found.
After installation, neither GZSIMRESOURCEPATH or IGNGAZEBORESOURCEPATH 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/rosgzsim_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.
Asked by mjohannessen on 2023-07-27 11:41:34 UTC
Answers
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/tree/master 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>
Asked by mjohannessen on 2023-07-27 14:48:25 UTC
Comments