Skip to content

Commit 9a30167

Browse files
committed
Add launch files
1 parent 4eae232 commit 9a30167

File tree

3 files changed

+235
-0
lines changed

3 files changed

+235
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Launch file for Coffee Voice Agent - Bridge Only Mode
4+
5+
This launch file runs only the ROS2 bridge node, assuming the LiveKit voice agent
6+
is already running separately (e.g., started manually or by another process).
7+
8+
The bridge connects to the voice agent via WebSocket and provides ROS2 integration.
9+
10+
Usage:
11+
ros2 launch coffee_voice_agent voice_agent_bridge.launch.py
12+
13+
# With custom parameters:
14+
ros2 launch coffee_voice_agent voice_agent_bridge.launch.py \
15+
voice_agent_host:=192.168.1.100 \
16+
voice_agent_port:=8080
17+
"""
18+
19+
from launch import LaunchDescription
20+
from launch.actions import DeclareLaunchArgument
21+
from launch.substitutions import LaunchConfiguration
22+
from launch_ros.actions import Node
23+
24+
25+
def generate_launch_description():
26+
"""Generate launch description for bridge-only mode"""
27+
28+
# Declare launch arguments
29+
host_arg = DeclareLaunchArgument(
30+
'voice_agent_host',
31+
default_value='localhost',
32+
description='Host address of the voice agent WebSocket server'
33+
)
34+
35+
port_arg = DeclareLaunchArgument(
36+
'voice_agent_port',
37+
default_value='8080',
38+
description='Port of the voice agent WebSocket server'
39+
)
40+
41+
reconnect_interval_arg = DeclareLaunchArgument(
42+
'reconnect_interval',
43+
default_value='5.0',
44+
description='Reconnection interval in seconds'
45+
)
46+
47+
# Create the bridge node
48+
bridge_node = Node(
49+
package='coffee_voice_agent',
50+
executable='voice_agent_bridge',
51+
name='voice_agent_bridge',
52+
output='screen',
53+
emulate_tty=True,
54+
parameters=[{
55+
'voice_agent_host': LaunchConfiguration('voice_agent_host'),
56+
'voice_agent_port': LaunchConfiguration('voice_agent_port'),
57+
'reconnect_interval': LaunchConfiguration('reconnect_interval'),
58+
}],
59+
respawn=True,
60+
respawn_delay=2.0
61+
)
62+
63+
return LaunchDescription([
64+
host_arg,
65+
port_arg,
66+
reconnect_interval_arg,
67+
bridge_node,
68+
])
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Launch file for Coffee Voice Agent - Standalone Mode
4+
5+
This launch file runs only the LiveKit voice agent script in console mode.
6+
Console mode provides local CLI functionality with interactive controls.
7+
8+
For console mode to work properly, run this in a proper terminal:
9+
ros2 launch coffee_voice_agent voice_agent_standalone.launch.py
10+
11+
Usage:
12+
ros2 launch coffee_voice_agent voice_agent_standalone.launch.py
13+
ros2 launch coffee_voice_agent voice_agent_standalone.launch.py mode:=dev # Development mode
14+
ros2 launch coffee_voice_agent voice_agent_standalone.launch.py mode:=start # Production mode
15+
"""
16+
17+
import os
18+
from launch import LaunchDescription
19+
from launch.actions import ExecuteProcess, DeclareLaunchArgument
20+
from launch.substitutions import LaunchConfiguration
21+
from launch_ros.substitutions import FindPackageShare
22+
23+
24+
def generate_launch_description():
25+
"""Generate launch description for standalone voice agent"""
26+
27+
# Declare launch arguments
28+
mode_arg = DeclareLaunchArgument(
29+
'mode',
30+
default_value='console',
31+
description='Voice agent mode: console (interactive CLI), dev, or start (production)'
32+
)
33+
34+
# Get package share directory
35+
package_share = FindPackageShare('coffee_voice_agent')
36+
37+
# Path to the voice agent script
38+
script_path = os.path.join(package_share.find('coffee_voice_agent'), 'scripts', 'livekit_voice_agent.py')
39+
40+
# Create the process to run the voice agent
41+
voice_agent_process = ExecuteProcess(
42+
cmd=[
43+
'python3',
44+
script_path,
45+
LaunchConfiguration('mode')
46+
],
47+
output='screen',
48+
name='livekit_voice_agent',
49+
emulate_tty=True,
50+
shell=False,
51+
respawn=False, # Don't auto-restart in console mode
52+
respawn_delay=2.0
53+
)
54+
55+
return LaunchDescription([
56+
mode_arg,
57+
voice_agent_process,
58+
])
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Launch file for Coffee Voice Agent - Complete System Mode
4+
5+
This launch file runs both the LiveKit voice agent script and the ROS2 bridge node
6+
together for a complete production system. The voice agent runs in 'start' mode
7+
(production) and the bridge provides ROS2 integration.
8+
9+
Usage:
10+
ros2 launch coffee_voice_agent voice_agent_system.launch.py
11+
12+
# With custom parameters:
13+
ros2 launch coffee_voice_agent voice_agent_system.launch.py \
14+
voice_agent_mode:=dev \
15+
voice_agent_port:=8080 \
16+
bridge_reconnect_interval:=3.0
17+
"""
18+
19+
import os
20+
from launch import LaunchDescription
21+
from launch.actions import ExecuteProcess, DeclareLaunchArgument, TimerAction
22+
from launch.substitutions import LaunchConfiguration
23+
from launch_ros.actions import Node
24+
from launch_ros.substitutions import FindPackageShare
25+
26+
27+
def generate_launch_description():
28+
"""Generate launch description for complete system"""
29+
30+
# Declare launch arguments
31+
voice_agent_mode_arg = DeclareLaunchArgument(
32+
'voice_agent_mode',
33+
default_value='start',
34+
description='Voice agent mode: console, dev, or start (production)'
35+
)
36+
37+
voice_agent_port_arg = DeclareLaunchArgument(
38+
'voice_agent_port',
39+
default_value='8080',
40+
description='WebSocket port for voice agent server'
41+
)
42+
43+
bridge_reconnect_interval_arg = DeclareLaunchArgument(
44+
'bridge_reconnect_interval',
45+
default_value='5.0',
46+
description='Bridge reconnection interval in seconds'
47+
)
48+
49+
voice_agent_host_arg = DeclareLaunchArgument(
50+
'voice_agent_host',
51+
default_value='localhost',
52+
description='Host address of the voice agent (for bridge connection)'
53+
)
54+
55+
# Get package share directory
56+
package_share = FindPackageShare('coffee_voice_agent')
57+
58+
# Path to the voice agent script
59+
script_path = os.path.join(package_share.find('coffee_voice_agent'), 'scripts', 'livekit_voice_agent.py')
60+
61+
# Create the voice agent process
62+
voice_agent_process = ExecuteProcess(
63+
cmd=[
64+
'python3',
65+
script_path,
66+
LaunchConfiguration('voice_agent_mode')
67+
],
68+
output='screen',
69+
name='livekit_voice_agent',
70+
emulate_tty=True,
71+
shell=False,
72+
respawn=True, # Auto-restart in production mode
73+
respawn_delay=5.0,
74+
# Set environment variables for the voice agent
75+
additional_env={
76+
'WEBSOCKET_PORT': LaunchConfiguration('voice_agent_port'),
77+
'WEBSOCKET_HOST': LaunchConfiguration('voice_agent_host'),
78+
}
79+
)
80+
81+
# Create the bridge node (with delay to let voice agent start first)
82+
bridge_node = TimerAction(
83+
period=3.0, # Wait 3 seconds for voice agent to start
84+
actions=[
85+
Node(
86+
package='coffee_voice_agent',
87+
executable='voice_agent_bridge',
88+
name='voice_agent_bridge',
89+
output='screen',
90+
emulate_tty=True,
91+
parameters=[{
92+
'voice_agent_host': LaunchConfiguration('voice_agent_host'),
93+
'voice_agent_port': LaunchConfiguration('voice_agent_port'),
94+
'reconnect_interval': LaunchConfiguration('bridge_reconnect_interval'),
95+
}],
96+
respawn=True,
97+
respawn_delay=2.0
98+
)
99+
]
100+
)
101+
102+
return LaunchDescription([
103+
voice_agent_mode_arg,
104+
voice_agent_port_arg,
105+
bridge_reconnect_interval_arg,
106+
voice_agent_host_arg,
107+
voice_agent_process,
108+
bridge_node,
109+
])

0 commit comments

Comments
 (0)