2025-10-23 17:42:21 +08:00
|
|
|
from launch import LaunchDescription
|
|
|
|
|
from launch.actions import DeclareLaunchArgument
|
|
|
|
|
from launch.substitutions import LaunchConfiguration
|
|
|
|
|
from launch_ros.actions import Node
|
2026-02-01 11:09:49 +08:00
|
|
|
from ament_index_python.packages import get_package_share_directory
|
|
|
|
|
import os
|
2025-10-23 17:42:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_launch_description() -> LaunchDescription:
|
|
|
|
|
# Optional node name override from launch argument
|
|
|
|
|
node_name_arg = DeclareLaunchArgument(
|
|
|
|
|
'node_name', default_value='ctrlgui_node',
|
|
|
|
|
description='Name of the ctrlgui node')
|
|
|
|
|
host_arg = DeclareLaunchArgument(
|
|
|
|
|
'host', default_value='0.0.0.0',
|
|
|
|
|
description='Host interface for NiceGUI')
|
|
|
|
|
port_arg = DeclareLaunchArgument(
|
|
|
|
|
'port', default_value='8080',
|
|
|
|
|
description='TCP port for NiceGUI')
|
2026-02-01 11:09:49 +08:00
|
|
|
params_file_arg = DeclareLaunchArgument(
|
|
|
|
|
'params_file',
|
|
|
|
|
default_value=os.path.join(get_package_share_directory('ctrlgui'), 'config', 'ctrlgui.yaml'),
|
|
|
|
|
description='Path to the ctrlgui parameter file')
|
2025-10-23 17:42:21 +08:00
|
|
|
|
2026-02-01 11:09:49 +08:00
|
|
|
ld = LaunchDescription([node_name_arg, host_arg, port_arg, params_file_arg])
|
2025-10-23 17:42:21 +08:00
|
|
|
|
|
|
|
|
ctrlgui_node = Node(
|
|
|
|
|
package='ctrlgui',
|
|
|
|
|
executable='ctrlgui_node',
|
|
|
|
|
name=LaunchConfiguration('node_name'),
|
|
|
|
|
output='screen',
|
|
|
|
|
emulate_tty=True,
|
2026-02-01 11:09:49 +08:00
|
|
|
parameters=[
|
|
|
|
|
LaunchConfiguration('params_file'),
|
|
|
|
|
{
|
|
|
|
|
'host': LaunchConfiguration('host'),
|
|
|
|
|
'port': LaunchConfiguration('port'),
|
|
|
|
|
},
|
|
|
|
|
],
|
2025-10-23 17:42:21 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
ld.add_action(ctrlgui_node)
|
|
|
|
|
return ld
|