ros-simulation / gazebo_ros_pkgs

Wrappers, tools and additional API's for using ROS with Gazebo
http://wiki.ros.org/gazebo_ros_pkgs
742 stars 766 forks source link

Issue in spawn_entity.py ROS2 version #1525

Open RDaneelOlivav opened 3 months ago

RDaneelOlivav commented 3 months ago

Hi I got the error:

[INFO] [1711033583.879509419] [spawn_entity]: Spawn Entity started
[INFO] [1711033583.881519221] [spawn_entity]: Loading entity XML from file /home/user/ros2_ws/src/grasp_box_mini.urdf
Traceback (most recent call last):
  File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 370, in <module>
    main()
  File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 365, in main
    exit_code = spawn_entity_node.run()
  File "/opt/ros/humble/lib/gazebo_ros/spawn_entity.py", line 143, in run    self.get_logger().error('Error: specified file %s does not exist', self.args.file)
TypeError: RcutilsLogger.error() takes 2 positional arguments but 3 were given
[ros2run]: Process exited with failure 1

I solved it by changing:

self.get_logger().error('Error: specified file %s does not exist', self.args.file)

To

self.get_logger().error(f'Error: specified file {self.args.file} does not exist')

I imagine this issue apperaed recently because I worked some days ago with it and it worked perfectly.

In case someone has this issue