Robotics StackExchange | Archived questions

how to run the world of gazebo and robot separately?

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.

Asked by sharp-0000ff on 2022-08-15 14:00:33 UTC

Comments

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.

Asked by muratcngncr on 2022-08-16 02:55:16 UTC

Answers

Thanks, I solved the problem.

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

Asked by sharp-0000ff on 2022-08-23 03:36:32 UTC

Comments