Spawning a Robot in Gazebo using Python Launch File
This is something I struggled with for a few hours today and I wanted to post this for posterity. If you have a URDF file and want to launch Gazebo with the robot spawned then this will get you there:
launch_gazebo_arg = IncludeLaunchDescription(
PythonLaunchDescriptionSource([get_package_share_directory('ros_ign_gazebo'), '/launch', '/ign_gazebo.launch.py']),
launch_arguments={
'ign_args' : #Add path to World File if so desired
}.items(),
)
spawn_robot_arg = Node(
package='ros_ign_gazebo',
executable='create',
output='screen',
arguments=["-file", "<path_to_urdf>/robot.urdf"]
)
return LaunchDescription([
launch_gazebo_arg,
spawn_robot_arg
])