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

how to run the world of gazebo and robot separately?

asked 2022-08-15 14:00:33 -0600

sharp-0000ff gravatar image

updated 2022-08-15 14:00:48 -0600

I use Ubuntu 20.04, ROS2 Foxy, Gazebo11

Hi, everyone.

I'm trying to run gazebo.launch.py and robot.launch.py

gazebo.launch.py

def generate_launch_description():
    gazebo_ros_pkg = get_package_share_directory('gazebo_ros')

    gazebo = IncludeLaunchDescription(PythonLaunchDescriptionSource(os.path.join(gazebo_ros_pkg, 'launch', 'gazebo.launch.py')))

    return LaunchDescription([
        gazebo,
    ])

robot.launch.py

def generate_launch_description():
    use_sim_time = LaunchConfiguration('use_sim_time', default='true')
    description_pkg = get_package_share_directory('robot_description')
    xacro_file = PathJoinSubstitution([description_pkg, 'urdf', 'robot.urdf.xacro'])
    robot_description = ParameterValue(Command(['xacro', ' ', xacro_file]), value_type=str)

    robot_state_publisher_node = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        parameters=[{'robot_description' : robot_description},
                    {'use_sim_time' : use_sim_time},
                    {'publish_frequency' : 30.0}],
        output='screen',
     )

    spawn_node = Node(
        package='gazebo_ros',
        executable='spawn_entity.py',
        arguments=['-topic', {"robot_description": robot_description}, "-entity", "robot", "-x", "0.0", "-y", "0.0", "-z", "0.0"],
        output='screen',
    )

I see endless loading and nothing else, but if I copy/paste the gazebo config into robot.launch.py everything loads fine. Help me, please.

edit retag flag offensive close merge delete

Comments

1

instead of

    gazebo = IncludeLaunchDescription(PythonLaunchDescriptionSource(os.path.join(gazebo_ros_pkg, 'launch', 'gazebo.launch.py')))

can you try to add

  start_gazebo_server_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')))


     start_gazebo_client_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py')))

Also in your robot.launch i am assuming there is a return launch description.

muratcngncr gravatar image muratcngncr  ( 2022-08-16 02:55:16 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-08-23 03:36:32 -0600

sharp-0000ff gravatar image

updated 2022-08-23 03:37:59 -0600

Thanks, I solved the problem.

Gazebo couldn't find my mesh files via filename="package://. I changed to filename="file:// in URDF.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-08-15 14:00:33 -0600

Seen: 77 times

Last updated: Aug 23 '22