def update_localization(self, ego_vehicle):
        """
        Update current position, route completion and checkpoints according to current position.

        Args:
            ego_vehicle: a vehicle object

        Returns:
            None
        """
        position = ego_vehicle.position
        lane, lane_index = self._update_current_lane(ego_vehicle)
        long, _ = lane.local_coordinates(position)
        need_update = self._update_target_checkpoints(lane_index, long)
        assert len(self.checkpoints) >= 2

        # Update travelled_length for route completion
        long_in_ref_lane, _ = self.current_ref_lanes[0].local_coordinates(position)
        travelled = long_in_ref_lane - self._last_long_in_ref_lane
        self.travelled_length += travelled
        self._last_long_in_ref_lane = long_in_ref_lane
        # print(f"{self.travelled_length=}, {travelled=}, {long_in_ref_lane=}, "
        #       f"{self.route_completion=}, {self._last_long_in_ref_lane=}")

        # target_road_1 is the road segment the vehicle is driving on.
        if need_update:
            target_road_1_start = self.checkpoints[self._target_checkpoints_index[0]]
            target_road_1_end = self.checkpoints[self._target_checkpoints_index[0] + 1]
            target_lanes_1 = self.map.road_network.graph[target_road_1_start][target_road_1_end]
            self.current_ref_lanes = target_lanes_1
            self.current_road = Road(target_road_1_start, target_road_1_end)

            self._last_long_in_ref_lane = self.current_ref_lanes[0].local_coordinates(position)[0]

            # target_road_2 is next road segment the vehicle should drive on.
            target_road_2_start = self.checkpoints[self._target_checkpoints_index[1]]
            target_road_2_end = self.checkpoints[self._target_checkpoints_index[1] + 1]
            target_lanes_2 = self.map.road_network.graph[target_road_2_start][target_road_2_end]

            if target_road_1_start == target_road_2_start:
                # When we are in the final road segment that there is no further road to drive on
                self.next_road = None
                self.next_ref_lanes = None
            else:
                self.next_road = Road(target_road_2_start, target_road_2_end)
                self.next_ref_lanes = target_lanes_2

        self._navi_info.fill(0.0)
        half = self.CHECK_POINT_INFO_DIM
        # Put the next checkpoint's information into the first half of the navi_info
        self._navi_info[:half], lanes_heading1, next_checkpoint = self._get_info_for_checkpoint(
            lanes_id=0, ref_lane=self.current_ref_lanes[0], ego_vehicle=ego_vehicle
        )

        # Put the next of the next checkpoint's information into the first half of the navi_info
        self._navi_info[half:], lanes_heading2, next_next_checkpoint = self._get_info_for_checkpoint(
            lanes_id=1,
            ref_lane=self.next_ref_lanes[0] if self.next_ref_lanes is not None else self.current_ref_lanes[0],
            ego_vehicle=ego_vehicle
        )

        self.navi_arrow_dir = [lanes_heading1, lanes_heading2]
        if self._show_navi_info:
            # Whether to visualize little boxes in the scene denoting the checkpoints
            pos_of_goal = next_checkpoint
            self._goal_node_path.setPos(panda_vector(pos_of_goal[0], pos_of_goal[1], self.MARK_HEIGHT))
            self._goal_node_path.setH(self._goal_node_path.getH() + 3)

            pos_of_goal = next_next_checkpoint
            self._goal_node_path2.setPos(panda_vector(pos_of_goal[0], pos_of_goal[1], self.MARK_HEIGHT))
            self._goal_node_path2.setH(self._goal_node_path2.getH() + 3)

            dest_pos = self._dest_node_path.getPos()
            self._draw_line_to_dest(start_position=ego_vehicle.position, end_position=(dest_pos[0], dest_pos[1]))
            navi_pos = self._goal_node_path.getPos()
            next_navi_pos = self._goal_node_path2.getPos()
            self._draw_line_to_navi(
                start_position=ego_vehicle.position,
                end_position=(navi_pos[0], navi_pos[1]),
                next_checkpoint=(next_navi_pos[0], next_navi_pos[1])
            )

        Update current position, route completion and checkpoints according to current position.

        Args:
            ego_vehicle: a vehicle object

        Returns:
            None
        
metadrive/component/navigation_module/node_network_navigation.py