-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkenning-instance-segmentation.py
More file actions
121 lines (106 loc) · 3.55 KB
/
kenning-instance-segmentation.py
File metadata and controls
121 lines (106 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright (c) 2025 Antmicro <www.antmicro.com>
#
# SPDX-License-Identifier: Apache-2.0
import os
import launch
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode
from launch.actions import DeclareLaunchArgument
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
from launch.actions import ExecuteProcess
from launch.actions import SetEnvironmentVariable
def generate_launch_description():
cuda_mps_pipe = os.getenv("CUDA_MPS_PIPE_DIRECTORY", "/tmp/nvidia-mps")
cuda_mps_logs = os.getenv("CUDA_MPS_LOG_DIRECTORY", "/tmp/mps-logs")
camera_path = DeclareLaunchArgument(
"camera_path",
default_value="/dev/video0",
description="Path to camera device"
)
use_gui = LaunchConfiguration('use_gui')
start_nvidia_mps = LaunchConfiguration('start_nvidia_mps')
use_gui_arg = DeclareLaunchArgument(
"use_gui",
default_value="False",
description="Set to true if you want to use GUI"
)
start_nvidia_mps_arg = DeclareLaunchArgument(
"start_nvidia_mps",
default_value="False",
description="Set to true to start nvidia-cuda-mps-control"
)
camera_node_container = ComposableNodeContainer(
name='camera_node_container',
namespace='camera_node',
package='rclcpp_components',
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='camera_node',
plugin='camera_node::CameraNode',
name='camera_node',
parameters=[
{'camera_path': LaunchConfiguration("camera_path")}
]
),
],
output='both',
)
gui_node = ComposableNodeContainer(
name='gui_container',
namespace='',
package='rclcpp_components',
executable='component_container',
composable_node_descriptions=[
ComposableNode(
package='gui_node',
plugin='gui_node::KenningYolactGuiComponent',
name='sample_gui_node')
],
output='both',
on_exit=launch.actions.Shutdown(),
condition=IfCondition(use_gui)
)
kenning_node = Node(
name="kenning_node",
executable="kenning",
arguments=["ros","flow","--verbosity","DEBUG"],
parameters=[{
"config_file":"./src/gui_node/examples/kenning-instance-segmentation/kenning-instance-segmentation.yaml"
}],
on_exit=launch.actions.Shutdown()
)
nvidia_mps_node = ExecuteProcess(
name="cuda_mps_node",
cmd=["nvidia-cuda-mps-control", "-f"],
additional_env={
"CUDA_MPS_PIPE_DIRECTORY": cuda_mps_pipe,
"CUDA_MPS_LOG_DIRECTORY": cuda_mps_logs,
},
output='both',
on_exit=launch.actions.Shutdown(),
condition=IfCondition(start_nvidia_mps)
)
mps_pipe_env = SetEnvironmentVariable(
"CUDA_MPS_PIPE_DIRECTORY",
cuda_mps_pipe,
condition=IfCondition(start_nvidia_mps)
)
mps_logs_env = SetEnvironmentVariable(
"CUDA_MPS_LOG_DIRECTORY",
cuda_mps_logs,
condition=IfCondition(start_nvidia_mps)
)
return launch.LaunchDescription([
start_nvidia_mps_arg,
mps_pipe_env,
mps_logs_env,
nvidia_mps_node,
use_gui_arg,
camera_path,
camera_node_container,
gui_node,
kenning_node,
])