foxy can't launch gazebo11 model and report SyntaxError.
hello, I'm trying to use the foxy to launch the simulation environment(gazebo11) on the ubuntu20.04,but can not load the robot model and report an error. The error is as follows:
[spawn_entity.py-4] Traceback (most recent call last):
[spawn_entity.py-4] File "/opt/ros/foxy/lib/gazebo_ros/spawn_entity.py", line 27, in <module>
[spawn_entity.py-4] from gazebo_msgs.msg import ModelStates
[spawn_entity.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/gazebo_msgs/msg/__init__.py", line 1, in <module>
[spawn_entity.py-4] from gazebo_msgs.msg._contact_state import ContactState # noqa: F401
[spawn_entity.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/gazebo_msgs/msg/_contact_state.py", line 11, in <module>
[spawn_entity.py-4] import rosidl_parser.definition # noqa: E402, I100
[spawn_entity.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/rosidl_parser/definition.py", line 426
[spawn_entity.py-4] raise ValueError(f"No '{name}' annotation")
[spawn_entity.py-4] ^
[spawn_entity.py-4] SyntaxError: invalid syntax
[ERROR] [spawn_entity.py-4]: process has died [pid 4442, exit code 1, cmd '/opt/ros/foxy/lib/gazebo_ros/spawn_entity.py --ros-args -r __node:=urdf_spawner'].
I want to use String.format(name) solve the problem,but it will report more error。such as :
[spawn_entity.py-4] import rclpy
[spawn_entity.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/__init__.py", line 50, in <module>
[spawn_entity.py-4] from rclpy.utilities import get_default_context
[spawn_entity.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/utilities.py", line 98
[spawn_entity.py-4] f'The RMW implementations {missing_rmw_implementations}
and
[spawn_entity.py-4] from rclpy.node import Node
[spawn_entity.py-4] File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/node.py'',line 146
[spawn_entity.py-4] self.__subcriptions: List[Subcription]=[]
[spawn_entity.py-4] SyntaxError: invalid syntax
my laucnh file code:
import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, ExecuteProcess,IncludeLaunchDescription
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.substitutions import FindPackageShare
def generate_launch_description():
use_sim_time = LaunchConfiguration('use_sim_time', default='false')
urdf_file_name = '/home/zys/ros2_prj/AGV_SIM_WS/src/urdf_tutorial_r2d2/urdf/agv_car.urdf'
package_name = 'urdf_tutorial_r2d2'
pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
print("urdf_file_name : {}".format(urdf_file_name))
urdf = os.path.join(
get_package_share_directory('urdf_tutorial_r2d2'),
urdf_file_name)
with open(urdf, 'r') as infp:
robot_desc = infp.read()
return LaunchDescription([
DeclareLaunchArgument(
'use_sim_time',
default_value='false',
description='Use simulation (Gazebo) clock if true'),
ExecuteProcess(
# cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_factory.so'],
cmd=['gazebo', '--verbose', '/home/zys/ros2_prj/AGV_SIM_WS/src/urdf_tutorial_r2d2/sim_world/box_house.world'],
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_desc}],
arguments=[urdf]),
Node(
package='joint_state_publisher',
executable='joint_state_publisher',
name='joint_state_publisher',
parameters=[{'use_sim_time': use_sim_time, 'robot_description': robot_desc}],
output='screen',
),
Node(
package='gazebo_ros',
executable='spawn_entity.py',
name='urdf_spawner',
output='screen',
# arguments=["-topic", "/robot_description", "-entity", -f"AGV_CAR"])
# arguments=['-entity',
# 'mobot',
# '-x', '3.5', '-y', '1.0', '-z', '0.1',
# '-file', urdf
# ]
)
])
my running enviroment:
Linux ubuntu20.04
gazebo11
ROS_VERSION=2
ROS_PYTHON_VERSION=3
ROS_LOCALHOST_ONLY=0
ROS_DISTRO=foxy