-
Notifications
You must be signed in to change notification settings - Fork 674
/
Copy pathsubscribe.launch.py
114 lines (108 loc) · 4 KB
/
subscribe.launch.py
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
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, LogInfo, OpaqueFunction
from launch.conditions import IfCondition
from launch.substitutions import LaunchConfiguration, TextSubstitution
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory, get_package_prefix
import os
import sys
launch_args = [
DeclareLaunchArgument(name="namespace", default_value="", description="namespace"),
DeclareLaunchArgument(
name="ov_enable", default_value="true", description="enable OpenVINS node"
),
DeclareLaunchArgument(
name="rviz_enable", default_value="true", description="enable rviz node"
),
DeclareLaunchArgument(
name="config",
default_value="euroc_mav",
description="euroc_mav, tum_vi, rpng_aruco...",
),
DeclareLaunchArgument(
name="config_path",
default_value="",
description="path to estimator_config.yaml. If not given, determined based on provided 'config' above",
),
DeclareLaunchArgument(
name="verbosity",
default_value="INFO",
description="ALL, DEBUG, INFO, WARNING, ERROR, SILENT",
),
DeclareLaunchArgument(
name="use_stereo",
default_value="true",
description="if we have more than 1 camera, if we should try to track stereo constraints between pairs",
),
DeclareLaunchArgument(
name="max_cameras",
default_value="2",
description="how many cameras we have 1 = mono, 2 = stereo, >2 = binocular (all mono tracking)",
),
DeclareLaunchArgument(
name="save_total_state",
default_value="false",
description="record the total state with calibration and features to a txt file",
)
]
def launch_setup(context):
config_path = LaunchConfiguration("config_path").perform(context)
if not config_path:
configs_dir = os.path.join(get_package_share_directory("ov_msckf"), "config")
available_configs = os.listdir(configs_dir)
config = LaunchConfiguration("config").perform(context)
if config in available_configs:
config_path = os.path.join(
get_package_share_directory("ov_msckf"),
"config",config,"estimator_config.yaml"
)
else:
return [
LogInfo(
msg="ERROR: unknown config: '{}' - Available configs are: {} - not starting OpenVINS".format(
config, ", ".join(available_configs)
)
)
]
else:
if not os.path.isfile(config_path):
return [
LogInfo(
msg="ERROR: config_path file: '{}' - does not exist. - not starting OpenVINS".format(
config_path)
)
]
node1 = Node(
package="ov_msckf",
executable="run_subscribe_msckf",
condition=IfCondition(LaunchConfiguration("ov_enable")),
namespace=LaunchConfiguration("namespace"),
output='screen',
parameters=[
{"verbosity": LaunchConfiguration("verbosity")},
{"use_stereo": LaunchConfiguration("use_stereo")},
{"max_cameras": LaunchConfiguration("max_cameras")},
{"save_total_state": LaunchConfiguration("save_total_state")},
{"config_path": config_path},
],
)
node2 = Node(
package="rviz2",
executable="rviz2",
condition=IfCondition(LaunchConfiguration("rviz_enable")),
arguments=[
"-d"
+ os.path.join(
get_package_share_directory("ov_msckf"), "launch", "display_ros2.rviz"
),
"--ros-args",
"--log-level",
"warn",
],
)
return [node1, node2]
def generate_launch_description():
opfunc = OpaqueFunction(function=launch_setup)
ld = LaunchDescription(launch_args)
ld.add_action(opfunc)
return ld