6 from rclpy.node
import Node
7 from rclpy.clock
import Clock
8 from sensor_msgs.msg
import Image
14 """ Global image descriptor matching for loop closure detection """
17 """Initialization and parameter parsing"""
18 super().
__init__(
'loop_closure_detection')
20 self.declare_parameters(
22 parameters=[(
'frontend.similarity_threshold', 0.9),
23 (
'frontend.global_descriptor_technique',
'cosplace'),
24 (
'frontend.netvlad.pca_checkpoint',
''), (
'frontend.nn_checkpoint',
'models/resnet18_64.pth'),
25 (
'robot_id', 0), (
'max_nb_robots', 10),
26 (
'frontend.inter_robot_loop_closure_budget', 5),
27 (
'frontend.inter_robot_detection_period_sec', 5),
28 (
'frontend.nb_best_matches', 10), (
'frontend.image_crop_size', 376),
29 (
'frontend.intra_loop_min_inbetween_keyframes', 10),
30 (
'neighbor_management.max_heartbeat_delay_sec', 5.0),
31 (
'neighbor_management.init_delay_sec', 5.0),
32 (
'neighbor_management.heartbeat_period_sec', 0.5),
33 (
'frontend.detection_publication_period_sec', 1.0),
34 (
'frontend.detection_publication_max_elems_per_msg',
35 10), (
'neighbor_management.enable_neighbor_monitoring',
False),
36 (
'frontend.enable_intra_robot_loop_closures',
False),
37 (
'frontend.global_descriptors_topic',
"global_descriptors"),
38 (
'frontend.inter_robot_matches_topic',
"inter_robot_matches"),
39 (
'frontend.enable_sparsification',
True),
40 (
'frontend.use_vertex_cover_selection',
True),
41 (
'frontend.cosplace.descriptor_dim', 64),
42 (
'frontend.cosplace.backbone',
"resnet18"),
43 (
'frontend.sensor_type',
"stereo"),
44 (
'evaluation.enable_logs',
False),
45 (
'evaluation.enable_sparsification_comparison',
False),
48 self.
paramsparams[
'frontend.similarity_threshold'] = self.get_parameter(
49 'frontend.similarity_threshold').value
50 self.
paramsparams[
'frontend.intra_loop_min_inbetween_keyframes'] = self.get_parameter(
51 'frontend.intra_loop_min_inbetween_keyframes').value
52 self.
paramsparams[
'frontend.nb_best_matches'] = self.get_parameter(
53 'frontend.nb_best_matches').value
54 self.
paramsparams[
'frontend.global_descriptor_technique'] = self.get_parameter(
55 'frontend.global_descriptor_technique').value
56 self.
paramsparams[
'frontend.nn_checkpoint'] = self.get_parameter(
57 'frontend.nn_checkpoint').value
58 self.
paramsparams[
'robot_id'] = self.get_parameter(
'robot_id').value
59 self.
paramsparams[
'max_nb_robots'] = self.get_parameter(
'max_nb_robots').value
60 self.
paramsparams[
'frontend.inter_robot_loop_closure_budget'] = self.get_parameter(
61 'frontend.inter_robot_loop_closure_budget').value
62 self.
paramsparams[
'frontend.enable_intra_robot_loop_closures'] = self.get_parameter(
63 'frontend.enable_intra_robot_loop_closures').value
64 self.
paramsparams[
'frontend.inter_robot_detection_period_sec'] = self.get_parameter(
65 'frontend.inter_robot_detection_period_sec').value
66 self.
paramsparams[
"frontend.image_crop_size"] = self.get_parameter(
67 'frontend.image_crop_size').value
68 self.
paramsparams[
"frontend.enable_sparsification"] = self.get_parameter(
69 'frontend.enable_sparsification').value
70 self.
paramsparams[
"neighbor_management.enable_neighbor_monitoring"] = self.get_parameter(
71 'neighbor_management.enable_neighbor_monitoring').value
72 self.
paramsparams[
"neighbor_management.max_heartbeat_delay_sec"] = self.get_parameter(
73 'neighbor_management.max_heartbeat_delay_sec').value
74 self.
paramsparams[
"neighbor_management.init_delay_sec"] = self.get_parameter(
75 'neighbor_management.init_delay_sec').value
76 self.
paramsparams[
"neighbor_management.heartbeat_period_sec"] = self.get_parameter(
77 'neighbor_management.heartbeat_period_sec').value
79 "frontend.detection_publication_period_sec"] = self.get_parameter(
80 'frontend.detection_publication_period_sec').value
82 "frontend.detection_publication_max_elems_per_msg"] = self.get_parameter(
83 'frontend.detection_publication_max_elems_per_msg').value
84 self.
paramsparams[
"frontend.use_vertex_cover_selection"] = self.get_parameter(
85 'frontend.use_vertex_cover_selection').value
86 self.
paramsparams[
"frontend.cosplace.descriptor_dim"] = self.get_parameter(
87 'frontend.cosplace.descriptor_dim').value
88 self.
paramsparams[
"frontend.cosplace.backbone"] = self.get_parameter(
89 'frontend.cosplace.backbone').value
90 self.
paramsparams[
"frontend.sensor_type"] = self.get_parameter(
91 'frontend.sensor_type').value.lower()
92 self.
paramsparams[
"evaluation.enable_logs"] = self.get_parameter(
93 'evaluation.enable_logs').value
94 self.
paramsparams[
"evaluation.enable_sparsification_comparison"] = self.get_parameter(
95 'evaluation.enable_sparsification_comparison').value
100 self.
paramsparams[
'frontend.inter_robot_detection_period_sec'],
101 self.
glcdglcd.detect_inter, clock=Clock())
104 if __name__ ==
'__main__':
106 rclpy.init(args=
None)
108 lcd.get_logger().info(
'Initialization done.')
inter_robot_detection_timer