launch process stuck when using Python Launch file
Hi guys,
I'm trying to load my robot model in rviz using python launch file, but somehow the launch process just paused after loading robotstatepublisher and jointstatepublisher, and no error messages are returned:
[INFO] [launch]: All log files can be found below /home/muyejia1202/.ros/log/2023-01-07-15-15-17-482970-sampc-7847
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [joint_state_publisher-1]: process started with pid [7848]
[INFO] [robot_state_publisher-2]: process started with pid [7850]
**[robot_state_publisher-2] Link base_link had 5 children
[robot_state_publisher-2] Link caster_back_link had 0 children
[robot_state_publisher-2] Link imu_link had 0 children
[robot_state_publisher-2] Link base_scan had 0 children
[robot_state_publisher-2] Link wheel_left_link had 0 children
[robot_state_publisher-2] Link wheel_right_link had 0 children
[robot_state_publisher-2] [INFO] [1673126117.700923627] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-2] [INFO] [1673126117.701017667] [robot_state_publisher]: got segment base_link
[robot_state_publisher-2] [INFO] [1673126117.701023003] [robot_state_publisher]: got segment base_scan
[robot_state_publisher-2] [INFO] [1673126117.701026084] [robot_state_publisher]: got segment caster_back_link
[robot_state_publisher-2] [INFO] [1673126117.701029177] [robot_state_publisher]: got segment imu_link
[robot_state_publisher-2] [INFO] [1673126117.701032263] [robot_state_publisher]: got segment wheel_left_link
[robot_state_publisher-2] [INFO] [1673126117.701035342] [robot_state_publisher]: got segment wheel_right_link**
And above is all I got in my terminal, the process just stuck here, anyone knows why is this? Thanks!
Below is my launch file:
def generate_launch_description():
urdf_path = get_package_share_path('nuturtle_description')
default_model_path = urdf_path / 'urdf/turtlebot3_burger.urdf.xacro'
default_rviz_config_path = urdf_path / 'rviz/burger.rviz'
use_jsp = DeclareLaunchArgument(name='use_jsp', default_value='true',
choices=['true', 'false'],
description='determine how to publish joint states')
model_arg = DeclareLaunchArgument(name='model', default_value=str(default_model_path),
description='Absolute path to robot urdf file')
use_rviz = DeclareLaunchArgument(name='use_rviz', default_value='true',
choices=['true', 'false'],
description='determine whether to use rviz')
rviz_arg = DeclareLaunchArgument(name='rvizconfig',
default_value=str(default_rviz_config_path),
description='Absolute path to rviz config file')
# pass color value
use_color = DeclareLaunchArgument(name='robot_color', default_value='purple',
choices=['purple', 'red', 'green', 'blue'],
description='determine the robot color')
doc = xacro.process_file(default_model_path, \
mappings={'color': str(LaunchConfiguration('robot_color'))})
robot_description = doc.toprettyxml(indent=' ')
robot_state_publisher_node = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
output='both',
parameters=[{'robot_description': robot_description}]
)
# Depending on gui parameter, either launch joint_state_publisher or joint_state_publisher_gui
joint_state_publisher_node = Node(
package='joint_state_publisher',
executable='joint_state_publisher',
arguments=[os.path.join(urdf_path, 'urdf/turtlebot3_burger.urdf.xacro')],
condition=LaunchConfigurationEquals('use_jsp', 'true')
)
joint_state_publisher_gui_node = Node(
package='joint_state_publisher_gui',
executable='joint_state_publisher_gui',
arguments=[os.path.join(urdf_path, 'urdf/turtlebot3_burger.urdf.xacro')],
condition=LaunchConfigurationEquals('use_jsp', 'false')
)
rviz_node = Node(
package='rviz2',
executable='rviz2',
name='rviz2',
output='screen',
arguments=['-d', LaunchConfiguration('rvizconfig')],
condition=LaunchConfigurationEquals('use_rviz', 'true'),
on_exit=Shutdown() # Shut down launched system upon closing rviz.
)
return LaunchDescription([
use_jsp,
model_arg,
rviz_arg,
joint_state_publisher_node,
joint_state_publisher_gui_node,
robot_state_publisher_node,
rviz_node,
use_rviz,
use_color,
])
Asked by ros_noob1212 on 2023-01-07 16:19:52 UTC
Comments
Since it is impossible to debug so much code on the fly, I can only suggest you to comment out all your nodes (rviz_node, joint_state_publisher, etc.) and all your arguments (model_arg, use_rviz, etc.). Then you start with one node/argument and try to run the launch file. If the node starts without any problem, then you can remove the comment
#
from the next node/argument. Step by step you can tackle the problem.Asked by Andromeda on 2023-01-09 06:08:08 UTC