Files
hivecore_robot_ctrl_gui/launch/ctrlgui.launch.py
2026-02-01 11:09:49 +08:00

44 lines
1.5 KiB
Python

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os
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')
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')
ld = LaunchDescription([node_name_arg, host_arg, port_arg, params_file_arg])
ctrlgui_node = Node(
package='ctrlgui',
executable='ctrlgui_node',
name=LaunchConfiguration('node_name'),
output='screen',
emulate_tty=True,
parameters=[
LaunchConfiguration('params_file'),
{
'host': LaunchConfiguration('host'),
'port': LaunchConfiguration('port'),
},
],
)
ld.add_action(ctrlgui_node)
return ld