2 from cslam_common_interfaces.msg
import RobotIdsAndOrigin
3 from std_msgs.msg
import String
9 """Manage neighbors to keep track of which other robots are in communication range
20 self.
nodenode, rid, self.
21 params[
'neighbor_management.enable_neighbor_monitoring'],
22 self.
paramsparams[
'neighbor_management.init_delay_sec'],
23 self.
paramsparams[
'neighbor_management.max_heartbeat_delay_sec'])
26 String,
'cslam/get_current_neighbors',
29 RobotIdsAndOrigin,
'cslam/current_neighbors', 100)
32 """Check which neighbors are in range
35 is_robot_in_range = {}
36 robots_in_range_list = []
39 is_robot_in_range[i] =
True
40 robots_in_range_list.append(i)
42 is_robot_in_range[i] =
True
43 robots_in_range_list.append(i)
45 is_robot_in_range[i] =
False
46 return is_robot_in_range, robots_in_range_list
49 """This method check if the local robot (that runs this node), is the
50 default broker based on its current neighbors.
53 bool: is the local robot the default broker
54 among the robots in range
67 """This function finds the range of descriptors to send
68 so that we do not loose info
71 from_kf_id = latest_local_id
83 i].last_keyframe_sent = latest_local_id
88 """This function finds the range of matches to send
89 so that we do not loose info
92 from_match_id = latest_local_match_idx
104 i].last_match_sent = latest_local_match_idx
106 return from_match_id + 1
109 """Determines which descriptors are not useless and can be deleted
112 last_kf_id (int): last keyframe id in the list of descriptors
114 int: the id of the first descriptor that is not useless
116 from_kf_id = last_kf_id
124 """Determines which matches are not useless and can be deleted
127 last_match_id (int): last match id in the list of matches
129 int: the id of the first match that is not useless
131 from_match_id = last_match_id
139 """Keep monitors up to date with received keyframes
142 other_robot_id (int): other robot id
143 kf_id (int): keyframe id
145 self.
neighbors_monitorsneighbors_monitors[other_robot_id].last_keyframe_received = kf_id
151 descriptors (list): list of descriptors with ids info
154 range: indexes in list to process
156 other_robot_id = descriptors[0].robot_id
157 kf_ids = [d.keyframe_id
for d
in descriptors]
158 last_id = max(kf_ids)
161 i
for i
in range(len(descriptors))
if descriptors[i].keyframe_id >
169 return list_index_range
172 """Publish the current neighbors in range
179 robots_in_range_list.remove(self.
robot_idrobot_id)
180 msg = RobotIdsAndOrigin()
181 msg.robots.ids = robots_in_range_list
182 for i
in robots_in_range_list:
def __init__(self, node, params)
def get_unknown_range(self, descriptors)
def check_neighbors_in_range(self)
def select_from_which_kf_to_send(self, latest_local_id)
def useless_matches(self, last_match_id)
def local_robot_is_broker(self)
def update_received_kf_id(self, other_robot_id, kf_id)
def useless_descriptors(self, last_kf_id)
def select_from_which_match_to_send(self, latest_local_match_idx)
def get_current_neighbors_callback(self, msg)