Trying to reach a working mini model
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import math
|
||||
|
||||
from enum import Enum
|
||||
|
||||
from maneuver_scheduler import ManeuverScheduler
|
||||
|
||||
|
||||
class ManeuverAlarmType(Enum):
|
||||
ManeuverNode = 1,
|
||||
@@ -7,8 +11,9 @@ class ManeuverAlarmType(Enum):
|
||||
|
||||
|
||||
class Maneuver:
|
||||
def __init__(self, conn, vessel):
|
||||
self.vessel = vessel
|
||||
def __init__(self, conn, mission_control):
|
||||
self.mission_control = mission_control
|
||||
self.vessel = mission_control.vessel
|
||||
self.conn = conn
|
||||
|
||||
def plan_next_maneuver(self):
|
||||
@@ -18,8 +23,8 @@ class Maneuver:
|
||||
class NodeManeuver(Maneuver):
|
||||
alarm_type = ManeuverAlarmType.ManeuverNode
|
||||
|
||||
def __init__(self, conn, vessel):
|
||||
super().__init__(conn, vessel)
|
||||
def __init__(self, conn, mission_control):
|
||||
super().__init__(conn, mission_control)
|
||||
self.mech_jeb = conn.mech_jeb
|
||||
self.node_executor = self.mech_jeb.node_executor
|
||||
|
||||
@@ -42,9 +47,28 @@ class NodeManeuver(Maneuver):
|
||||
while enabled():
|
||||
enabled.wait()
|
||||
|
||||
def book_timeslot_for_node(self, node, maneuver, duration=None):
|
||||
if node.time_to < 0:
|
||||
node.remove()
|
||||
planning_duration = 60
|
||||
ut = ManeuverScheduler.next_free_timeslot(self.conn.space_center.ut + planning_duration, planning_duration)
|
||||
ManeuverScheduler.book_timeslot(ut, self.vessel, duration=planning_duration)
|
||||
|
||||
time_required = (node.delta_v * self.vessel.mass) / self.vessel.available_thrust
|
||||
duration = math.floor(2 * ManeuverScheduler.node_offsets + time_required)
|
||||
alarm_start = node.ut - (duration / 2 + ManeuverScheduler.node_offsets)
|
||||
|
||||
if ManeuverScheduler.timeslot_is_free(alarm_start, duration):
|
||||
ManeuverScheduler.book_timeslot_for_node(self.vessel, node, self, alarm_start=alarm_start, duration=duration)
|
||||
else:
|
||||
node.remove()
|
||||
planning_duration = 60
|
||||
ut = ManeuverScheduler.next_free_timeslot(alarm_start, planning_duration)
|
||||
ManeuverScheduler.book_timeslot(ut, self.vessel, duration=planning_duration)
|
||||
|
||||
|
||||
class MechJebManeuver(NodeManeuver):
|
||||
def __init__(self, conn, vessel):
|
||||
super().__init__(conn, vessel)
|
||||
def __init__(self, conn, mission_control):
|
||||
super().__init__(conn, mission_control)
|
||||
self.maneuver_planner = self.mech_jeb.maneuver_planner
|
||||
|
||||
|
||||
Reference in New Issue
Block a user