Infernal Robotics

Warning

The Infernal Robotics mod has been migrating to Infernal Robotics Next. kOS includes support for IR Next only, and no longer supports re-compiled versions of the original IR. The links to the original mod forum thread and downloads remain in this file for historical context and reference.

Infernal Robotics might not be installed on your copy of the game. Your script can test whether or not it’s installed by using the boolean expression addons:available("ir").

Warning

At the time of this writing, IR Next officially supports KSP 1.3.1 and 1.4.2 with the beta 3 patch 7 “pre-release”. The addon has been tested using this 1.4.2 zip file running on KSP 1.6.1 with no errors reported. While using this addon, please keep in mind that IR Next may have underlying issues due to KSP version mismatch, and that newer releases to IR Next may cause this addon to break in unexpected ways.

Infernal Robotics introduces robotics parts to the game, letting you create moving or spinning contraptions that just aren’t possible under stock KSP.

http://i.imgur.com/O94LBvF.png

Access structure IRAddon via ADDONS:IR.

structure IRAddon
Suffix Type Description
AVAILABLE boolean (readonly) Returns True if mod Infernal Robotics is installed, available to KOS and applicable to current craft. It is better to use addons:available("rt").
GROUPS List of IRControlGroup Lists all Servo Groups for the Vessel on which CPU runs this command (see details below).
ALLSERVOS List of IRServo Lists all Servos for the Vessel on which CPU runs this command (see details below).
PARTSERVOS(Part) List of IRServo Lists all Servos for the provided part
IRAddon:AVAILABLE
Type:Boolean
Access:Get only

It is better to first call ADDONS:AVAILABLE("IR") to find out if the plugin exists.

Returns True if mod Infernal Robotics is installed, available to KOS and applicable to current craft. Example of use:

if ADDONS:IR:AVAILABLE
{
    //some IR dependent code
}
IRAddon:GROUPS
Type:List of IRControlGroup objects
Access:Get only

Lists all Servo Groups for the Vessel on which the script is being executed. Example of use:

for g in ADDONS:IR:GROUPS
{
    Print g:NAME + " contains " + g:SERVOS:LENGTH + " servos".
}
IRAddon:ALLSERVOS
Type:List of IRServo objects
Access:Get only

Lists all Servos for the Vessel on which the script is being executed. Example of use:

for s in ADDONS:IR:ALLSERVOS
{
    print "Name: " + s:NAME + ", position: " + s:POSITION.
}
IRAddon:PARTSERVOS(part)
Parameters:
  • partPart for which to return servos
Return type:

List of IRServo objects

Lists all Servos found on the given Part.

structure IRControlGroup
Suffix Type Description
NAME string Name of the Control Group
SPEED scalar Speed multiplier set in the IR UI
EXPANDED Boolean True if Group is expanded in IR UI
FORWARDKEY string Key assigned to forward movement
REVERSEKEY string Key assigned to reverse movement
SERVOS List (readonly) List of servos in the group
VESSEL Vessel Vessel object, owning this servo group. Readonly.
MOVERIGHT() void Commands servos in the group to move in positive direction
MOVELEFT() void Commands servos in the group to move in negative direction
MOVECENTER() void Commands servos in the group to move to default position
MOVENEXTPRESET() void Commands servos in the group to move to next preset
MOVEPREVPRESET() void Commands servos in the group to move to previous preset
STOP() void Commands servos in the group to stop
IRControlGroup:NAME
Type:string
Access:Get/Set

Name of the Control Group (cannot be empty).

IRControlGroup:SPEED
Type:scalar
Access:Get/Set

Speed multiplier as set in the IR user interface. Avoid setting it to 0.

IRControlGroup:EXPANDED
Type:Boolean
Access:Get/Set

True if Group is expanded in IR UI

IRControlGroup:FORWARDKEY
Type:string
Access:Get/Set

Key assigned to forward movement. Can be empty.

IRControlGroup:REVERSEKEY
Type:string
Access:Get/Set

Key assigned to reverse movement. Can be empty.

IRControlGroup:SERVOS
Type:List of IRServo objects
Access:Get only

Lists Servos in the Group. Example of use:

for g in ADDONS:IR:GROUPS
{
    Print g:NAME + " contains " + g:SERVOS:LENGTH + " servos:".
    for s in g:servos
    {
        print "    " + s:NAME + ", position: " + s:POSITION.
    }
}
IRControlGroup:VESSEL
Type:Vessel
Access:Get only

Returns a Vessel that owns this ServoGroup

IRControlGroup:MOVERIGHT()
Returns:void

Commands servos in the group to move in positive direction.

IRControlGroup:MOVELEFT()
Returns:void

Commands servos in the group to move in negative direction.

IRControlGroup:MOVECENTER()
Returns:void

Commands servos in the group to move to default position.

IRControlGroup:MOVENEXTPRESET()
Returns:void

Commands servos in the group to move to next preset

IRControlGroup:MOVEPREVPRESET()
Returns:void

Commands servos in the group to move to previous preset

IRControlGroup:STOP()
Returns:void

Commands servos in the group to stop

structure IRServo
Suffix Type Description
NAME string Name of the Servo
UID scalar (int) Unique ID of the servo part (part.flightID).
HIGHLIGHT Boolean (set-only) Set Hightlight status of the part.
POSITION scalar (readonly) Current position of the servo.
MINCFGPOSITION scalar (readonly) Minimum position for servo as defined by part creator in part.cfg
MAXCFGPOSITION scalar (readonly) Maximum position for servo as defined by part creator in part.cfg
MINPOSITION scalar Minimum position for servo, from tweakable.
MAXPOSITION scalar Maximum position for servo, from tweakable.
CONFIGSPEED scalar (readonly) Servo movement speed as defined by part creator in part.cfg
SPEED scalar Servo speed multiplier, from tweakable.
CURRENTSPEED scalar (readonly) Current Servo speed.
ACCELERATION scalar Servo acceleration multiplier, from tweakable.
ISMOVING Boolean (readonly) True if Servo is moving
ISFREEMOVING Boolean (readonly) True if Servo is uncontrollable (ex. docking washer)
LOCKED Boolean Servo’s locked status, set true to lock servo.
INVERTED Boolean Servo’s inverted status, set true to invert servo’s axis.
PART Part A reference to a Part containing servo module.
MOVERIGHT() void Commands servo to move in positive direction
MOVELEFT() void Commands servo to move in negative direction
MOVECENTER() void Commands servo to move to default position
MOVENEXTPRESET() void Commands servo to move to next preset
MOVEPREVPRESET() void Commands servo to move to previous preset
STOP() void Commands servo to stop
MOVETO(position, speedMult) void Commands servo to move to position with speedMult multiplier
IRServo:NAME
Type:string
Access:Get/Set

Name of the Control Group (cannot be empty).

IRServo:UID
Type:scalar
Access:Get

Unique ID of the servo part (part.flightID).

IRServo:HIGHLIGHT
Type:Boolean
Access:Set

Set Hightlight status of the part.

IRServo:POSITION
Type:scalar
Access:Get

Current position of the servo.

IRServo:MINCFGPOSITION
Type:scalar
Access:Get

Minimum position for servo as defined by part creator in part.cfg

IRServo:MAXCFGPOSITION
Type:scalar
Access:Get

Maximum position for servo as defined by part creator in part.cfg

IRServo:MINPOSITION
Type:scalar
Access:Get/Set

Minimum position for servo, from tweakable.

IRServo:MAXPOSITION
Type:scalar
Access:Get/Set

Maximum position for servo, from tweakable.

IRServo:CONFIGSPEED
Type:scalar
Access:Get

Servo movement speed as defined by part creator in part.cfg

IRServo:SPEED
Type:scalar
Access:Get/Set

Servo speed multiplier, from tweakable.

IRServo:CURRENTSPEED
Type:scalar
Access:Get

Current Servo speed.

IRServo:ACCELERATION
Type:scalar
Access:Get/Set

Servo acceleration multiplier, from tweakable.

IRServo:ISMOVING
Type:Boolean
Access:Get

True if Servo is moving

IRServo:ISFREEMOVING
Type:Boolean
Access:Get

True if Servo is uncontrollable (ex. docking washer)

IRServo:LOCKED
Type:Boolean
Access:Get/Set

Servo’s locked status, set true to lock servo.

IRServo:INVERTED
Type:Boolean
Access:Get/Set

Servo’s inverted status, set true to invert servo’s axis.

IRServo:PART
Type:Part
Access:Get

Returns reference to the Part containing servo module. Please note that Part:UID does not equal IRServo:UID.

IRServo:MOVERIGHT()
Returns:void

Commands servo to move in positive direction

IRServo:MOVELEFT()
Returns:void

Commands servo to move in negative direction

IRServo:MOVECENTER()
Returns:void

Commands servo to move to default position

IRServo:MOVENEXTPRESET()
Returns:void

Commands servo to move to next preset

IRServo:MOVEPREVPRESET()
Returns:void

Commands servo to move to previous preset

IRServo:STOP()
Returns:void

Commands servo to stop

IRServo:MOVETO(position, speedMult)
Parameters:
  • position – (float) Position to move to
  • speedMult – (float) Speed multiplier
Returns:

void

Commands servo to move to position with speedMult multiplier.

Example code:

print "IR Iavailable: " + ADDONS:IR:AVAILABLE.

Print "Groups:".

for g in ADDONS:IR:GROUPS
{
    Print g:NAME + " contains " + g:SERVOS:LENGTH + " servos:".
    for s in g:servos
    {
        print "    " + s:NAME + ", position: " + s:POSITION.
        if (g:NAME = "Hinges" and s:POSITION = 0)
        {
            s:MOVETO(30, 2).
        }
        else if (g:NAME = "Hinges" and s:POSITION > 0)
        {
            s:MOVETO(0, 1).
        }
    }
}