Rescue mission almost done docking part behaves weirdly)
This commit is contained in:
36
maneuvers/grapple.py
Normal file
36
maneuvers/grapple.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from time import sleep
|
||||
|
||||
from . import Maneuver
|
||||
from .utils import magnitude, correct_course_to_target, rcs_push, point_toward_target
|
||||
|
||||
|
||||
class GrappleManeuver(Maneuver):
|
||||
def __init__(self, conn, mission_control, target):
|
||||
super().__init__(conn, mission_control)
|
||||
self.target = target
|
||||
|
||||
def start(self):
|
||||
vessel = self.mission_control.vessel
|
||||
vessel.parts.controlling = self.mission_control.get_grappling()
|
||||
|
||||
point_toward_target(self.conn, vessel, self.target)
|
||||
|
||||
self.mission_control.toggle_grappling(True)
|
||||
rcs_push(vessel, {"y": 1}, .75)
|
||||
|
||||
vessel.control.rcs = True
|
||||
try:
|
||||
while magnitude(vessel.position(self.target.reference_frame)) > 0:
|
||||
print(magnitude(vessel.position(self.target.reference_frame)))
|
||||
sa = self.conn.mech_jeb.smart_ass
|
||||
sa.autopilot_mode = self.conn.mech_jeb.SmartASSAutopilotMode.relative_plus
|
||||
sa.update(False)
|
||||
correct_course_to_target(vessel, self.target)
|
||||
|
||||
except ValueError:
|
||||
vessel = self.conn.space_center.active_vessel
|
||||
self.mission_control.vessel = vessel
|
||||
finally:
|
||||
vessel.control.rcs = False
|
||||
|
||||
return True
|
||||
Reference in New Issue
Block a user