在ros1中可以直接通过命令行实现
rosbag record --split --duration=10m --max-splits 6 /scan
这样就可以记录最新10*6=60分钟以内的scan话题到bag文件了,在60分钟之前的bag会被回滚删除
但是ros2 bag中没有这样的实现命令
在ros1中可以直接通过命令行实现
rosbag record --split --duration=10m --max-splits 6 /scan
这样就可以记录最新10*6=60分钟以内的scan话题到bag文件了,在60分钟之前的bag会被回滚删除
但是ros2 bag中没有这样的实现命令
各位大佬:
使用C++创建节点,订阅某topic,将topic存入队列,保持队列队首和队尾话题时间戳间隔不超过某固定周期,超过的则pop队首,等调用保存bag服务时,将队列中的topic写入bag文件。
但是这样带来的问题是:使用ros2 bag play ${bag}时,无论多长时间的bag,都会瞬间播放完毕,而没有按照话题间的时间间隔。
有没有办法在写bag时解决该问题,难道只能使用ros2bag reader的API在程序中根据话题时间间隔休眠后再发布吗?
ros2 service call /save_map cartographer_ros_msgs/srv/SaveMap "{path: /home/, include_unfinished_submaps: true}"
Traceback (most recent call last):
File "/opt/ros2/foxy/lib/python3.6/site-packages/rosidl_generator_py/import_type_support_impl.py", line 46, in import_type_support
return importlib.import_module(module_name, package=pkg_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'cartographer_ros_msgs.cartographer_ros_msgs_s__rosidl_typesupport_c'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/ros2/foxy/bin/ros2", line 11, in <module>
load_entry_point('ros2cli==0.9.11', 'console_scripts', 'ros2')()
File "/opt/ros2/foxy/lib/python3.6/site-packages/ros2cli/cli.py", line 67, in main
rc = extension.main(parser=parser, args=args)
File "/opt/ros2/foxy/lib/python3.6/site-packages/ros2service/command/service.py", line 41, in main
return extension.main(args=args)
File "/opt/ros2/foxy/lib/python3.6/site-packages/ros2service/verb/call.py", line 59, in main
args.service_type, args.service_name, args.values, period)
File "/opt/ros2/foxy/lib/python3.6/site-packages/ros2service/verb/call.py", line 83, in requester
cli = node.create_client(srv_module, service_name)
File "/opt/ros2/foxy/lib/python3.6/site-packages/rclpy/node.py", line 1249, in create_client
check_for_type_support(srv_type)
File "/opt/ros2/foxy/lib/python3.6/site-packages/rclpy/type_support.py", line 29, in check_for_type_support
msg_type.__class__.__import_type_support__()
File "/opt/eame/cartographer_ros_msgs/lib/python3.6/site-packages/cartographer_ros_msgs/srv/_save_map.py", line 279, in __import_type_support__
module = import_type_support('cartographer_ros_msgs')
File "/opt/ros2/foxy/lib/python3.6/site-packages/rosidl_generator_py/import_type_support_impl.py", line 48, in import_type_support
raise UnsupportedTypeSupport(pkg_name)
rosidl_generator_py.import_type_support_impl.UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package 'cartographer_ros_msgs'
ros2先后source 同名pkg但路径不同(path1和path2)的local_setup.bash,再source path1的local_setup.bash无效,pkg的环境变量仍为path2,这是为什么? 难道是环境变量已有path1和path2,且path2在path1前面,当再次source path1的local_setup.bash时,不会再往环境变量里添加path1?这是什么机理?
@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,
])
@小鱼 我发现我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'].
各位大佬,我想通过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的运动,不知到原因是什么