コード例 #1
0
ファイル: programs.py プロジェクト: mwhagedorn/basaGC
 def execute(self):
     super(Program40, self).execute()
     # if TIG < 2 mins away, abort burn
     if utils.seconds_to_time(self.burn.time_until_ignition)["minutes"] < 2:
         gc.remove_burn(gc.next_burn)
         gc.poodoo_abort(226)
         return
     # if time to ignition if further than a hour away, display time to ignition
     if utils.seconds_to_time(self.burn.time_until_ignition)["hours"] > 0:
         utils.log("TIG > 1 hour away")
         gc.execute_verb(verb="16", noun="33")
         gc.main_loop_table.append(self._ten_minute_monitor)
     else:
         utils.log("TIG < 1 hour away, enabling burn")
         self.burn.execute()
コード例 #2
0
ファイル: programs.py プロジェクト: mwhagedorn/basaGC
 def recalculate_phase_angles(self):
 
     """ This function is to be placed in the GC main loop to recalculate maneuver parameters.
     :return: nothing
     """
 
     # update current phase angle
     telemachus_body_id = config.TELEMACHUS_BODY_IDS[config.OCTAL_BODY_NAMES[self.target_name]]
     current_phase_angle = get_telemetry("body_phaseAngle",
                                         body_number=telemachus_body_id)
 
     # recalculate phase angle difference
     phase_angle_difference = current_phase_angle - self.phase_angle_required
     if phase_angle_difference < 0:
         phase_angle_difference = 180 + abs(phase_angle_difference)
     self.delta_time_to_burn = phase_angle_difference / ((360 / self.orbital_period) - (360 /
                                                                                 self.departure_body_orbital_period))
     delta_time = utils.seconds_to_time(self.delta_time_to_burn)
     velocity_at_cutoff = get_telemetry("orbitalVelocity") + self.delta_v_first_burn
コード例 #3
0
ファイル: programs.py プロジェクト: mwhagedorn/basaGC
 def _ten_minute_monitor(self):
     if utils.seconds_to_time(self.burn.time_until_ignition)["minutes"] < 10:
         gc.main_loop_table.remove(self._ten_minute_monitor)
         self.burn.execute()
コード例 #4
0
ファイル: programs.py プロジェクト: mwhagedorn/basaGC
    def calculate_maneuver(self):

        """ Calculates the maneuver parameters and creates a Burn object
        :return: Nothing
        """

        # load target
        telemachus_target_id = config.TELEMACHUS_BODY_IDS[self.target_name]
        target_apoapsis = float(get_telemetry("body_ApA", body_number=telemachus_target_id))

        # set destination altitude
        self.destination_altitude = target_apoapsis + 500000
        # if target == "Mun":
        #     self.destination_altitude = 12750000

        # obtain parameters to calculate burn
        self.departure_altitude = get_telemetry("altitude")
        self.orbital_period = get_telemetry("period")
        self.departure_body_orbital_period = get_telemetry("body_period", body_number=config.TELEMACHUS_BODY_IDS[
            "Kerbin"])
        self.grav_param = get_telemetry("body_gravParameter", body_number=config.TELEMACHUS_BODY_IDS[
            self.orbiting_body])
        current_phase_angle = get_telemetry("body_phaseAngle", body_number=telemachus_target_id)

        # calculate the first and second burn Δv parameters
        self.delta_v_first_burn, gc.moi_burn_delta_v = hohmann_transfer.delta_v(self.departure_altitude,
                                                                                self.destination_altitude)
        print(gc.moi_burn_delta_v)

        # calculate the time to complete the Hohmann transfer
        self.time_to_transfer = hohmann_transfer.time_to_transfer(self.departure_altitude, self.destination_altitude,
                                                                  self.grav_param)

        # calculate the correct phase angle for the start of the burn
        # note that the burn impulse is calculated as a instantaneous burn, to be correct the burn should be halfway
        # complete at this calculated time

        self.phase_angle_required = hohmann_transfer.phase_angle(self.departure_altitude, self.destination_altitude,
                                                                 self.grav_param)

        # calculate the current difference in phase angle required and current phase angle
        self.phase_angle_difference = current_phase_angle - self.phase_angle_required
        # if self.phase_angle_difference < 0:
        #     self.phase_angle_difference = 180 + abs(self.phase_angle_difference)

        # calculate time of ignition (TIG)
        self.delta_time_to_burn = self.phase_angle_difference / ((360 / self.orbital_period) -
                                                                 (360 / self.departure_body_orbital_period))

        # if the time of ignition is less than 120 seconds in the future, schedule the burn for next orbit
        if self.delta_time_to_burn <= 120:
            utils.log("Time of ignition less that 2 minutes in the future, starting burn during next orbit")
            self.delta_time_to_burn += get_telemetry("period")

        # convert the raw value in seconds to HMS
        delta_time = utils.seconds_to_time(self.delta_time_to_burn)

        # log the maneuver calculations
        utils.log("P15 calculations:")
        utils.log("Phase angle required: {}, Δv for burn: {} m/s, time to transfer: {}".format(
            round(self.phase_angle_required, 2),
            int(self.delta_v_first_burn),
            utils.seconds_to_time(self.time_to_transfer)))
        utils.log("Current Phase Angle: {}, difference: {}".format(
            current_phase_angle,
            self.phase_angle_difference))
        utils.log("Time to burn: {} hours, {} minutes, {} seconds".format(
            int(delta_time["hours"]),
            int(delta_time["minutes"]),
            delta_time["seconds"]))

        # calculate the Δt from now of TIG for both burns
        self.time_of_ignition_first_burn = get_telemetry("missionTime") + self.delta_time_to_burn

        # create a Burn object for the outbound burn
        self.first_burn = Burn(delta_v=self.delta_v_first_burn,
                               direction="prograde",
                               time_of_ignition=self.time_of_ignition_first_burn,
                               calling_program=self)


        # load the Burn object into computer
        gc.add_burn_to_queue(self.first_burn, execute=False)

        # display burn parameters and go to poo
        gc.execute_verb(verb="06", noun="95")
        gc.go_to_poo()