ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Spawning a Robot in Gazebo using Python Launch File

asked 2023-03-07 13:34:34 -0600

ROS_Engineer gravatar image

updated 2023-03-07 14:08:14 -0600

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
])
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-03-07 14:07:43 -0600

ROS_Engineer gravatar image

Solution to spawning a robot from a URDF file into a Gazebo instance provided above. Hope it helped.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-03-07 13:34:34 -0600

Seen: 1,511 times

Last updated: Mar 07 '23