Can't spawn my robot in gazebo11 ros2.

asked 2022-11-22 06:05:33 -0500

Edvard gravatar image

updated 2022-11-22 06:59:27 -0500

Hi. Sorry for all mistakes, English is not my native language. I'm relatively new to ROS2 and so maybe my problem is something obvious, but I spend quite amount of time trying to solve it and steal failed. I'm porting project to Foxy from Noetic and I need to spawn my robot in gazebo with world map. World is loaded without any problem, with robot I have following issue:

[spawn_entity.py-4] [INFO] [1669159785.808222868] [urdf_spawner]: Spawn status: SpawnEntity: Successfully spawned entity [minicar]
[gazebo-1] [INFO] [1669159785.920794765] [gazebo_ros2_control]: Loading gazebo_ros2_control plugin
[gazebo-1] [INFO] [1669159785.955314297] [gazebo_ros_control]: Starting gazebo_ros2_control plugin in namespace: /
[gazebo-1] [INFO] [1669159785.955436357] [gazebo_ros_control]: Starting gazebo_ros2_control plugin in ros 2 node: gazebo_ros_control
[gazebo-1] [ERROR] [1669159785.955508975] [gazebo_ros_control]: No parameter file provided. Configuration might be wrong
[gazebo-1] [ERROR] [1669159785.955956115] [gazebo_ros_control]: parser error Couldn't parse params file: '--params-file '. Error: Error opening YAML file, at /tmp/binarydeb/ros-foxy-rcl-yaml-param-parser-1.1.14/src/parser.c:198, at /tmp/binarydeb/ros-foxy-rcl-1.1.14/src/rcl/arguments.c:388
[gazebo-1] 
[INFO] [spawn_entity.py-4]: process has finished cleanly [pid 19325]

Here is my launch file:

import os
import xacro
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess
from launch.substitutions import LaunchConfiguration, Command
from launch_ros.actions import Node
from launch.launch_description_sources import PythonLaunchDescriptionSource

xacro_path = os.path.join(get_package_share_directory('minicar_simulator'), 'urdf', 'minicar.gazebo.xacro')
xacro_doc = xacro.parse(open(xacro_path, 'r'))
xacro.process_doc(xacro_doc)
robot_description = xacro_doc.toxml()

def generate_launch_description():

    use_sim_time = LaunchConfiguration('use_sim_time', default='false')
    package_dir = get_package_share_directory('minicar_simulator')
    world_files = os.path.join(package_dir,'worlds','test_walls.world')
    print("urdf_file_name : {}".format(world_files))

    return LaunchDescription([

        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='Use simulation (Gazebo) clock if true'),

        ExecuteProcess(
            cmd=['gazebo', '--verbose', world_files, '-s', 'libgazebo_ros_factory.so'],
            output='screen'),

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

        Node(
            package='joint_state_publisher',
            executable='joint_state_publisher',
            name='joint_state_publisher',
            output='screen',
            parameters=[{'use_sim_time': use_sim_time}]
            ),

        Node(
            package='gazebo_ros',
            executable='spawn_entity.py',
            name='urdf_spawner',
            output='screen',
            arguments=["-topic", "/robot_description", "-entity", "minicar"])
    ])

minicar.gazebo.xacro file:

<?xml version="1.0"?>
<robot name="minicar" xmlns:xacro="http://ros.org/wiki/xacro">

<xacro:include filename="$(find minicar_description)/urdf/minicar.xacro" />
<xacro:include filename="$(find minicar_simulator)/urdf/macro.gazebo.xacro" />

<!-- Gazebo plugin for ROS Control -->
<gazebo>
  <plugin name="gazebo_ros_control" filename="libgazebo_ros2_control.so"/>
</gazebo>

</robot>

I understand from error that I need to provide somesort of .yaml file, but I don't really understand what file and where to provide considering that I don't invoke gazebo_ros_control in this launch file. Appreciate any help.

edit retag flag offensive close merge delete