.. default-domain:: lua .. highlight:: lua .. currentmodule:: InfernalRobotics Servo ===== .. class:: Servo Represents a servo. Obtained using :attr:`InfernalRobotics.ServoGroup.servos`, :meth:`InfernalRobotics.ServoGroup.servo_with_name` or :meth:`InfernalRobotics.servo_with_name`. .. attribute:: name: string The name of the servo. :Attribute: Can be read or written :rtype: string .. attribute:: uid: number The unique identifier of the servo. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: part: SpaceCenter.Part The part containing the servo. :Attribute: Read-only, cannot be set :rtype: :class:`SpaceCenter.Part` .. attribute:: mode: InfernalRobotics.ServoMode Whether the part acts as a servo or a rotor. :Attribute: Read-only, cannot be set :rtype: :class:`InfernalRobotics.ServoMode` .. attribute:: highlight: boolean Whether the servo should be highlighted in-game. :Attribute: Write-only, cannot be read :rtype: boolean .. attribute:: position: number The position of the servo. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: min_config_position: number The minimum position of the servo, specified by the part configuration. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: max_config_position: number The maximum position of the servo, specified by the part configuration. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: min_position: number The minimum position of the servo, specified by the in-game tweak menu. :Attribute: Can be read or written :rtype: number .. attribute:: max_position: number The maximum position of the servo, specified by the in-game tweak menu. :Attribute: Can be read or written :rtype: number .. attribute:: config_speed: number The speed multiplier of the servo, specified by the part configuration. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: speed: number The speed multiplier of the servo, specified by the in-game tweak menu. :Attribute: Can be read or written :rtype: number .. attribute:: current_speed: number The current speed at which the servo is moving. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: acceleration: number The current speed multiplier set in the UI. :Attribute: Can be read or written :rtype: number .. attribute:: is_moving: boolean Whether the servo is moving. :Attribute: Read-only, cannot be set :rtype: boolean .. attribute:: is_free_moving: boolean Whether the servo is freely moving. :Attribute: Read-only, cannot be set :rtype: boolean .. attribute:: is_locked: boolean Whether the servo is locked. :Attribute: Can be read or written :rtype: boolean .. attribute:: is_axis_inverted: boolean Whether the servos axis is inverted. :Attribute: Can be read or written :rtype: boolean .. attribute:: target_position: number The target position the servo is moving towards. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: target_speed: number The target speed the servo is moving at. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: commanded_position: number The position the servo is currently being commanded to move to. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: default_position: number The default (built) position of the servo. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: force_limit: number The force limit of the servo, as a percentage of the maximum force. :Attribute: Can be read or written :rtype: number .. attribute:: max_force: number The maximum force the servo can generate. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: max_acceleration: number The maximum acceleration the servo can achieve. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: max_speed: number The maximum speed the servo can achieve. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: electric_charge_required: number The rate at which the servo consumes electric charge, in units per second, when moving. :Attribute: Read-only, cannot be set :rtype: number .. attribute:: spring_power: number The strength of the servo's spring, when it has one. :Attribute: Can be read or written :rtype: number .. attribute:: damping_power: number The strength of the servo's damping. :Attribute: Can be read or written :rtype: number .. attribute:: rotor_acceleration: number The acceleration of the servo when operating as a rotor. :Attribute: Can be read or written :rtype: number .. attribute:: is_limited: boolean Whether the servo's range of movement is limited to the configured minimum and maximum positions. :Attribute: Can be read or written :rtype: boolean .. attribute:: is_rotational: boolean Whether the servo moves rotationally (as opposed to linearly). :Attribute: Read-only, cannot be set :rtype: boolean .. attribute:: is_servo: boolean Whether the part is operating as a servo (rather than a rotor). :Attribute: Read-only, cannot be set :rtype: boolean .. attribute:: can_have_limits: boolean Whether the servo can have its range of movement limited. :Attribute: Read-only, cannot be set :rtype: boolean .. attribute:: has_spring: boolean Whether the servo has a spring. :Attribute: Read-only, cannot be set :rtype: boolean .. attribute:: is_running: boolean Whether the servo is running, when operating as a rotor. :Attribute: Read-only, cannot be set :rtype: boolean .. attribute:: preset_positions: List The list of preset positions configured for the servo. :Attribute: Read-only, cannot be set :rtype: List .. method:: move_right() Moves the servo to the right. .. method:: move_left() Moves the servo to the left. .. method:: move_center() Moves the servo to the center. .. method:: move_to(position, speed) Moves the servo to *position* and sets the speed multiplier to *speed*. :param number position: The position to move the servo to. :param number speed: Speed multiplier for the movement. .. method:: stop() Stops the servo. .. method:: add_preset(position) Adds a preset position to the servo. :param number position: The position of the preset. .. method:: remove_preset_at(index) Removes the preset position at the given index. :param number index: The index of the preset to remove. .. method:: sort_presets() Sorts the preset positions of the servo into ascending order. .. class:: ServoMode The mode a servo is operating in. See :attr:`InfernalRobotics.Servo.mode`. .. data:: servo The part acts as a servo, driving towards a target position. .. data:: rotor The part acts as a rotor, spinning continuously.