Files
hivecore_robot_voice/launch/voice.launch.py
2026-01-27 20:53:43 +08:00

47 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import SetEnvironmentVariable
import os
def generate_launch_description():
"""启动语音交互节点,所有参数从 voice.yaml 读取"""
# 获取interfaces包的install路径
interfaces_install_path = os.path.expanduser('~/ros_learn/hivecore_robot_interfaces/install')
# 设置AMENT_PREFIX_PATH确保能找到interfaces包的消息类型
ament_prefix_path = os.environ.get('AMENT_PREFIX_PATH', '')
if interfaces_install_path not in ament_prefix_path:
if ament_prefix_path:
ament_prefix_path = f'{ament_prefix_path}:{interfaces_install_path}'
else:
ament_prefix_path = interfaces_install_path
return LaunchDescription([
SetEnvironmentVariable('AMENT_PREFIX_PATH', ament_prefix_path),
# ASR + 音频输入设备节点同时提供VAD事件Service利用云端ASR的VAD
Node(
package='robot_speaker',
executable='asr_audio_node',
name='asr_audio_node',
output='screen'
),
# TTS + 音频输出设备节点
Node(
package='robot_speaker',
executable='tts_audio_node',
name='tts_audio_node',
output='screen'
),
# 主业务逻辑节点
Node(
package='robot_speaker',
executable='robot_speaker_node',
name='robot_speaker_node',
output='screen'
),
])