紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
ros2在gazebo中控制lidar_joint旋转
-
各位大佬,我想通过gazebo仿真实现控制单线雷达关节旋转,完成三维扫描,以下是我运行时的报错,主要在于“Spawn status: Entity [turtlebot3_waffle] already exists”
ros2 launch turtlebot3_gazebo turtlebot3_house0.launch.py [INFO] [launch]: All log files can be found below /home/hql/.ros/log/2023-08-21-14-13-49-966433-hql-ZhaoYang-K4e-ITL-51997 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [gzserver-1]: process started with pid [51999] [INFO] [gzclient -2]: process started with pid [52001] [INFO] [spawn_entity.py-3]: process started with pid [52004] [INFO] [robot_state_publisher-4]: process started with pid [52007] [robot_state_publisher-4] Parsing robot urdf xml string. [robot_state_publisher-4] Link base_link had 7 children [robot_state_publisher-4] Link camera_link had 2 children [robot_state_publisher-4] Link camera_depth_frame had 1 children [robot_state_publisher-4] Link camera_depth_optical_frame had 0 children [robot_state_publisher-4] Link camera_rgb_frame had 1 children [robot_state_publisher-4] Link camera_rgb_optical_frame had 0 children [robot_state_publisher-4] Link caster_back_left_link had 0 children [robot_state_publisher-4] Link caster_back_right_link had 0 children [robot_state_publisher-4] Link imu_link had 0 children [robot_state_publisher-4] Link base_scan had 0 children [robot_state_publisher-4] Link wheel_left_link had 0 children [robot_state_publisher-4] Link wheel_right_link had 0 children [robot_state_publisher-4] [INFO] [1692598430.338458857] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-4] [INFO] [1692598430.338521434] [robot_state_publisher]: got segment base_link [robot_state_publisher-4] [INFO] [1692598430.338526266] [robot_state_publisher]: got segment base_scan [robot_state_publisher-4] [INFO] [1692598430.338529278] [robot_state_publisher]: got segment camera_depth_frame [robot_state_publisher-4] [INFO] [1692598430.338532361] [robot_state_publisher]: got segment camera_depth_optical_frame [robot_state_publisher-4] [INFO] [1692598430.338535346] [robot_state_publisher]: got segment camera_link [robot_state_publisher-4] [INFO] [1692598430.338538123] [robot_state_publisher]: got segment camera_rgb_frame [robot_state_publisher-4] [INFO] [1692598430.338540907] [robot_state_publisher]: got segment camera_rgb_optical_frame [robot_state_publisher-4] [INFO] [1692598430.338543632] [robot_state_publisher]: got segment caster_back_left_link [robot_state_publisher-4] [INFO] [1692598430.338546345] [robot_state_publisher]: got segment caster_back_right_link [robot_state_publisher-4] [INFO] [1692598430.338549126] [robot_state_publisher]: got segment imu_link [robot_state_publisher-4] [INFO] [1692598430.338551809] [robot_state_publisher]: got segment wheel_left_link [robot_state_publisher-4] [INFO] [1692598430.338554579] [robot_state_publisher]: got segment wheel_right_link [spawn_entity.py-3] [INFO] [1692598430.699218816] [spawn_entity]: Spawn Entity started [spawn_entity.py-3] [INFO] [1692598430.699438523] [spawn_entity]: Loading entity published on topic robot_description [spawn_entity.py-3] [INFO] [1692598430.700504205] [spawn_entity]: Waiting for entity xml on robot_description [spawn_entity.py-3] [INFO] [1692598430.712174955] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30 [spawn_entity.py-3] [INFO] [1692598430.712361052] [spawn_entity]: Waiting for service /spawn_entity [gzserver-1] Warning [parser.cc:833] XML Attribute[version] in element[sdf] not defined in SDF, ignoring. [gzserver-1] [INFO] [1692598431.457520457] [turtlebot3_imu]: <initial_orientation_as_reference> is unset, using default value of false to comply with REP 145 (world as orientation reference) [spawn_entity.py-3] [INFO] [1692598431.466083664] [spawn_entity]: Calling service /spawn_entity [spawn_entity.py-3] [INFO] [1692598431.479069834] [spawn_entity]: Spawn status: Entity [turtlebot3_waffle] already exists. [spawn_entity.py-3] [ERROR] [1692598431.479316168] [spawn_entity]: Spawn service failed. Exiting. [gzserver-1] ../src/intel/isl/isl.c:2105: FINISHME: ../src/intel/isl/isl.c:isl_surf_supports_ccs: CCS for 3D textures is disabled, but a workaround is available. [ERROR] [spawn_entity.py-3]: process has died [pid 52004, exit code 1, cmd '/opt/ros/foxy/lib/gazebo_ros/spawn_entity.py -topic robot_description -entity turtlebot3_waffle --ros-args']. [INFO] [ros2-5]: process started with pid [52113] [gzclient -2] ../src/intel/isl/isl.c:2105: FINISHME: ../src/intel/isl/isl.c:isl_surf_supports_ccs: CCS for 3D textures is disabled, but a workaround is available. [gzserver-1] [INFO] [1692598432.288202592] [camera_driver]: Publishing camera info to [/camera/camera_info] [gzserver-1] [INFO] [1692598432.303368286] [turtlebot3_diff_drive]: Wheel pair 1 separation set to [0.287000m] [gzserver-1] [INFO] [1692598432.303420511] [turtlebot3_diff_drive]: Wheel pair 1 diameter set to [0.066000m] [gzserver-1] [INFO] [1692598432.304143535] [turtlebot3_diff_drive]: Subscribed to [/cmd_vel] [gzserver-1] [INFO] [1692598432.304831018] [turtlebot3_diff_drive]: Advertise odometry on [/odom] [gzserver-1] [INFO] [1692598432.305499218] [turtlebot3_diff_drive]: Publishing odom transforms between [odom] and [base_footprint] [gzserver-1] [INFO] [1692598432.312081807] [turtlebot3_joint_state]: Going to publish joint [wheel_left_joint] [gzserver-1] [INFO] [1692598432.312118787] [turtlebot3_joint_state]: Going to publish joint [wheel_right_joint] [gzserver-1] [INFO] [1692598432.322473284] [gazebo_ros2_control]: Loading gazebo_ros2_control plugin [gzserver-1] [INFO] [1692598432.324913210] [gazebo_ros_control]: Starting gazebo_ros2_control plugin in namespace: / [gzserver-1] [INFO] [1692598432.324950093] [gazebo_ros_control]: Starting gazebo_ros2_control plugin in ros 2 node: gazebo_ros_control [gzserver-1] [ERROR] [1692598432.324987156] [gazebo_ros_control]: No parameter file provided. Configuration might be wrong [gzserver-1] [ERROR] [1692598432.325048344] [gazebo_ros_control]: failed to parse input yaml file(s) [ros2-5] Could not contact service /controller_manager/load_controller [ERROR] [ros2-5]: process has died [pid 52113, exit code 1, cmd 'ros2 control load_controller --set-state start joint_state_broadcaster']. [INFO] [ros2-6]: process started with pid [52213] [ros2-6] Could not contact service /controller_manager/load_controller [ERROR] [ros2-6]: process has died [pid 52213, exit code 1, cmd 'ros2 control load_controller --set-state start lidar_joint_position_controller'].
这是我的launch文件
#!/usr/bin/env python3 # # Copyright 2019 ROBOTIS CO., LTD. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Authors: Darby Lim, Ryan Shim import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration from launch.actions import ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler from launch.event_handlers import OnProcessExit from launch.launch_description_sources import PythonLaunchDescriptionSource from launch_ros.actions import Node import xacro TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL'] def generate_launch_description(): gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource([os.path.join( get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']), ) use_sim_time = LaunchConfiguration('use_sim_time', default='true') world_file_name = 'turtlebot3_houses/' + TURTLEBOT3_MODEL + '.model' world = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'worlds', world_file_name) world = '/opt/ros/foxy/share/turtlebot3_gazebo/worlds/turtlebot3_houses/waffle.model' launch_file_dir = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'launch') pkg_gazebo_ros = get_package_share_directory('gazebo_ros') gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource([os.path.join( get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']), ) turtlebot3_description_path = os.path.join( get_package_share_directory('turtlebot3_description')) xacro_file = os.path.join(turtlebot3_description_path, 'urdf', 'turtlebot3_waffle.xacro.urdf') doc = xacro.parse(open(xacro_file)) xacro.process_doc(doc) params = {'robot_description': doc.toxml()} node_robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', output='screen', parameters=[params] ) spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=['-topic', 'robot_description', '-entity', 'turtlebot3_waffle'], output='screen') load_joint_state_controller = ExecuteProcess( cmd=['ros2', 'control', 'load_controller', '--set-state', 'start', 'joint_state_broadcaster'], output='screen' ) load_position_controllers = ExecuteProcess( cmd=['ros2', 'control', 'load_controller', '--set-state', 'start', 'lidar_joint_position_controller'], output='screen' ) return LaunchDescription([ RegisterEventHandler( event_handler=OnProcessExit( target_action=spawn_entity, on_exit=[load_joint_state_controller], ) ), RegisterEventHandler( event_handler=OnProcessExit( target_action=load_joint_state_controller, on_exit=[load_position_controllers], ) ), #gazebo, IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py') ), launch_arguments={'world': world}.items(), ), IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py') ), ), spawn_entity, node_robot_state_publisher, ])
我测试发现加载一个空的gazebo环境不会出现以上问题,且可以通过发布话题实现控制lidar_joint的运动,不知到原因是什么
-
@811877507 因为非空的world里已经有一个小车了,你再加载小车,so...
-
@小鱼 大佬,那我该怎么通过spawn加载房间环境和小车呢
-
@小鱼 我是想用ros control控制house环境中的车的关节运动,大佬帮我看看有launch文件有问题吗
-
@小鱼 把非空里的launch删除掉就好了
-
@小鱼 我发现我spawn_entity如果穿入的参数是topic的话,还能正常运行,只是gazebo不显示模型,但是如果参数是database的话,虽然gazebo显示模型,但是gazebo_ros_control报错,load_controller失败
[INFO] [launch]: All log files can be found below /home/hql/.ros/log/2023-08-21-16-45-37-739355-hql-ZhaoYang-K4e-ITL-89542 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [gzserver-1]: process started with pid [89544] [INFO] [gzclient -2]: process started with pid [89546] [INFO] [spawn_entity.py-3]: process started with pid [89549] [INFO] [robot_state_publisher-4]: process started with pid [89551] [robot_state_publisher-4] Parsing robot urdf xml string. [robot_state_publisher-4] Link base_link had 7 children [robot_state_publisher-4] Link camera_link had 2 children [robot_state_publisher-4] Link camera_depth_frame had 1 children [robot_state_publisher-4] Link camera_depth_optical_frame had 0 children [robot_state_publisher-4] Link camera_rgb_frame had 1 children [robot_state_publisher-4] Link camera_rgb_optical_frame had 0 children [robot_state_publisher-4] Link caster_back_left_link had 0 children [robot_state_publisher-4] Link caster_back_right_link had 0 children [robot_state_publisher-4] Link imu_link had 0 children [robot_state_publisher-4] Link base_scan had 0 children [robot_state_publisher-4] Link wheel_left_link had 0 children [robot_state_publisher-4] Link wheel_right_link had 0 children [robot_state_publisher-4] [INFO] [1692607538.110385903] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-4] [INFO] [1692607538.110440445] [robot_state_publisher]: got segment base_link [robot_state_publisher-4] [INFO] [1692607538.110444751] [robot_state_publisher]: got segment base_scan [robot_state_publisher-4] [INFO] [1692607538.110447557] [robot_state_publisher]: got segment camera_depth_frame [robot_state_publisher-4] [INFO] [1692607538.110450364] [robot_state_publisher]: got segment camera_depth_optical_frame [robot_state_publisher-4] [INFO] [1692607538.110453364] [robot_state_publisher]: got segment camera_link [robot_state_publisher-4] [INFO] [1692607538.110456010] [robot_state_publisher]: got segment camera_rgb_frame [robot_state_publisher-4] [INFO] [1692607538.110458649] [robot_state_publisher]: got segment camera_rgb_optical_frame [robot_state_publisher-4] [INFO] [1692607538.110461414] [robot_state_publisher]: got segment caster_back_left_link [robot_state_publisher-4] [INFO] [1692607538.110464076] [robot_state_publisher]: got segment caster_back_right_link [robot_state_publisher-4] [INFO] [1692607538.110466752] [robot_state_publisher]: got segment imu_link [robot_state_publisher-4] [INFO] [1692607538.110469360] [robot_state_publisher]: got segment wheel_left_link [robot_state_publisher-4] [INFO] [1692607538.110472023] [robot_state_publisher]: got segment wheel_right_link [spawn_entity.py-3] [INFO] [1692607538.789917495] [spawn_entity]: Spawn Entity started [spawn_entity.py-3] [INFO] [1692607538.790110541] [spawn_entity]: Loading entity XML from Gazebo Model Database [spawn_entity.py-3] [INFO] [1692607538.790595980] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30 [spawn_entity.py-3] [INFO] [1692607538.790753386] [spawn_entity]: Waiting for service /spawn_entity [spawn_entity.py-3] [INFO] [1692607539.043183064] [spawn_entity]: Calling service /spawn_entity [gzserver-1] [INFO] [1692607539.295802329] [turtlebot3_imu]: <initial_orientation_as_reference> is unset, using default value of false to comply with REP 145 (world as orientation reference) [spawn_entity.py-3] [INFO] [1692607539.351107675] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [turtlebot3_waffle] [gzserver-1] ../src/intel/isl/isl.c:2105: FINISHME: ../src/intel/isl/isl.c:isl_surf_supports_ccs: CCS for 3D textures is disabled, but a workaround is available. [INFO] [spawn_entity.py-3]: process has finished cleanly [pid 89549] [INFO] [ros2-5]: process started with pid [89678] [gzclient -2] ../src/intel/isl/isl.c:2105: FINISHME: ../src/intel/isl/isl.c:isl_surf_supports_ccs: CCS for 3D textures is disabled, but a workaround is available. [gzserver-1] [INFO] [1692607540.028915368] [camera_driver]: Publishing camera info to [/camera/camera_info] [gzserver-1] [INFO] [1692607540.063431383] [turtlebot3_diff_drive]: Wheel pair 1 separation set to [0.287000m] [gzserver-1] [INFO] [1692607540.063480234] [turtlebot3_diff_drive]: Wheel pair 1 diameter set to [0.066000m] [gzserver-1] [INFO] [1692607540.064669715] [turtlebot3_diff_drive]: Subscribed to [/cmd_vel] [gzserver-1] [INFO] [1692607540.065357436] [turtlebot3_diff_drive]: Advertise odometry on [/odom] [gzserver-1] [INFO] [1692607540.065961237] [turtlebot3_diff_drive]: Publishing odom transforms between [odom] and [base_footprint] [gzserver-1] [INFO] [1692607540.072362177] [turtlebot3_joint_state]: Going to publish joint [wheel_left_joint] [gzserver-1] [INFO] [1692607540.072400319] [turtlebot3_joint_state]: Going to publish joint [wheel_right_joint] [gzserver-1] [INFO] [1692607540.082506411] [gazebo_ros2_control]: Loading gazebo_ros2_control plugin [gzserver-1] [INFO] [1692607540.084576222] [gazebo_ros_control]: Starting gazebo_ros2_control plugin in namespace: / [gzserver-1] [INFO] [1692607540.084612420] [gazebo_ros_control]: Starting gazebo_ros2_control plugin in ros 2 node: gazebo_ros_control [gzserver-1] [ERROR] [1692607540.084640023] [gazebo_ros_control]: No parameter file provided. Configuration might be wrong [gzserver-1] [ERROR] [1692607540.084681996] [gazebo_ros_control]: failed to parse input yaml file(s) [ros2-5] Could not contact service /controller_manager/load_controller [ERROR] [ros2-5]: process has died [pid 89678, exit code 1, cmd 'ros2 control load_controller --set-state start joint_state_broadcaster']. [INFO] [ros2-6]: process started with pid [89768] [ros2-6] Could not contact service /controller_manager/load_controller [ERROR] [ros2-6]: process has died [pid 89768, exit code 1, cmd 'ros2 control load_controller --set-state start lidar_joint_position_controller'].
-
@811877507 launch文件:
#!/usr/bin/env python3 # # Copyright 2019 ROBOTIS CO., LTD. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Authors: Darby Lim, Ryan Shim import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration from launch.actions import ExecuteProcess, IncludeLaunchDescription, RegisterEventHandler from launch.event_handlers import OnProcessExit from launch.launch_description_sources import PythonLaunchDescriptionSource from launch_ros.actions import Node import xacro TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL'] def generate_launch_description(): gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource([os.path.join( get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']), ) use_sim_time = LaunchConfiguration('use_sim_time', default='true') world_file_name = 'turtlebot3_houses/' + TURTLEBOT3_MODEL + '.model' world = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'worlds', world_file_name) world = '/opt/ros/foxy/share/turtlebot3_gazebo/worlds/turtlebot3_houses/waffle.model' launch_file_dir = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'launch') pkg_gazebo_ros = get_package_share_directory('gazebo_ros') gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource([os.path.join( get_package_share_directory('gazebo_ros'), 'launch'), '/gazebo.launch.py']), ) turtlebot3_description_path = os.path.join( get_package_share_directory('turtlebot3_description')) xacro_file = os.path.join(turtlebot3_description_path, 'urdf', 'turtlebot3_waffle.xacro.urdf') doc = xacro.parse(open(xacro_file)) xacro.process_doc(doc) params = {'robot_description': doc.toxml()} node_robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', output='screen', parameters=[params] ) spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py', arguments=[#'-topic', 'robot_description', '-database', 'turtlebot3_waffle', '-entity', 'turtlebot3_waffle'], output='screen') load_joint_state_controller = ExecuteProcess( cmd=['ros2', 'control', 'load_controller', '--set-state', 'start', 'joint_state_broadcaster'], output='screen' ) load_position_controllers = ExecuteProcess( cmd=['ros2', 'control', 'load_controller', '--set-state', 'start', 'lidar_joint_position_controller'], output='screen' ) return LaunchDescription([ RegisterEventHandler( event_handler=OnProcessExit( target_action=spawn_entity, on_exit=[load_joint_state_controller], ) ), RegisterEventHandler( event_handler=OnProcessExit( target_action=load_joint_state_controller, on_exit=[load_position_controllers], ) ), gazebo, # IncludeLaunchDescription( # PythonLaunchDescriptionSource( # os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py') # ), # launch_arguments={'world': world}.items(), # ), # IncludeLaunchDescription( # PythonLaunchDescriptionSource( # os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py') # ), # ), spawn_entity, node_robot_state_publisher, ])