diff --git a/waypoint_nav/scripts/tandem_run_manager.py b/waypoint_nav/scripts/tandem_run_manager.py index b1c39f9..4b10af0 100755 --- a/waypoint_nav/scripts/tandem_run_manager.py +++ b/waypoint_nav/scripts/tandem_run_manager.py @@ -37,7 +37,7 @@ self.costmap_client1 = dynamic_reconfigure.client.Client("/move_base/global_costmap/obstacle_layer1") self.costmap_client2 = dynamic_reconfigure.client.Client("/move_base/global_costmap/obstacle_layer2") ## Variable - self.front_angle = 40 # degree + self.front_angle = 20 # degree self.danger_dist = 1.0 # meter self.waypoint_num = 0 self.front_range = None @@ -49,16 +49,28 @@ ## Subscribe current waypoint number def waypoint_num_callback(self, msg): if (self.no_tandem_area) or (msg.data == self.waypoint_num) or (self.stop): return + if (self.waypoint_num == 0) and (msg.data > 1): + for i in range(0, len(self.tandem_start_list)): + if (msg.data >= self.tandem_end_list[i]): + self.tandem_id += 1 + continue + if (msg.data >= self.tandem_start_list[i]) and (msg.data < self.tandem_end_list[i]): + self.tandem_id = i + self.in_tandem_area = True + self.update_costmap_config(False) + rospy.loginfo("Enter tandem area.") + break + self.waypoint_num = msg.data + return + if (msg.data == self.tandem_start_list[self.tandem_id]): self.in_tandem_area = True - self.costmap_client1.update_configuration({"enabled": False}) - self.costmap_client2.update_configuration({"enabled": False}) + self.update_costmap_config(False) rospy.loginfo("Enter tandem area.") elif (msg.data == self.tandem_end_list[self.tandem_id]): self.in_tandem_area = False - self.costmap_client1.update_configuration({"enabled": True}) - self.costmap_client2.update_configuration({"enabled": True}) + self.update_costmap_config(True) self.tandem_id += 1 self.stop = (self.tandem_id >= len(self.tandem_start_list)) # if True, self.stop will never be False rospy.loginfo("Exit from tandem area.") @@ -97,7 +109,12 @@ except AttributeError: pass return - + + + def update_costmap_config(self, enable: bool): + self.costmap_client1.update_configuration({"enabled": enable}) + self.costmap_client2.update_configuration({"enabled": enable}) + return