在gazebo ros2中加载sdf文件时发生RutilsLogger.error()



我试图通过名为'launch_py''launch/car_launch2.launch.py'的python包中的启动文件加载名为
'models_pkg''和

'models/rcCar_assembly/sdf'凉亭版本:11.10.2ros2发行版:谦逊的

hp@hp-HP-Pavilion-Gaming-Laptop-15-dk2xxx:~/rosws/ros2/bfmc_ws$ ros2 launch launch_py car_launch2.launch.py
[INFO] [launch]: All log files can be found below /home/hp/.ros/log/2022-09-25-10-53-59-112288-hp-HP-Pavilion-Gaming-Laptop-15-dk2xxx-20694
[INFO] [launch]: Default logging verbosity is set to INFO
urdf_file_name : rcCar_assembly/model.sdf
[INFO] [spawn_entity.py-1]: process started with pid [20695]
[spawn_entity.py-1] [INFO] [1664083439.508709594] [spawn_entity]: Spawn Entity started
[spawn_entity.py-1] [INFO] [1664083439.509012197] [spawn_entity]: Loading entity XML from file /home/hp/rosws/ros2/bfmc_ws/install/models_pkg/share/models_pkg/rcCar_assembly/model.sdf
[spawn_entity.py-1] Traceback (most recent call last):
[spawn_entity.py-1]   File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 370, in <module>
[spawn_entity.py-1]     main()
[spawn_entity.py-1]   File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 365, in main
[spawn_entity.py-1]     exit_code = spawn_entity_node.run()
[spawn_entity.py-1]   File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 143, in run
[spawn_entity.py-1]     self.get_logger().error('Error: specified file %s does not exist', self.args.file)
[spawn_entity.py-1] TypeError: RcutilsLogger.error() takes 2 positional arguments but 3 were given
[ERROR] [spawn_entity.py-1]: process has died [pid 20695, exit code 1, cmd '/opt/ros/humble/lib/gazebo_ros/spawn_entity.py -entity automobile -file /home/hp/rosws/ros2/bfmc_ws/install/models_pkg/share/models_pkg/rcCar_assembly/model.sdf -x 0.82 -y -14.91 -z 0.032939 -Y 1.5707 --ros-args'].
hp@hp-HP-Pavilion-Gaming-Laptop-15-dk2xxx:~/rosws/ros2/bfmc_ws$ 
~/rosws/ros2/bfmc_ws$ ros2 launch gazebo_ros gazebo.launch.py
[INFO] [launch]: All log files can be found below /home/hp/.ros/log/2022-09-25-11-06-53-410707-hp-HP-Pavilion-Gaming-Laptop-15-dk2xxx-21804
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [gzserver-1]: process started with pid [21805]
[INFO] [gzclient-2]: process started with pid [21807]
[ERROR] [gzserver-1]: process has died [pid 21805, exit code 255, cmd 'gzserver -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so'].
[gzclient-2] ../src/intel/isl/isl.c:2220: FINISHME: ../src/intel/isl/isl.c:isl_surf_supports_ccs: CCS for 3D textures is disabled, but a workaround is available.

car_launch2.launch.py

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
def generate_launch_description():
use_sim_time = LaunchConfiguration('use_sim_time', default='false')
urdf_file_name = 'rcCar_assembly/model.sdf'
args_ = " -model automobile -sdf -x 0.82 -y -14.91 -z 0.032939 -Y 1.570796"
print("urdf_file_name : {}".format(urdf_file_name))
urdf = os.path.join(
get_package_share_directory('models_pkg'),
urdf_file_name)
return LaunchDescription([
DeclareLaunchArgument(
'use_sim_time',
default_value='false',
description='Use simulation (Gazebo) clock if true'),
Node(
package="gazebo_ros",
executable  = "spawn_entity.py",
output='screen',
arguments=["-entity", "automobile",
"-file", urdf,
"-x","0.82",
"-y","-14.91",
"-z","0.032939",
"-Y","1.5707"])
])

这只是一个目录问题,指定的文件不在目录中

Loading entity XML from file /home/hp/rosws/ros2/bfmc_ws/install/models_pkg/share/models_pkg/rcCar_assembly/model.sdf

请检查文件的路径

最新更新