|
|
|
|
|
|
|
|
from launch import LaunchDescription |
|
|
from launch.actions import DeclareLaunchArgument, TimerAction |
|
|
from launch.conditions import IfCondition |
|
|
from launch.substitutions import LaunchConfiguration, PythonExpression |
|
|
from launch_ros.actions import Node |
|
|
|
|
|
|
|
|
def generate_launch_description(): |
|
|
|
|
|
json_file_arg = DeclareLaunchArgument( |
|
|
'json_file', |
|
|
default_value='', |
|
|
description='Path to the JSON layout file' |
|
|
) |
|
|
|
|
|
rviz_config_arg = DeclareLaunchArgument( |
|
|
'rviz_config', |
|
|
default_value='/home/user/ws/src/db_loader/rviz/layout_view.rviz', |
|
|
description='Path to RViz config file (leave empty to skip RViz)' |
|
|
) |
|
|
|
|
|
publisher_delay_arg = DeclareLaunchArgument( |
|
|
'publisher_delay', |
|
|
default_value='1.5', |
|
|
description='Delay in seconds before starting publishers (to let subscribers connect)' |
|
|
) |
|
|
|
|
|
filled_shelves_arg = DeclareLaunchArgument( |
|
|
'filled', |
|
|
default_value='true', |
|
|
description='Display shelves as filled transparent boxes (true/false)' |
|
|
) |
|
|
|
|
|
shelf_alpha_arg = DeclareLaunchArgument( |
|
|
'alpha', |
|
|
default_value='0.3', |
|
|
description='Transparency level for filled shelves (0.0-1.0)' |
|
|
) |
|
|
|
|
|
|
|
|
static_tf_node = Node( |
|
|
package='tf2_ros', |
|
|
executable='static_transform_publisher', |
|
|
name='map_tf_publisher', |
|
|
arguments=['0', '0', '0', '0', '0', '0', 'world', 'map'], |
|
|
output='screen', |
|
|
) |
|
|
|
|
|
|
|
|
layout_visualizer_node = Node( |
|
|
package='db_loader', |
|
|
executable='layout_visualizer', |
|
|
name='layout_visualizer', |
|
|
output='screen', |
|
|
arguments=[ |
|
|
'--filled', |
|
|
'--alpha', |
|
|
LaunchConfiguration('alpha') |
|
|
], |
|
|
condition=IfCondition( |
|
|
PythonExpression([ |
|
|
'"', LaunchConfiguration('filled'), '" == "true"' |
|
|
]) |
|
|
), |
|
|
) |
|
|
|
|
|
|
|
|
layout_visualizer_wireframe_node = Node( |
|
|
package='db_loader', |
|
|
executable='layout_visualizer', |
|
|
name='layout_visualizer', |
|
|
output='screen', |
|
|
condition=IfCondition( |
|
|
PythonExpression([ |
|
|
'"', LaunchConfiguration('filled'), '" != "true"' |
|
|
]) |
|
|
), |
|
|
) |
|
|
|
|
|
|
|
|
rviz_node = Node( |
|
|
package='rviz2', |
|
|
executable='rviz2', |
|
|
name='rviz2', |
|
|
output='screen', |
|
|
arguments=['-d', LaunchConfiguration('rviz_config')], |
|
|
condition=IfCondition( |
|
|
PythonExpression([ |
|
|
'"', LaunchConfiguration('rviz_config'), '" != ""' |
|
|
]) |
|
|
), |
|
|
) |
|
|
|
|
|
|
|
|
layout_publisher_node = Node( |
|
|
package='db_loader', |
|
|
executable='layout_publisher', |
|
|
name='layout_publisher', |
|
|
output='screen', |
|
|
arguments=[LaunchConfiguration('json_file')], |
|
|
condition=IfCondition( |
|
|
PythonExpression([ |
|
|
'"', LaunchConfiguration('json_file'), '" != ""' |
|
|
]) |
|
|
), |
|
|
) |
|
|
|
|
|
|
|
|
delayed_layout_publisher = TimerAction( |
|
|
period=LaunchConfiguration('publisher_delay'), |
|
|
actions=[layout_publisher_node] |
|
|
) |
|
|
|
|
|
return LaunchDescription([ |
|
|
json_file_arg, |
|
|
rviz_config_arg, |
|
|
publisher_delay_arg, |
|
|
filled_shelves_arg, |
|
|
shelf_alpha_arg, |
|
|
static_tf_node, |
|
|
layout_visualizer_node, |
|
|
layout_visualizer_wireframe_node, |
|
|
rviz_node, |
|
|
delayed_layout_publisher, |
|
|
]) |