Jump to content

[UNSOLVED] Python-Script not working


HCF

Recommended Posts

Hi guys,

for a school project wanted to to some BFS style landings and tried krpc with Infernal Robotics and a python script to build it. Unfortunatly, my script is not working at all.

I can run it and krpc get a popup that a scripts want to connect, but if I run it it says "RESTART" and thats all. As if it never get over the initial connection with krpc. Can somebody please help me?

My setup:

  • KSP-Version: Steam, 1.4.2
  • CKAN 1.25.4
  • Kronal Vessel Viewer 0.0.9.6 with Click Through Block 0.1.6.7 and Toolbar Controller 0.1.6.16 (installed with CKAN)
  • KRPC 0.4.8
  • Kerbal Engineer Redux 1.1.4.10
  • Infernal Robotics - Next 3.0.0.0 beta3 for KSP 1.4.2

 

# Import benötigter Module  
import krpc  
  
# Aufbau der Verbindung zu KRPC und Auswahl der aktiven Raumfähre  
verbindung = krpc.connect(name='Alpha ')  
faehre = verbindung.space_center.active_vessel  
  
# Anlegen von Variablen um die Servos zur Steuerung ansprechen zu können  
lb = verbindung.infernal_robotics.servo_with_name(faehre,"LinkerBug")  
rb = verbindung.infernal_robotics.servo_with_name(faehre,"RechterBug")  
lh = verbindung.infernal_robotics.servo_with_name(faehre,"LinkesHeck")  
rh = verbindung.infernal_robotics.servo_with_name(faehre,"RechtesHeck")  
  
# Ausgabe der aktuellen Position der Servos  
print lb.name + " " + str(lb.position)  
print rb.name + " " + str(rb.position)  
print lh.name + " " + str(lh.position)  
print rh.name + " " + str(rh.position)  
  
# Anlegen von Variablen für die Servopositionen, setzten auf 0  
lbp = 0  
rbp = 0  
lhp = 0  
rhp = 0  
  
# Überprüfen ob die Bremse aktiviert wurde  
# Wurde die Bremse aktiviert, 
# wird der 'Servo-Modus' gestartet, der erlaubt, über die 
# Spielsteuerung die Seitenleitwerke mithilfe der Servos zu kontrollieren  
bremse = vessel.control.brakes  
servoModus = False  
while(1):  
    if vessel.control.brakes:  
        if bremse != vessel.control.brakes:  
            rhp = -45  
            lhp = 45  
            rbp = -45  
            lbp = -45  
            rh.move_to(rhp,5)  
            lh.move_to(lhp,5)  
            rb.move_to(rbp,5)  
            lb.move_to(lbp,5)  
  
            bremse = vessel.control.brakes  
            servoModus = True  
  
    else:  
        if bremse != vessel.control.brakes:  
            rh.move_to(0,5)  
            lh.move_to(0,5)  
            rb.move_to(0,5)  
            lb.move_to(0,5)  
  
            bremse = vessel.control.brakes  
            servoModus = False  
  
# Bewegungen entlang der Roll-Nick-Gier-Winkel  
    if servoModus:  
        neigen = vessel.control.up  
        bewegung = False  
        if(neigen != 0):  
            bewegung = True  
            if(neigen < 0):  
                lbp = lbp + 0.5  
                rbp = rbp - 0.5  
                lhp = lhp - 0.5  
                rhp = rhp - 0.5  
            if(neigen > 0):  
                lbp = lbp - 0.5  
                rbp = rbp + 0.5  
                lhp = lhp + 0.5  
                rhp = rhp + 0.5  
          
        gieren = vessel.control.right  
        if(gieren != 0):  
            bewegung = True  
            if(gieren > 0):  
                lbp = lbp + 0.1  
                rbp = rbp + 0.1  
                lhp = lhp - 0.1  
                rhp = rhp + 0.1  
            if(gieren > 0):  
                lbp = lbp - 0.5  
                rbp = rbp - 0.5  
                lhp = lhp + 0.5  
                rhp = rhp - 0.5  
  
        rollen = vessel.control.forward  
        if(rollen != 0):  
            bewegung = True  
            if(rollen > 0):  
                lbp = -45  
                rbp = -45  
                lhp = 45  
                rhp = -45  
                if(rollen < 0):  
                    lbp = 0  
                    rbp = 0  
                    lhp = 0  
                    rhp = 0  
      
            if bewegung:  
                rh.move_to(rhp,1)  
                lh.move_to(lhp,1)  
                rb.move_to(rbp,1)  
                lb.move_to(lbp,1)

Thank you!

HCF

Edited by HCF
Adding setup
Link to comment
Share on other sites

9 minutes ago, FleshJeb said:

Your KRPC version may not be compatible with KSP 1.4.2.

0.4.8 has this in its .version file:

{
  "NAME": "kRPC",
  "URL": "http://ksp-avc.cybutek.net/version.php?id=254",
  "DOWNLOAD": "https://github.com/krpc/krpc/releases/latest",
  "VERSION": { "MAJOR": 0, "MINOR": 4, "PATCH": 8 },
  "KSP_VERSION": { "MAJOR": 1, "MINOR": 5, "PATCH": 1 },
  "KSP_VERSION_MAX": { "MAJOR": 1, "MINOR": 5, "PATCH": 1 },
  "KSP_VERSION_MIN": { "MAJOR": 1, "MINOR": 2, "PATCH": 2 }
}

Should be fine for 1.4.2 if that's accurate.

Link to comment
Share on other sites

9 hours ago, HebaruSan said:

0.4.8 has this in its .version file:


{
  "NAME": "kRPC",
  "URL": "http://ksp-avc.cybutek.net/version.php?id=254",
  "DOWNLOAD": "https://github.com/krpc/krpc/releases/latest",
  "VERSION": { "MAJOR": 0, "MINOR": 4, "PATCH": 8 },
  "KSP_VERSION": { "MAJOR": 1, "MINOR": 5, "PATCH": 1 },
  "KSP_VERSION_MAX": { "MAJOR": 1, "MINOR": 5, "PATCH": 1 },
  "KSP_VERSION_MIN": { "MAJOR": 1, "MINOR": 2, "PATCH": 2 }
}

Should be fine for 1.4.2 if that's accurate.

 

9 hours ago, FleshJeb said:

Your KRPC version may not be compatible with KSP 1.4.2. You can try posting your issue here:

Or, try using KRPC 0.4.5 or 0.4.6 instead:  https://github.com/krpc/krpc/releases

I will try a different version of krpc on the weekend and see, if that solves my problem. Furthermore, I will reinstall all mods and see if that fixes something. Thank you!

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...