def _thrust_monitor(self): # recalculate accumulated delta-v so far self.accumulated_delta_v = self._calculate_accumulated_delta_v() current_velocity = get_telemetry("orbitalVelocity") #print("Accumulated dV: {:.2f}".format(self.accumulated_delta_v)) #print("dV required: {:.2f}".format(self.delta_v_required)) #print("Velocity at start: {:.2f}".format(self.initial_speed)) #print("Current Velocity: {:.2f}".format(current_velocity)) #print("Expected dV at cutoff: {}".format(self.velocity_at_cutoff)) if current_velocity > (self.velocity_at_cutoff - 13.5) and not self._is_thrust_reduced: utils.log("Throttling back to 10%", log_level="DEBUG") telemachus.set_throttle(10) self._is_thrust_reduced = True telemachus.disable_smartass() telemachus.send_command_to_ksp("command=f.sas") if current_velocity > (self.velocity_at_cutoff - 3.5): # the 3.5 a hack otherwise it overshoots, FIXME! telemachus.cut_throttle() utils.log("Closing throttle, burn complete!", log_level="DEBUG") computer.dsky.current_verb.terminate() computer.execute_verb(verb="06", noun="14") computer.main_loop_table.remove(self._thrust_monitor) #computer.burn_complete() self.terminate() computer.go_to_poo()
def _begin_burn(self): self.initial_speed = get_telemetry("orbitalVelocity") self.velocity_at_cutoff = self._calculate_velocity_at_cutoff() # start thrusting # set actual TIG #self.actual_time_of_ignition = get_telemetry("universalTime") #self.time_of_cutoff = self.actual_time_of_ignition + self.burn_duration telemachus.set_throttle(100) computer.main_loop_table.append(self._thrust_monitor)