Documentation Index

Fetch the complete documentation index at: https://docs.vention.com/llms.txt

Use this file to discover all available pages before exploring further.

Machine-Logic-sdk v3.1.0

Prev Next

Compatibility

This table specifies the compatibility of the Python package versions with the Vention's MachineMotion and Pendant versions.  

Package

MachineMotion

Pendant

v1.12.x*

v2.13.x

v3.2, v3.3

v1.13.0

>= v2.14.x, < v3.0.0

>= v3.4

v1.13.1

>= v2.15.x, < v3.0.0

>= v3.5

v1.13.2

>= v2.15.x, < v3.0.0

>= v3.5

v2.0.x

>= v3.0.0, < v3.1.0

N/A**

v2.1.x

>= v3.1.0, < v3.2.0

N/A**

v2.2.x

>= v3.2.0, < v3.3.0

N/A**

v3.0.x

>= v3.3.0, < v3.5.0

N/A**

v3.1.0

>= v3.5.0

N/A**

*Package versions before 1.13.0 were published to PyPi under the package name machine-code-python-sdk  **Post MMAI release (MachineMotion v3.0.0), machine-logic-sdk is no longer dependent on Pendant version.

Change Log

Version 3.1.0                

Version 3.1.0

Added:

  • machine.mqtt - New MQTT interface (IMqtt) on the Machine class:

  • machine.mqtt.on_event(topic, callback) -> int - Register a callback on an MQTT topic. Returns a callback ID.

  • machine.mqtt.remove_on_event_callback(callback_id) - Remove a previously registered event callback.

  • machine.mqtt.publish_event(topic, message=None) - Publish a message to an MQTT topic.

  • machine.ethernet_ip - New EthernetIP interface (IEthernetIp) on the Machine class:

  • machine.ethernet_ip.connect() - Establish a connection to the EthernetIP service.

  • machine.ethernet_ip.set_user_input(parameter_name, value) - Send a user input value to the PLC.

  • machine.ethernet_ip.on_user_output(parameter_name, callback) -> int - Register a callback for PLC output changes.

  • machine.ethernet_ip.remove_on_user_output_callback(callback_id) - Remove a PLC output callback.

  • Robot.move_until_tool_contact(max_travel, speed, force_threshold, reference_frame, torque_threshold, retract_distance, retract_speed) -> tuple[bool, CartesianPose] - Blocking guarded linear move that stops on tool contact.

  • Robot.move_until_tool_contact_async(...) -> MoveUntilToolContactResult - Non-blocking version of move_until_tool_contact.

  • MoveUntilToolContactResult - Result handle for async guarded moves:

    • .wait(timeout=None) -> tuple[bool, CartesianPose] - Block until the move completes.

    • .is_done() -> bool - Check if the move has completed.

    • .is_running() -> bool - Check if the move is still executing.

Deprecated:

  • Machine.on_mqtt_event() - Use machine.mqtt.on_event() instead. To remove a callback, use machine.mqtt.remove_on_event_callback() with the returned ID.

  • Machine.publish_mqtt_event() - Use machine.mqtt.publish_event() instead.

Fixed:

  • IO module inputs and outputs now update via gRPC stream instead of MQTT.

  • Blend radius now defaults to None.

Machine

A software representation of the entire Machine. A Machine is defined as any number of MachineMotions, each containing their own set of axes, outputs, inputs, pneumatics, and AC Motors. The Machine class offers a global way to retrieve these various components using the friendly names that you've defined in your MachineLogic configuration.

To create a new Machine with default settings, you can simply write:


machine = Machine()

If you need to connect to services running on a different machine or IP address, you can specify the IP address as follows:


machine = Machine("192.168.7.2")

You should only ever have a single instance of this object in your program.

ethernet_ip                

  • Description The EthernetIP communication interface for exchanging data with external PLCs.

  • Type EthernetIp

mqtt                

  • Description The MQTT interface for subscribing to and publishing events.

  • Type Mqtt

state                

get_ac_motor                

  • Description Retrieves an AC Motor by name.

  • Parameters

    • name

      • Description The name of the AC Motor.

      • Type str

  • Returns

    • Description The AC Motor that was found.

    • Type ACMotor

get_actuator                

  • Description Retrieves an Actuator by name.

  • Parameters

    • name

      • Description The name of the Actuator.

      • Type str

  • Returns

    • Description The Actuator that was found.

    • Type Actuator

from machinelogic import Machine, MotionProfile

machine = Machine()
my_actuator = machine.get_actuator("Actuator")


# Always home the actuator before starting to ensure position is properly calibrated.
my_actuator.home(timeout=10)

start_position = my_actuator.state.position
print("starting at position: ", start_position)

TARGET_DISTANCE = 150  # millimeters
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

my_actuator.move_relative(
    distance=TARGET_DISTANCE,
    motion_profile=new_motion_profile,
)

# first_move_end_position is approx. equal to start_position + target_distance.
first_move_end_position = my_actuator.state.position
print("first move finished at position: ", first_move_end_position)


# move back to starting position
TARGET_DISTANCE = -1 * TARGET_DISTANCE
my_actuator.move_relative(
    distance=TARGET_DISTANCE,
    motion_profile=new_motion_profile,
)

# approx. equal to start_position,
end_position = my_actuator.state.position
print("finished back at position: ", end_position)

get_input                

  • Description Retrieves an DigitalInput by name. The name must match the input pin's friendly name exactly as it appears in the machine configuration (for example "Input C0"), not the display name of a device wired to it.

  • Parameters

    • name

      • Description The name of the DigitalInput.

      • Type str

  • Returns

    • Description The DigitalInput that was found.

    • Type DigitalInput

from machinelogic import Machine

machine = Machine()

# Get input by friendly name
# Input peripherals can be connected to the controller via the following devices:
#  - IO Module
#  - Push Button Module
#  - Conveyor Motor

my_input = machine.get_input("Input")

if my_input.state.value:
    print(f"{my_input.configuration.name} is HIGH")
else:
    print(f"{my_input.configuration.name} is LOW")

print("Timestamp: ", my_input.state.timestamp)

get_machine_motion                

  • Description Retrieves an IMachineMotion instance by name.

  • Parameters

    • name

      • Description The name of the MachineMotion.

      • Type str

  • Returns

from machinelogic import Machine

machine = Machine()

my_controller_1 = machine.get_machine_motion("Controller 1")

configuration = my_controller_1.configuration

print("Name:", configuration.name)

get_output                

  • Description Retrieves an Output by name. The name must match the output pin's friendly name exactly as it appears in the machine configuration (for example "Output C0"), not the display name of a device wired to it.

  • Parameters

    • name

      • Description The name of the Output

      • Type str

  • Returns

    • Description The Output that was found.

    • Type IOutput

from machinelogic import Machine

machine = Machine()
my_output = machine.get_output("Output")

my_output.write(True)  # Write "true" to the Output
my_output.write(False)  # Write "false" to the Output

get_pneumatic                

  • Description Retrieves a Pneumatic by name.

  • Parameters

    • name

      • Description The name of the Pneumatic.

      • Type str

  • Returns

    • Description The Pneumatic that was found.

    • Type Pneumatic

import time

from machinelogic import Machine

machine = Machine()
my_pneumatic = machine.get_pneumatic("Pneumatic")


# Idle
my_pneumatic.idle_async()
time.sleep(1)

# Push
my_pneumatic.push_async()
time.sleep(1)

# Pull
my_pneumatic.pull_async()
time.sleep(1)

get_robot                

  • Description Retrieves a Robot by name. If no name is specified, then returns the first Robot.

  • Parameters

    • name

      • Description The Robot name. If it's `None`, then the first Robot in the Robot list is returned.

      • Type str

  • Returns

    • Description The Robot that was found.

    • Type Robot

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Example of use: moving robot to specified joint angles in deg
my_robot.movej([0, -90, 120, -90, -90, 0])

get_scene                

  • Description Returns the scene instance

  • Returns

    • Description The instance of the scene containing the scene assets.

    • Type Scene

on_mqtt_event                

  • Description Attach a callback function to an MQTT topic. .. deprecated::     Use ``machine.mqtt.on_event`` instead. To remove a callback, use     ``machine.mqtt.remove_on_event_callback`` with the ID returned by ``on_event``.

  • Parameters

    • topic

      • Description The topic to listen on.

      • Type str

    • callback

      • Description A callback where the first argument is the topic and the second is the message. Pass ``None`` to remove the callback.

      • Type Optional[Callable[[str, str], None]]

import time

from machinelogic import Machine

machine = Machine()

my_event_topic = "my_custom/event/topic"


# A "callback" function called everytime a new mqtt event on my_event_topic is received.
def event_callback(topic: str, message: str):
    print("new mqtt event:", topic, message)


# DEPRECATED: on_mqtt_event is deprecated. Use machine.mqtt.on_event instead.
# See examples/Mqtt/on_event.py for the updated usage.
machine.on_mqtt_event(my_event_topic, event_callback)
machine.publish_mqtt_event(my_event_topic, "my message")

time.sleep(2)

machine.on_mqtt_event(my_event_topic, None)  # remove the callback.

on_system_state_change                

  • Description Adds a change listener to execute when the Machine state changes.

from machinelogic import Machine
from machinelogic.types import MachineOperationalState, MachineSafetyState

machine = Machine()


# Callback function called everytime a new system state is received.
def on_machine_state_change_callback(operational_state: MachineOperationalState, safety_state: MachineSafetyState):
    print("New Machine Operational State", operational_state)
    print("New Machine Safety State", safety_state)


# To set an on_system_state_change callback
machine.on_system_state_change(on_machine_state_change_callback)

# To remove the callback
machine.on_system_state_change(None)

publish_mqtt_event                

  • Description Publish an MQTT event. .. deprecated::     Use ``machine.mqtt.publish_event`` instead.

  • Parameters

    • topic

      • Description Topic to publish.

      • Type str

    • message

      • Description Optional message. Defaults to None.

      • Type Optional[str]

import json
import time

from machinelogic import Machine

machine = Machine()

# Example for publishing a cycle-start and cycle-end topic and message
# to track application cycles in MachineAnalytics
cycle_start_topic = "application/cycle-start"
cycle_end_topic = "application/cycle-end"
cycle_message = {"applicationId": "My Python Application", "cycleId": "default"}
json_cycle_message = json.dumps(cycle_message)

while True:
    # DEPRECATED: publish_mqtt_event is deprecated. Use machine.mqtt.publish_event instead.
    # See examples/Mqtt/publish_event.py for the updated usage.
    machine.publish_mqtt_event(cycle_start_topic, json_cycle_message)
    print("Cycle Start")
    time.sleep(5)
    machine.publish_mqtt_event(cycle_end_topic, json_cycle_message)
    time.sleep(1)
    print("Cycle end")

reset                

  • Description Reset the machine by trying to clear drive errors.

  • Returns

    • Description True if the machine was reset successfully, False otherwise.

    • Type bool

from machinelogic import Machine

machine = Machine()

# Example for resetting the machine if the MachineOperationalState is
# NON_OPERATIONAL. The reset programmatically tries to clear drive errors

if machine.state.operational_state == "NON_OPERATIONAL":
    machine.reset()
    print("Machine Reset")

MachineState

A representation of the state of the Machine.

operational_state                

safety_state                

MachineOperationalState

Description: The machine's operational state.

  • NON_OPERATIONAL= 0

  • NORMAL= 1

MachineSafetyState

Description: The machine's safety state.

  • ERROR= -1

  • NONE= 0

  • EMERGENCY_STOP= 1

  • NORMAL= 2

MachineMotion

A software representation of a MachineMotion controller. The MachineMotion is comprised of many actuators, inputs, outputs, pneumatics, and ac motors. It keeps a persistent connection to MQTT as well.

You should NEVER construct this object yourself. Instead, it is best to rely on the Machine instance to provide you with a list of the available MachineMotions.

configuration                

  • Description          MachineMotionConfiguration: The representation of the configuration associated with this MachineMotion.        

  • Type MachineMotionConfiguration

Mqtt

A software representation of the MQTT communication interface.

MQTT allows the Machine to subscribe to and publish events on topics.

It is not recommended that you construct this object yourself. Instead, access it via the Machine instance:

E.g.:


machine = Machine()
callback_id = machine.mqtt.on_event("my/topic", my_callback)
machine.mqtt.publish_event("my/topic", "my message")
machine.mqtt.remove_on_event_callback(callback_id)

on_event                

  • Description Register a callback that fires whenever a message is received on the given topic. Multiple callbacks can be registered on the same topic.

  • Parameters

    • topic

      • Description The MQTT topic to subscribe to. Supports wildcards (e.g. ``"sensor/+/value"``).

      • Type str

    • callback

      • Description A function called with ``(topic, message)`` when a message arrives.

      • Type Callable[[str, Optional[str]], None]

  • Returns

    • Description A callback ID that can be passed to ``remove_on_event_callback`` to unregister.

    • Type int

import time

from machinelogic import Machine

machine = Machine()

my_event_topic = "my_custom/event/topic"


# A "callback" function called everytime a new mqtt event on my_event_topic is received.
def event_callback(topic: str, message: str):
    print("new mqtt event:", topic, message)


callback_id = machine.mqtt.on_event(my_event_topic, event_callback)
machine.mqtt.publish_event(my_event_topic, "my message")

time.sleep(2)

machine.mqtt.remove_on_event_callback(callback_id)

publish_event                

  • Description Publish a message to an MQTT topic.

  • Parameters

    • topic

      • Description The topic to publish to.

      • Type str

    • message

      • Description The message payload. Defaults to ``None``.

      • Type Optional[str]

import json
import time

from machinelogic import Machine

machine = Machine()

# Example for publishing a cycle-start and cycle-end topic and message
# to track application cycles in MachineAnalytics
cycle_start_topic = "application/cycle-start"
cycle_end_topic = "application/cycle-end"
cycle_message = {"applicationId": "My Python Application", "cycleId": "default"}
json_cycle_message = json.dumps(cycle_message)

while True:
    machine.mqtt.publish_event(cycle_start_topic, json_cycle_message)
    print("Cycle Start")
    time.sleep(5)
    machine.mqtt.publish_event(cycle_end_topic, json_cycle_message)
    time.sleep(1)
    print("Cycle end")

remove_on_event_callback                

  • Description Remove a previously registered event callback.

  • Parameters

    • callback_id

      • Description The ID returned by ``on_event``.

      • Type int

import time

from machinelogic import Machine

machine = Machine()

my_event_topic = "my_custom/event/topic"


# Multiple callbacks can be registered on the same topic.
def callback_one(topic: str, message: str):
    print("callback_one received:", topic, message)


def callback_two(topic: str, message: str):
    print("callback_two received:", topic, message)


callback_id_one = machine.mqtt.on_event(my_event_topic, callback_one)
callback_id_two = machine.mqtt.on_event(my_event_topic, callback_two)

machine.mqtt.publish_event(my_event_topic, "both callbacks will fire")

time.sleep(2)

# Remove individual callbacks by their ID.
machine.mqtt.remove_on_event_callback(callback_id_one)
machine.mqtt.remove_on_event_callback(callback_id_two)

EthernetIp

A software representation of an EtherNet/IP (EIP) communication interface.

EtherNet/IP allows the Machine to exchange data with external PLCs. User Inputs are values sent from the Machine to the PLC, and User Outputs are values received from the PLC.

It is not recommended that you construct this object yourself. Instead, access it via the Machine instance:

E.g.:


machine = Machine()
machine.ethernet_ip.connect()

connect                

  • Description Establish a connection to the EtherNet/IP service. This must be called before any other EtherNet/IP operations.

  • Raises

    • Type RuntimeError

    • Description If the connection cannot be established.

from machinelogic import Machine

machine = Machine()

# Connect to the EthernetIP service before performing any EIP operations
machine.ethernet_ip.connect()

on_user_output                

  • Description Register a callback that fires whenever the specified User Output value changes. When the PLC changes the User Output values, the callback receives the corresponding new integer value.

  • Parameters

    • parameter_name

      • Description The name of the User Output parameter as defined in the EDS file.

      • Type str

    • callback

      • Description A function that receives the new User Output value as an integer.

      • Type Callable[[int], None]

  • Returns

    • Description A handle that can be passed to ``remove_on_user_output_callback`` to unregister.

    • Type int

  • Raises

    • Type RuntimeError

    • Description If not connected.

from machinelogic import Machine
import time
machine = Machine()

machine.ethernet_ip.connect()


def handle_sensor_value(value):
    print(f"Received new sensor value from PLC: {value}")


# Register a callback that fires when the "UserOutput0" value changes.
# "UserOutput0" is the tag name defined in the EDS file.
machine.ethernet_ip.on_user_output("UserOutput0", handle_sensor_value)

while True:
    time.sleep(1)

remove_on_user_output_callback                

  • Description Remove a previously registered callback for User Output changes.

  • Parameters

    • callback_id

      • Description The ID of the callback to remove.

      • Type int

from machinelogic import Machine
import time

machine = Machine()

machine.ethernet_ip.connect()

def handle_sensor_value(value):
    print(f"Received: {value}")

handle = machine.ethernet_ip.on_user_output("UserOutput0", handle_sensor_value)

time.sleep(3)

# Remove the callback using the handle returned by on_user_output
machine.ethernet_ip.remove_on_user_output_callback(handle)

set_user_input                

  • Description Set a User Input value to be sent to the PLC.

  • Parameters

    • parameter_name

      • Description The name of the User Input param as defined in the EDS file.

      • Type str

    • value

      • Description The integer value to set.

      • Type int

  • Raises

    • Type RuntimeError

    • Description If not connected.

from machinelogic import Machine

machine = Machine()

machine.ethernet_ip.connect()

# Set an EtherNet/IP user input value that will be sent to the PLC.
# "UserInput0" is the tag name defined in the EDS file.
machine.ethernet_ip.set_user_input("UserInput0", 100)

Actuator

A software representation of an Actuator. An Actuator is defined as a motorized axis that can move by discrete distances. It is not recommended that you construct this object yourself. Rather, you should query it from a Machine instance:

E.g.:


machine = Machine()
my_actuator = machine.get_actuator("Actuator")

In this example, "New actuator" is the friendly name assigned to the Actuator in the MachineLogic configuration page.

configuration                

  • Description The representation of the configuration associated with this MachineMotion.

  • Type ActuatorConfiguration

state                

  • Description The representation of the current state of this MachineMotion.

  • Type ActuatorState

home                

  • Description Home the Actuator synchronously. Homing establishes the actuator's position reference. Absolute positions are only meaningful after the actuator has been homed.

  • Parameters

    • timeout

      • Description The timeout in seconds.

      • Type float

  • Raises

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")

my_actuator.home(timeout=10)

move_absolute                

  • Description Moves absolute synchronously to the specified position. Absolute positions are only meaningful after the actuator has been homed.

  • Parameters

    • position

      • Description The position to move to.

      • Type float

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class.

      • Type MotionProfile

from machinelogic import Machine, MotionProfile

machine = Machine()
my_actuator = machine.get_actuator("Actuator")


# Always home the actuator before starting to ensure position is properly calibrated.
my_actuator.home(timeout=10)

TARGET_POSITION = 150.0  # millimeters
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

my_actuator.move_absolute(
    position=TARGET_POSITION,  # millimeters
    motion_profile=MotionProfile(
        velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
    ),
)

move_absolute_async                

  • Description Moves absolute asynchronously.

  • Parameters

    • position

      • Description The position to move to.

      • Type float

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class.

      • Type MotionProfile

import time

from machinelogic import Machine, MotionProfile

machine = Machine()
my_actuator = machine.get_actuator("Actuator")

# Always home the actuator before starting to ensure position is properly calibrated.
my_actuator.home(timeout=10)

TARGET_POSITION = 150.0  # millimeters
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

# move_absolute_async will start the move and return without waiting for the move to complete.
my_actuator.move_absolute_async(
    position=TARGET_POSITION, motion_profile=new_motion_profile
)

while my_actuator.state.move_in_progress:
    print("move is in progress...")
    time.sleep(1)

# end_position will be approx. equal to target_position.
end_position = my_actuator.state.position
print("finished at position: ", end_position)

move_continuous_async                

  • Description Starts a continuous move. The Actuator will keep moving until it is stopped.

  • Parameters

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class. Note: Actuator.move_continuous_async does not support jerk. If jerk is provided in the MotionProfile, a warning will be raised and the move will continue without jerk.

      • Type MotionProfile

import time

from machinelogic import Machine, MotionProfile

machine = Machine()
my_actuator = machine.get_actuator("Actuator")

# Always home the actuator before starting to ensure position is properly calibrated.
my_actuator.home(timeout=10)

# Continuous motion profile only uses velocity and acceleration.
VELOCITY = 100.0  # mm/s
ACCELERATION = 100.0  # mm/s^2

new_motion_profile = MotionProfile(velocity=VELOCITY, acceleration=ACCELERATION)

# move_continuous_async will start the move and return without waiting for the move to complete.
my_actuator.move_continuous_async(motion_profile=new_motion_profile)

time.sleep(10)  # move continuously for ~10 seconds.

my_actuator.stop()  # decelerate to stopped.

move_relative                

  • Description Moves relative synchronously by the specified distance.

  • Parameters

    • distance

      • Description The distance to move.

      • Type float

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class.

      • Type MotionProfile

from machinelogic import Machine, MotionProfile

machine = Machine()
my_actuator = machine.get_actuator("Actuator")


# Always home the actuator before starting to ensure position is properly calibrated.
my_actuator.home(timeout=10)

start_position = my_actuator.state.position
print("starting at position: ", start_position)

TARGET_DISTANCE = 150  # millimeters
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

my_actuator.move_relative(
    distance=TARGET_DISTANCE,
    motion_profile=new_motion_profile,
)

# first_move_end_position is approx. equal to start_position + target_distance.
first_move_end_position = my_actuator.state.position
print("first move finished at position: ", first_move_end_position)


# move back to starting position
TARGET_DISTANCE = -1 * TARGET_DISTANCE
my_actuator.move_relative(
    distance=TARGET_DISTANCE,
    motion_profile=new_motion_profile,
)

# approx. equal to start_position,
end_position = my_actuator.state.position
print("finished back at position: ", end_position)

move_relative_async                

  • Description Moves relative asynchronously by the specified distance.

  • Parameters

    • distance

      • Description The distance to move.

      • Type float

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class.

      • Type MotionProfile

import time

from machinelogic import Machine, MotionProfile

machine = Machine()
my_actuator = machine.get_actuator("Actuator")

# Always home the actuator before starting to ensure position is properly calibrated.
my_actuator.home(timeout=10)

start_position = my_actuator.state.position
print("starting at position: ", start_position)

TARGET_DISTANCE = 150  # millimeters
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

# move_relative_async will start the move and return without waiting for the move to complete.
my_actuator.move_relative_async(
    distance=TARGET_DISTANCE, motion_profile=new_motion_profile
)

while my_actuator.state.move_in_progress:
    print("move is in progress...")
    time.sleep(1)

# end_position will be approx. equal to start_position + target_distance.
end_position = my_actuator.state.position
print("finished at position", end_position)

stop                

  • Description Stops movement on this Actuator as quickly as possible.

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")

my_actuator.stop()
# The actuator will stop as quickly as possible.

wait_for_move_completion                

  • Description Waits for motion to complete before commencing the next action.

  • Parameters

    • timeout

      • Description The timeout in seconds, after which an exception will be thrown.

      • Type float

  • Raises

    • Type ActuatorException

    • Description If the request fails or the move did not complete in the allocated amount of time.

from machinelogic import Machine, MotionProfile

machine = Machine()
my_actuator = machine.get_actuator("Actuator")

# Always home the actuator before starting to ensure position is properly calibrated.
my_actuator.home(timeout=10)


TARGET_POSITION = 150.0  # millimeters
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2

new_motion_profile = MotionProfile(velocity=VELOCITY, acceleration=ACCELERATION)

# move_absolute_async will start the move and return without waiting for the move to complete.
my_actuator.move_absolute_async(
    position=TARGET_POSITION, motion_profile=new_motion_profile
)


print("move started...")
my_actuator.wait_for_move_completion(timeout=10)
print("motion complete.")


# end_position will be approx. equal to target_position.
end_position = my_actuator.state.position
print("finished at position: ", end_position)

ActuatorState

Representation of the current state of an Actuator instance. The values in this class are updated in real time to match the physical reality of the Actuator.

end_sensors                

  • Description A tuple representing the state of the [ home, end ] sensors.         On machines without end sensors wired, both values remain False.

  • Type typing.Tuple[bool, bool]

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.state.end_sensors)

move_in_progress                

  • Description The boolean is True if the actuator has not yet reached its target position, otherwise False.         Always False during continuous moves, which have no target position.

  • Type bool

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.state.move_in_progress)

output_torque                

  • Description The current torque output of the Actuator.

  • Type dict

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.state.output_torque)

position                

  • Description The current position of the Actuator.

  • Type float

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.state.position)

speed                

  • Description The current speed of the Actuator.

  • Type float

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.state.speed)

ActuatorConfiguration

Representation of the configuration of an Actuator instance. This configuration defines what your Actuator is and how it should behave when work is requested from it.

actuator_type                

  • Description The type of the Actuator.

  • Type typing.Literal['belt', 'rack_and_pinion', 'rack_and_pinion_v2', 'ball_screw', 'enclosed_ball_screw', 'enclosed_lead_screw', 'indexer', 'indexer_v2', 'electric_cylinder', 'belt_conveyor', 'roller_conveyor', 'pneumatic', 'ac_motor_with_vfd', 'enclosed_timing_belt', 'belt_rack', 'heavy_duty_roller_conveyor', 'timing_belt_conveyor', 'telescopic_column', 'custom']

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.configuration.actuator_type)

controller_id                

  • Description The controller id of the Actuator

  • Type str

home_sensor                

  • Description The home sensor port, either A or B.

  • Type typing.Literal['A', 'B']

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.configuration.home_sensor)

name                

  • Description The name of the Actuator.

  • Type str

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.configuration.name)

units                

  • Description The units that the Actuator functions in.

  • Type typing.Literal['deg', 'mm']

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.configuration.units)

uuid                

  • Description The Actuator's ID.

  • Type str

from machinelogic import Machine

machine = Machine()
my_actuator = machine.get_actuator("Actuator")
print(my_actuator.configuration.uuid)

ActuatorGroup

A helper class used to group N-many Actuator instances together so that they can be acted upon as a group. An ActuatorGroup may only contain Actuators that are on the same MachineMotion controller.

E.g.:


machine = Machine()
my_actuator_1 = machine.get_actuator("Actuator 1")
my_actuator_2 = machine.get_actuator("Actuator 2")
actuator_group = ActuatorGroup(my_actuator_1, my_actuator_2)

state                

  • Description The state of the ActuatorGroup.

  • Type ActuatorGroupState

move_absolute                

  • Description Moves absolute synchronously to the tuple of positions.

  • Parameters

    • position

      • Description The positions to move to. Each value corresponds 1-to-1 with the actuators tuple provided to the constructor.

      • Type Tuple[float, ...]

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class.

      • Type MotionProfile

from machinelogic import ActuatorGroup, Machine, MotionProfile

machine = Machine()
my_actuator_1 = machine.get_actuator("Actuator 1")
my_actuator_2 = machine.get_actuator("Actuator 2")

# Always home the actuators before starting to ensure position is properly calibrated.
my_actuator_1.home(timeout=10)
my_actuator_2.home(timeout=10)

actuator_group = ActuatorGroup(my_actuator_1, my_actuator_2)

TARGET_POSITIONS = (100.0, 200.0)  # (mm - actuator1, mm - actuator2)
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

actuator_group.move_absolute(
    position=TARGET_POSITIONS, motion_profile=new_motion_profile
)

move_absolute_async                

  • Description Moves absolute asynchronously to the tuple of positions.

  • Parameters

    • distance

      • Description The positions to move to. Each value corresponds 1-to-1 with the actuators tuple provided to the constructor.

      • Type Tuple[float, ...]

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class.

      • Type MotionProfile

from machinelogic import ActuatorGroup, Machine, MotionProfile

machine = Machine()
my_actuator_1 = machine.get_actuator("Actuator 1")
my_actuator_2 = machine.get_actuator("Actuator 2")

# Always home the actuators before starting to ensure position is properly calibrated.
my_actuator_1.home(timeout=10)
my_actuator_2.home(timeout=10)

actuator_group = ActuatorGroup(my_actuator_1, my_actuator_2)

TARGET_POSITIONS = (75.0, 158.0)  # (mm - actuator1, mm - actuator2)
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

# move_absolute_async will start the move and return without waiting for the move to complete.
actuator_group.move_absolute_async(
    position=TARGET_POSITIONS, motion_profile=new_motion_profile
)
print("move started..")

actuator_group.wait_for_move_completion()
print("motion completed.")

move_relative                

  • Description Moves relative synchronously by the tuple of distances.

  • Parameters

    • distance

      • Description The distances to move each Actuator. Each value corresponds 1-to-1 with the actuators tuple provided to the constructor.

      • Type Tuple[float, ...]

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class.

      • Type MotionProfile

from machinelogic import ActuatorGroup, Machine, MotionProfile

machine = Machine()
my_actuator_1 = machine.get_actuator("Actuator 1")
my_actuator_2 = machine.get_actuator("Actuator 2")

# Always home the actuators before starting to ensure position is properly calibrated.
my_actuator_1.home(timeout=10)
my_actuator_2.home(timeout=10)

actuator_group = ActuatorGroup(my_actuator_1, my_actuator_2)


TARGET_DISTANCES = (-120.0, 240.0)  # (mm - actuator1, mm - actuator2)
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

actuator_group.move_relative(
    distance=TARGET_DISTANCES, motion_profile=new_motion_profile
)

move_relative_async                

  • Description Moves relative asynchronously by the tuple of distances.

  • Parameters

    • distance

      • Description The distances to move each Actuator. Each value corresponds 1-to-1 with the actuators tuple provided to the constructor.

      • Type Tuple[float, ...]

    • motion_profile

      • Description The motion profile to move with. See MotionProfile class.

      • Type MotionProfile

import time

from machinelogic import ActuatorGroup, Machine, MotionProfile

machine = Machine()
actuator1 = machine.get_actuator("My Actuator #1")
actuator2 = machine.get_actuator("My Actuator #2")

# Always home the actuators before starting to ensure position is properly calibrated.
actuator1.home(timeout=10)
actuator2.home(timeout=10)

actuator_group = ActuatorGroup(actuator1, actuator2)

TARGET_DISTANCES = (-120.0, 240.0)  # (mm - actuator1, mm - actuator2)
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

# move_relative_async will start the move and return without waiting for the move to complete.
actuator_group.move_relative_async(
    distance=TARGET_DISTANCES, motion_profile=new_motion_profile
)

while actuator_group.state.move_in_progress:
    print("motion is in progress..")
    time.sleep(1)

print("motion complete")

stop                

  • Description Stops movement on all Actuators in the group.

wait_for_move_completion                

  • Description Waits for motion to complete on all Actuators in the group.

  • Parameters

    • timeout

      • Description The timeout in seconds, after which an exception will be thrown.

      • Type float

  • Raises

    • Type ActuatorGroupException

    • Description If the request fails or the move did not complete in the allocated amount of time.

from machinelogic import ActuatorGroup, Machine, MotionProfile

machine = Machine()
my_actuator_1 = machine.get_actuator("Actuator 1")
my_actuator_2 = machine.get_actuator("Actuator 2")

# Always home the actuators before starting to ensure position is properly calibrated.
my_actuator_1.home(timeout=10)
my_actuator_2.home(timeout=10)

actuator_group = ActuatorGroup(my_actuator_1, my_actuator_2)

TARGET_POSITIONS = (75.0, 158.0)  # (mm - actuator1, mm - actuator2)
VELOCITY = 150.0  # mm/s
ACCELERATION = 150.0  # mm/s^2
JERK = 150.0  # mm/s^3 OPTIONAL PARAMETER

new_motion_profile = MotionProfile(
    velocity=VELOCITY, acceleration=ACCELERATION, jerk=JERK
)

# move_absolute_async will start the move and return without waiting for the move to complete.
actuator_group.move_absolute_async(
    position=TARGET_POSITIONS, motion_profile=new_motion_profile
)
print("move started..")

actuator_group.wait_for_move_completion()
print("motion completed.")

MotionProfile

MotionProfile: A dataclass that represents the motion profile of a move. args:


velocity (float): The velocity of the move in mm/s
acceleration (float): The acceleration of the move in mm/s^2
jerk (float | None): The jerk of the move in mm/s^3. Defaults to None

If used in a continuous_move, only velocity and acceleration are required.

If jerk is defined, an s-curve profile will be generated. Jerk option is commonly used to limit vibration due to sharp changes in motion profile.

Robot

A software representation of a Robot. It is not recommended that you construct this object yourself. Rather, you should query it from a Machine instance:

E.g.:


machine = Machine()
my_robot = machine.get_robot("Robot")

In this example, "Robot" is the friendly name assigned to the actuator in the MachineLogic configuration page.

configuration                

  • Description The Robot configuration.

  • Type RobotConfiguration

state                

  • Description The current Robot state.

  • Type RobotState

compute_forward_kinematics                

  • Description Computes the forward kinematics from joint angles.

  • Parameters

    • joint_angles

      • Description The 6 joint angles, in degrees.

      • Type JointAnglesDegrees

  • Returns

    • Description Cartesian pose, in mm and degrees

    • Type CartesianPose

  • Raises

    • Type ValueError

    • Description Throws an error if the joint angles are invalid.

    • Type RobotException

    • Description Throws an error if the resulted forward kinematics computation not successful

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Joint angles, in degrees
joint_angles = [
    176.68,  # j1
    -35.95,  # j2
    86.37,  # j3
    -150.02,  # j4
    -90.95,  # j5
    -18.58,  # j6
]
computed_robot_pose = my_robot.compute_forward_kinematics(joint_angles)
print(computed_robot_pose)

compute_inverse_kinematics                

  • Description Computes the inverse kinematics from a Cartesian pose.

  • Parameters

    • cartesian_position

      • Description The end effector's pose, in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

      • Type CartesianPose

    • joint_constraints

      • Description A list of joint constraints. Length of list can be between 1 and number of joints on robot.

      • Type Optional[List[GenericJointConstraint]]

    • seed_position

      • Description The seed joint angles, in degrees (as start position for IK search)

      • Type Optional[JointAnglesDegrees]

  • Returns

    • Description Joint angles, in degrees.

    • Type JointAnglesDegrees

  • Raises

    • Type ValueError

    • Description Throws an error if the inverse kinematic solver fails.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

cartesian_position = [
    648.71,  # x in millimeters
    -313.30,  # y in millimeters
    159.28,  # z in millimeters
    107.14,  # rx in degrees
    -145.87,  # ry in degrees
    15.13,  # rz in degrees
]

computed_joint_angles = my_robot.compute_inverse_kinematics(cartesian_position)
print(computed_joint_angles)

create_sequence                

  • Description Creates a RobotMoveSequence object.

  • Returns

    • Description A RobotMoveSequence object with which you can chain movements.

    • Type RobotMoveSequence

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Create an arbitrary Cartesian waypoint, that is 10mm or 10 degrees away from the current position
cartesian_waypoint = [i + 10 for i, _ in my_robot.state.cartesian_position_data]

# Create an arbitrary joint waypoint, that is 10 degrees away from the current joint angles
joint_waypoint = [i + 10 for i, _ in my_robot.state.joint_angles_data]

cartesian_velocity = 100.0  # millimeters per second
cartesian_acceleration = 100.0  # millimeters per second squared
blend_radius_1 = 5.0  # millimeters
reference_frame = [
    23.56,  # x in millimeters
    -125.75,  # y in millimeters
    5.92,  # z in millimeters
    0.31,  # rx in degrees
    0.65,  # ry in degrees
    90.00,  # rz in degrees
]

joint_velocity = 10.0  # degrees per second
joint_acceleration = 10.0  # degrees per second squared
blend_radius_2 = 5.0  # millimeters


with my_robot.create_sequence() as seq:
    seq.append_movel(
        cartesian_waypoint,
        cartesian_velocity,
        cartesian_acceleration,
        blend_radius_1,
        reference_frame,
    )
    seq.append_movej(joint_waypoint, joint_velocity, joint_acceleration, blend_radius_2)

# Alternate Form:
seq = my_robot.create_sequence()
seq.append_movel(cartesian_waypoint)
seq.append_movej(joint_waypoint)
my_robot.execute_sequence(seq)

execute_sequence                

  • Description Moves the robot through a specific sequence of joint and linear motions.

  • Raises

    • Type ValueError

    • Description If the sequence is invalid.

    • Type RobotException

    • Description If the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Create an arbitrary Cartesian waypoint, that is 10mm or 10 degrees away from the current position
cartesian_waypoint = [i + 10 for i, _ in my_robot.state.cartesian_position_data]

# Create an arbitrary joint waypoint, that is 10 degrees away from the current joint angles
joint_waypoint = [i + 10 for i, _ in my_robot.state.joint_angles_data]

cartesian_velocity = 100.0  # millimeters per second
cartesian_acceleration = 100.0  # millimeters per second squared
blend_radius_1 = 5.0  # millimeters

joint_velocity = 10.0  # degrees per second
joint_acceleration = 10.0  # degrees per second squared
blend_radius_2 = 5.0  # millimeters

seq = my_robot.create_sequence()
seq.append_movel(
    cartesian_waypoint, cartesian_velocity, cartesian_acceleration, blend_radius_1
)
seq.append_movej(joint_waypoint, joint_velocity, joint_acceleration, blend_radius_2)
my_robot.execute_sequence(seq)

execute_sequence_async                

  • Description Moves the robot through a specific sequence of joint and linear motions asynchronously.

  • Raises

    • Type ValueError

    • Description If the sequence is invalid.

    • Type RobotException

    • Description If the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Create an arbitrary Cartesian waypoint, that is 10mm or 10 degrees away from the current position
cartesian_waypoint = [i + 10 for i, _ in my_robot.state.cartesian_position_data]

# Create an arbitrary joint waypoint, that is 10 degrees away from the current joint angles
joint_waypoint = [i + 10 for i, _ in my_robot.state.joint_angles_data]

cartesian_velocity = 100.0  # millimeters per second
cartesian_acceleration = 100.0  # millimeters per second squared
blend_radius_1 = 5.0  # millimeters

joint_velocity = 10.0  # degrees per second
joint_acceleration = 10.0  # degrees per second squared
blend_radius_2 = 5.0  # millimeters

# Method 1: Manual execution with execute_sequence_async
seq = my_robot.create_sequence()
seq.append_movel(
    cartesian_waypoint, cartesian_velocity, cartesian_acceleration, blend_radius_1
)
seq.append_movej(joint_waypoint, joint_velocity, joint_acceleration, blend_radius_2)

my_robot.execute_sequence_async(seq)

print("Robot is executing sequence asynchronously.")
my_robot.wait_for_motion_completion()
print("Robot has finished executing sequence.")

# Method 2: Context manager with execute_async_on_exit (alternative)
with my_robot.create_sequence().execute_async_on_exit() as seq:
    seq.append_movel(cartesian_waypoint, cartesian_velocity, cartesian_acceleration, blend_radius_1)
    seq.append_movej(joint_waypoint, joint_velocity, joint_acceleration, blend_radius_2)
# Executes asynchronously when context exits
print("Robot is executing sequence asynchronously.")
my_robot.wait_for_motion_completion()
print("Robot has finished executing sequence.")

move_stop                

  • Description Stops the robot current movement.

  • Returns

    • Description True if the robot was successfully stopped, False otherwise.

    • Type bool

from machinelogic import Machine
import time

machine = Machine()
my_robot = machine.get_robot("Robot")

joint_angles = [0.0, -45.0, 45.0, 0.0, 45.0, 0.0]

# Use an async move to allow move_stop to be called while the robot is moving.
# Synchronous moves (movej, movel) block until completion, so stopping mid-motion would require threads.
my_robot.movej_async(joint_angles)

# Simulate a condition that requires stopping (e.g., sensor trigger, user input)
time.sleep(1.0)

my_robot.move_stop()

move_to_target                

  • Description Moves the robot to a scene target identified by friendly name. The named target is resolved against the scene at call time. The first matching target is used; a warning is logged if multiple targets share the same name.

  • Parameters

    • name

      • Description Friendly name of the scene target asset.

      • Type None

    • move_type

      • Description 'j' for a joint-space move, 'l' for a linear Cartesian move.

      • Type None

    • velocity

      • Description Move velocity. Units are deg/s for move_type='j', mm/s for move_type='l'.

      • Type float

    • acceleration

      • Description Move acceleration. Units are deg/s^2 for move_type='j', mm/s^2 for move_type='l'.

      • Type float

  • Raises

    • Type SceneException

    • Description If no scene target is found with the given name.

    • Type RobotException

    • Description If the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Friendly name resolves to a CartesianTarget defined in the scene.
my_robot.move_to_target("New Cartesian Target", move_type="l", velocity=100.0, acceleration=100.0)

# Friendly name resolves to a JointTarget defined in the scene.
my_robot.move_to_target("New Joint Target", move_type="j", velocity=10.0, acceleration=10.0)

# Cross-type: target is a CartesianTarget, but a joint-space move is requested.
# Inverse kinematics is applied automatically.
my_robot.move_to_target("New Cartesian Target", move_type="j", velocity=10.0, acceleration=10.0)

# Cross-type: target is a JointTarget, but a linear Cartesian move is requested.
# Forward kinematics is applied automatically.
my_robot.move_to_target("New Joint Target", move_type="l", velocity=100.0, acceleration=100.0)

move_to_target_async                

  • Description Moves the robot to a scene target identified by friendly name asynchronously. The move starts immediately and this method returns without waiting for completion. Call wait_for_motion_completion() to block until the robot finishes. See move_to_target for target resolution semantics.

  • Parameters

    • name

      • Description Friendly name of the scene target asset.

      • Type None

    • move_type

      • Description 'j' for a joint-space move, 'l' for a linear Cartesian move.

      • Type None

    • velocity

      • Description Move velocity. Units are deg/s for move_type='j', mm/s for move_type='l'.

      • Type float

    • acceleration

      • Description Move acceleration. Units are deg/s^2 for move_type='j', mm/s^2 for move_type='l'.

      • Type float

  • Raises

    • Type SceneException

    • Description If no scene target is found with the given name. Raised synchronously before execution starts.

    • Type RobotException

    • Description If forward/inverse kinematics fails during cross-type resolution, or if the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

my_robot.move_to_target_async("New Cartesian Target", move_type="l", velocity=100.0, acceleration=100.0)
print("Robot is moving asynchronously to the specified target.")
my_robot.wait_for_motion_completion()
print("Robot has finished moving to the specified target.")

move_until_tool_contact                

  • Description Move the robot until tool contact is detected or max travel is reached. This method executes a guarded linear movement. Motion stops when a force/torque threshold indicates contact, the max travel distance is reached, or the command fails.

  • Parameters

    • max_travel

      • Description Movement vector [x, y, z] in mm.

      • Type Vector

    • speed

      • Description Movement speed in mm/s.

      • Type MillimetersPerSecond

    • force_threshold

      • Description Force threshold in Newtons for contact detection.

      • Type float

    • reference_frame

      • Description Frame of reference for the movement; "tool", "robot_base", or user-defined. If user-defined, it should be the position of the reference frame in mm and degrees, where the angles are extrinsic Euler angles in XYZ order. Default "robot_base".

      • Type Literal["tool", "robot_base"] | CartesianPose

    • torque_threshold

      • Description Optional torque threshold in Nm for contact detection.

      • Type float | None

    • retract_distance

      • Description Optional distance in mm to retract after contact.

      • Type Millimeters | None

    • retract_speed

      • Description Optional speed in mm/s for retraction.

      • Type MillimetersPerSecond | None

  • Returns

    • Description A tuple of (contact_detected, pose) where: - contact_detected: True if contact was reached, False if max travel was reached. - pose: The CartesianPose at the point of contact or position at maximum travel (mm + degrees) where angles are extrinsic Euler angles in XYZ order.

    • Type tuple[bool, CartesianPose]

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

max_travel = [0.0, 0.0, -100.0]  # move 100mm in -Z direction
speed = 50.0  # millimeters per second
force_threshold = 10.0  # Newtons

# --- Synchronous usage ---
# --- Using robot base frame (default) ---
contact_detected, pose = my_robot.move_until_tool_contact(
    max_travel=[0.0, 0.0, -100.0],       # movement vector [x, y, z] in mm
    speed=50.0,                            # movement speed in mm/s
    force_threshold=10.0,                  # force threshold in Newtons
    torque_threshold=2.5,                  # torque threshold in N*m
    retract_distance=5.0,                  # retraction distance in mm after contact
    retract_speed=25.0,                    # retraction speed in mm/s
)

if contact_detected:
    print(f"Contact detected at pose: {pose}")
else:
    print(f"Max travel reached without contact, final pose: {pose}")

# --- Using tool frame ---
contact_detected, pose = my_robot.move_until_tool_contact(
    max_travel=[0.0, 0.0, -100.0],
    speed=50.0,
    force_threshold=10.0,
    reference_frame="tool",
)

# --- Using a user-defined reference frame [x, y, z, rx, ry, rz] in mm and degrees ---
custom_frame = [100.0, 200.0, 0.0, 0.0, 0.0, 45.0]
contact_detected, pose = my_robot.move_until_tool_contact(
    max_travel=[0.0, 0.0, -50.0],
    speed=25.0,
    force_threshold=5.0,
    reference_frame=custom_frame,
)

if contact_detected:
    print(f"Contact detected at pose: {pose}")
else:
    print(f"Max travel reached without contact, final pose: {pose}")

move_until_tool_contact_async                

  • Description Starts a move_until_tool_contact operation asynchronously and returns a result object. The move runs in the background. Use the returned result to check status or wait for completion::      move_result = robot.move_until_tool_contact_async(...)     contact_detected, pose = move_result.wait()

  • Parameters

    • max_travel

      • Description Movement vector [x, y, z] in mm.

      • Type Vector

    • speed

      • Description Movement speed in mm/s.

      • Type MillimetersPerSecond

    • force_threshold

      • Description Force threshold in Newtons for contact detection.

      • Type float

    • reference_frame

      • Description Frame of reference for the movement; "tool", "robot_base", or user-defined. If user-defined, it should be the position of the reference frame in mm and degrees, where the angles are extrinsic Euler angles in XYZ order. Default "robot_base".

      • Type Literal["tool", "robot_base"] | CartesianPose

    • torque_threshold

      • Description Optional torque threshold in Nm.

      • Type float | None

    • retract_distance

      • Description Optional retraction distance in mm.

      • Type Millimeters | None

    • retract_speed

      • Description Optional retraction speed in mm/s.

      • Type MillimetersPerSecond | None

  • Returns

  • Raises

    • Type RobotException

    • Description If the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

max_travel = [0.0, 0.0, -100.0]  # move 100mm in -Z direction
speed = 50.0  # millimeters per second
force_threshold = 10.0  # Newtons

# --- Asynchronous usage ---
move_result = my_robot.move_until_tool_contact_async(
    max_travel=max_travel,
    speed=speed,
    force_threshold=force_threshold,
)

print("Robot is probing asynchronously...")
print(f"Move running: {move_result.is_running()}, done: {move_result.is_done()}")

contact_detected, pose = move_result.wait()

if contact_detected:
    print(f"[async] Contact detected at pose: {pose}")
else:
    print(f"[async] Max travel reached without contact, final pose: {pose}")

movej                

  • Description Moves the robot to a specified joint position.

  • Parameters

    • target

      • Description The target joint angles, in degrees.

      • Type JointAnglesDegrees

    • velocity

      • Description The joint velocity to move at, in degrees per second.

      • Type DegreesPerSecond

    • acceleration

      • Description The joint acceleration to move at, in degrees per second squared.

      • Type DegreesPerSecondSquared

  • Raises

    • Type ValueError

    • Description If the target joint angles are invalid.

    • Type RobotException

    • Description If the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

joint_velocity = 10.0  # degrees per second
joint_acceleration = 10.0  # degrees per second squared

# Joint angles, in degrees
joint_angles = [
    86.0,  # j1
    0.0,  # j2
    88.0,  # j3
    0.0,  # j4
    91.0,  # j5
    0.0,  # j6
]

my_robot.movej(
    joint_angles,
    joint_velocity,
    joint_acceleration,
)

movej_async                

  • Description Moves the robot to a specified joint position asynchronously.

  • Parameters

    • target

      • Description The target joint angles, in degrees.

      • Type JointAnglesDegrees

    • velocity

      • Description The joint velocity to move at, in degrees per second.

      • Type DegreesPerSecond

    • acceleration

      • Description The joint acceleration to move at, in degrees per second squared.

      • Type DegreesPerSecondSquared

  • Raises

    • Type ValueError

    • Description If the target joint angles are invalid.

    • Type RobotException

    • Description If the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

joint_velocity = 10.0  # degrees per second
joint_acceleration = 10.0  # degrees per second squared

# Joint angles, in degrees
joint_angles = [
    86.0,  # j1
    0.0,  # j2
    88.0,  # j3
    0.0,  # j4
    91.0,  # j5
    0.0,  # j6
]

my_robot.movej_async(
    joint_angles,
    joint_velocity,
    joint_acceleration,
)
print("Robot is moving asynchronously to the specified joint angles.")
my_robot.wait_for_motion_completion()
print("Robot has finished moving to the specified joint angles.")

movel                

  • Description Moves the robot to a specified Cartesian position relative to the robot base, unless a specified reference frame is provided.

  • Parameters

    • target

      • Description The end effector's pose, in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

      • Type CartesianPose

    • velocity

      • Description The velocity to move at, in mm/s.

      • Type MillimetersPerSecond

    • acceleration

      • Description The acceleration to move at, in mm/s^2.

      • Type MillimetersPerSecondSquared

    • reference_frame

      • Description The reference frame to move relative to. If None, the robot's base frame is used.

      • Type Optional[CartesianPose]

  • Raises

    • Type ValueError

    • Description If the target Cartesian position is invalid.

    • Type RobotException

    • Description If the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

linear_velocity = 100.0  # millimeters per second
linear_acceleration = 100.0  # millimeters per second squared

# Target Cartesian pose, in millimeters and degrees
cartesian_pose = [
    -267.8,  # x in millimeters
    -89.2,  # y in millimeters
    277.4,  # z in millimeters
    -167.8,  # rx in degrees
    0,  # ry in degrees
    -77.8,  # rz in degrees
]

reference_frame = [
    23.56,  # x in millimeters
    -125.75,  # y in millimeters
    5.92,  # z in millimeters
    0.31,  # rx in degrees
    0.65,  # ry in degrees
    90.00,  # rz in degrees
]

my_robot.movel(
    cartesian_pose,
    linear_velocity,  # Optional
    linear_acceleration,  # Optional
    reference_frame,  # Optional
)

movel_async                

  • Description Moves the robot to a specified Cartesian position asynchronously.

  • Parameters

    • target

      • Description The end effector's pose, in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

      • Type CartesianPose

    • velocity

      • Description The velocity to move at, in mm/s.

      • Type MillimetersPerSecond

    • acceleration

      • Description The acceleration to move at, in mm/s^2.

      • Type MillimetersPerSecondSquared

    • reference_frame

      • Description The reference frame to move relative to. If None, the robot's base frame is used.

      • Type Optional[CartesianPose]

  • Raises

    • Type ValueError

    • Description If the target Cartesian position is invalid.

    • Type RobotException

    • Description If the move does not complete successfully.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

linear_velocity = 100.0  # millimeters per second
linear_acceleration = 100.0  # millimeters per second squared

# Target Cartesian pose, in millimeters and degrees
cartesian_pose = [
    -267.8,  # x in millimeters
    -89.2,  # y in millimeters
    277.4,  # z in millimeters
    -167.8,  # rx in degrees
    0,  # ry in degrees
    -77.8,  # rz in degrees
]

reference_frame = [
    23.56,  # x in millimeters
    -125.75,  # y in millimeters
    5.92,  # z in millimeters
    0.31,  # rx in degrees
    0.65,  # ry in degrees
    90.00,  # rz in degrees
]

my_robot.movel_async(
    cartesian_pose,
    linear_velocity,  # Optional
    linear_acceleration,  # Optional
    reference_frame,  # Optional
)
print("Robot is moving asynchronously to the specified Cartesian pose.")
my_robot.wait_for_motion_completion()
print("Robot has finished moving to the specified Cartesian pose.")

on_log_alarm                

  • Description Set one or multiple callbacks to the log alarm which replaces the default callback. If no callback is set, the default callback is used. Default callback raises a RobotException if the alarm is of severity error or critical.

  • Parameters

    • callback

      • Description A callback function to be called when a robot alarm is received.

      • Type Callable[[RobotAlarm], None]

  • Returns

    • Description The callback ID.

    • Type int

from machinelogic import Machine
from machinelogic.types import RobotAlarm

machine = Machine()
my_robot = machine.get_robot("Robot")


# The functon defined here is called when the specified alarm occurs
def handle_log_alarm(alarm: RobotAlarm):
    print(alarm.level, alarm.error_code, alarm.description)


my_robot.on_log_alarm(handle_log_alarm)

on_system_state_change                

  • Description Registers a callback for system state changes.

  • Parameters

    • callback

      • Description The callback function.

      • Type Callable[[OperationalState, RobotSafetyState], None]

  • Returns

    • Description The callback ID.

    • Type int

from machinelogic import Machine
from machinelogic.types import RobotOperationalState, RobotSafetyState

machine = Machine()
my_robot = machine.get_robot("Robot")


# The function defined here is called when the specified state change occurs
def handle_state_change(
    robot_operational_state: RobotOperationalState, safety_state: RobotSafetyState
):
    print(robot_operational_state, safety_state)


callback_id = my_robot.on_system_state_change(handle_state_change)
print(callback_id)

reconnect                

  • Description It will disconnect then reconnect the MachineMotion to the robot. This is useful when operating the robot near its reach limits or other potential constraints where errors may cause the robot to disconnect automatically. It also facilitates re-connection while your application is still running.

  • Parameters

    • timeout

      • Description The timeout in seconds, after which an exception will be thrown, default is 15 seconds.

      • Type Union[float, None]

  • Returns

    • Description True if successful.

    • Type bool

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# if no timeout argument is provided, the default timeout is 15 seconds
did_reconnect = my_robot.reconnect()
print(did_reconnect)

remove_log_alarm_callback                

  • Description Remove a previously registered log alarm callback.

  • Parameters

    • callback_id

      • Description The ID of the callback to remove.

      • Type int

from machinelogic import Machine, RobotAlarm

machine = Machine()
my_robot = machine.get_robot("Robot")


def handle_log_alarm(alarm: RobotAlarm):
    print(f"Alarm received: {alarm.level}, {alarm.error_code}, {alarm.description}")


callback_id = my_robot.on_log_alarm(handle_log_alarm)
print(f"Callback registered with ID: {callback_id}")

my_robot.remove_log_alarm_callback(callback_id)
print(f"Callback {callback_id} has been removed")

remove_system_state_change_callback                

  • Description Removes a previously registered system state change callback.

  • Parameters

    • callback_id

      • Description The ID of the callback to remove.

      • Type int

from machinelogic import Machine
from machinelogic.types import RobotOperationalState, RobotSafetyState

machine = Machine()
my_robot = machine.get_robot("Robot")

# The function defined here is called when the specified state change occurs
def handle_state_change(
    robot_operational_state: RobotOperationalState, safety_state: RobotSafetyState
):
    print(robot_operational_state, safety_state)


callback_id = my_robot.on_system_state_change(handle_state_change)
print(f"Callback registered with ID: {callback_id}")

my_robot.remove_system_state_change_callback(callback_id)
print(f"Callback {callback_id} has been removed")

reset                

  • Description Deprecated: Use set_to_normal() instead. Attempts to reset the robot to a normal operational state.

  • Returns

    • Description True if successful.

    • Type bool

set_active_tcp                

  • Description Sets the active tool center point (TCP) by name.

  • Parameters

    • tcp_name

      • Description The name of the TCP to set as active. Must be defined in the robot configuration.

      • Type str

  • Raises

    • Type RobotException

    • Description If the TCP name does not exist in the robot configuration.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Set a new active TCP by name
# Note: The TCP must be defined in your robot configuration
tcp_name = "gripper_tcp"  # Replace with your actual TCP name

my_robot.set_active_tcp(tcp_name)
print(f"Successfully set active TCP to: {tcp_name}")

# Verify the change
new_active_tcp = my_robot.state.active_tcp
print(f"New active TCP: {new_active_tcp}")

set_payload                

  • Description Sets the payload of the robot.

  • Parameters

    • payload

      • Description The payload, in kg.

      • Type Kilograms

    • center_of_mass

      • Description List of the center of mass, in mm [x, y, z].

      • Type Vector

    • inertia

      • Description List of the inertia tensor, in kg*mm^2 [ixx, ixy, ixz, iyy, iyz, izz]. Defaults to None.

      • Type Optional[Inertia]

  • Raises

    • Type ValueError

    • Description If the center of mass or inertia tensor are invalid.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Weight in Kilograms
weight = 2.76
my_robot.set_payload(weight, [10,10,10])

print("Robot set payload was successful")

set_tcp_offset                

  • Description Deprecated: Use set_active_tcp() instead. Sets the tool center point offset in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

  • Parameters

    • tcp_offset

      • Description The tool center point (TCP) offset, in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

      • Type CartesianPose

  • Returns

    • Description True if the TCP offset was successfully set, False otherwise.

    • Type bool

set_to_freedrive                

  • Description Put the robot into freedrive mode. To exit freedrive mode, use set_to_normal() which will return the robot to normal operational state.

  • Raises

    • Type RobotException

    • Description If the robot fails to set to freedrive mode.

import time

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")


# Put the robot in free drive mode
my_robot.set_to_freedrive()

time.sleep(5)

print(my_robot.state.operational_state)

time.sleep(1)

# Set the robot to normal operational state
my_robot.set_to_normal()

time.sleep(1)

print(my_robot.state.operational_state)

set_to_normal                

  • Description Set the robot to normal operational state.

  • Raises

    • Type RobotException

    • Description If the robot fails to set to normal operational state.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Set the robot to normal operational state
# This is useful after freedrive mode or other non-standard states
my_robot.set_to_normal()

# Robot state should be 'Normal'
print(my_robot.state.operational_state)

wait_for_motion_completion                

  • Description Waits for the robot to complete its current motion. Used in asynchronous movements.

  • Raises

    • Type RobotException

    • Description If the request fails or the move did not complete in the allocated amount of time.

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

joint_velocity = 10.0  # degrees per second
joint_acceleration = 10.0  # degrees per second squared

# Joint angles, in degrees
joint_angles = [
    86.0,  # j1
    0.0,  # j2
    88.0,  # j3
    0.0,  # j4
    91.0,  # j5
    0.0,  # j6
]

my_robot.movej_async(
    joint_angles,
    joint_velocity,
    joint_acceleration,
)
print("Robot is moving asynchronously to the specified joint angles.")
my_robot.wait_for_motion_completion()
print("Robot has finished moving to the specified joint angles.")

RobotState

A representation of the robot current state.

active_tcp                

  • Description The name of the currently active tool center point (TCP).

  • Type str | None

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Get the name of the currently active TCP
active_tcp_name = my_robot.state.active_tcp
print(f"Active TCP: {active_tcp_name}")

cartesian_position_data                

  • Description          A tuple of the robot current Cartesian position and the timestamp as a datetime object.        

  • Type Tuple[CartesianPose, datetime]

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

end_effector_pose, timestamp = my_robot.state.cartesian_position_data

end_effector_position_mm = end_effector_pose[:3]
end_effector_orientation_euler_xyz_deg = end_effector_pose[-3:]

print(f"End effector's pose: {end_effector_pose}")
print(f"End effector's Cartesian position: {end_effector_position_mm}")
print(f"End effector's Euler XYZ orientation: {end_effector_orientation_euler_xyz_deg}")

print(f"Timestamp: {timestamp.isoformat()}")

joint_angles_data                

  • Description          A tuple of the robot current joint angles and the timestamp as a datetime object.        

  • Type Tuple[JointAnglesDegrees, datetime]

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

joint_angles, timestamp = my_robot.state.joint_angles_data

print(f"Joint angles: {joint_angles}")
print(f"Timestamp: {timestamp.isoformat()}")

move_in_progress                

  • Description Check if the robot is currently moving.

  • Type bool

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")
print(my_robot.state.move_in_progress)

operational_state                

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")
print(my_robot.state.operational_state)

safety_state                

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")
print(my_robot.state.safety_state)

tcp_offset                

  • Description The tool center point (TCP) offset, in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

  • Type CartesianPose

from machinelogic import Machine

machine = Machine()
my_robot = machine.get_robot("Robot")

# Get the current TCP offset
current_tcp_offset = my_robot.state.tcp_offset
tcp_position_mm = current_tcp_offset[:3]
tcp_orientation_euler_xyz_deg = current_tcp_offset[3:]

print(f"Current TCP offset: {current_tcp_offset}")
print(f"TCP position offset (mm): {tcp_position_mm}")
print(f"TCP orientation offset (degrees): {tcp_orientation_euler_xyz_deg}")

RobotAlarm

A representation of the robot alarm.

description                

  • Description The description of the alarm.

  • Type str

error_code                

  • Description The error code of the alarm.

  • Type int

level                

  • Description The severity level of the alarm.         UNKNOWN = 0         INFO = 1         WARNING = 2         ERROR = 3         CRITICAL = 4        

  • Type RobotAlarmLevel

timestamp                

  • Description The timestamp of the alarm.

  • Type datetime

RobotAlarmLevel

Description: An enumeration.

  • UNKNOWN= 0

  • INFO= 1

  • WARNING= 2

  • ERROR= 3

  • CRITICAL= 4

RobotMoveSequence

A class representing a sequence of robot movements. This class allows you to build up a sequence of joint and linear movements that can be executed together with blending. Supports method chaining for a fluent API.

Example Usage:


# Can be used in two ways:

# 1. Manual execution (explicit control):
    seq = robot.create_sequence()
    seq.append_movej([0, 0, 0, 0, 0, 0])
    seq.append_movel([100, 100, 100, 0, 0, 0])
    robot.execute_sequence(seq)

# 2. Context manager (auto-execution on exit):
    with robot.create_sequence() as seq:
        seq.append_movej([0, 0, 0, 0, 0, 0])
        seq.append_movel([100, 100, 100, 0, 0, 0])
    # Executes automatically when context exits

# Optional: Async execution:
    with robot.create_sequence().execute_async_on_exit() as seq:
        seq.append_movej([0, 0, 0, 0, 0, 0])
    # Executes asynchronously when context exits

append_move_to_target                

  • Description Append a move to a scene target identified by friendly name. The named target is resolved against the scene at call time. The first matching target is used; a warning is logged if multiple targets share the same name.

  • Parameters

    • name

      • Description Friendly name of the scene target asset.

      • Type None

    • move_type

      • Description 'j' for a joint-space move, 'l' for a linear Cartesian move.

      • Type None

    • velocity

      • Description Move velocity. Units are deg/s for move_type='j', mm/s for move_type='l'.

      • Type float

    • acceleration

      • Description Move acceleration. Units are deg/s^2 for move_type='j', mm/s^2 for move_type='l'.

      • Type float

    • blend_radius

      • Description Optional blend radius in mm for smooth transitions to the next move. None means no blending.

      • Type Millimeters | None

  • Returns

    • Description Self for method chaining.

    • Type None

  • Raises

    • Type ValueError

    • Description If the sequence has no robot reference (and therefore no scene to resolve names against).

    • Type SceneException

    • Description If no scene target is found with the given name.

    • Type RobotException

    • Description If the move does not complete successfully.

append_movej                

  • Description Append a joint move to the sequence.

  • Parameters

    • target

      • Description A list of 6 target joint angles in degrees.

      • Type None

    • velocity

      • Description Joint velocity in degrees per second

      • Type None

    • acceleration

      • Description Joint acceleration in degrees per second squared

      • Type None

    • blend_radius

      • Description Blend radius in millimeters for smooth transitions between moves. If None, the robot controller will use its default behavior (no blending).

      • Type None

  • Returns

    • Description Self for method chaining

    • Type None

append_movel                

  • Description Append a linear (Cartesian) move to the sequence.

  • Parameters

    • target

      • Description Target Cartesian pose [x, y, z, rx, ry, rz] in mm and degrees

      • Type None

    • velocity

      • Description Linear velocity in millimeters per second

      • Type None

    • acceleration

      • Description Linear acceleration in millimeters per second squared

      • Type None

    • blend_radius

      • Description Blend radius in millimeters for smooth transitions between moves. If None, the robot controller will use its default behavior (no blending).

      • Type None

    • reference_frame

      • Description Optional reference frame for the target pose. If None, uses robot base frame.

      • Type None

  • Returns

    • Description Self for method chaining

    • Type None

execute_async_on_exit                

  • Description Mark this sequence for asynchronous execution when used as a context manager. This method only affects behavior when the sequence is used with a context manager. When the context exits, the sequence will be executed asynchronously (non-blocking).

  • Returns

    • Description Self for method chaining

    • Type None

MoveUntilToolContactResult

Result of an async move_until_tool_contact operation.

is_done                

  • Description Return True if the move has completed (with result or exception).

is_running                

  • Description Return True if the move is currently executing.

wait                

  • Description Block until the move completes and return the result.

  • Parameters

    • timeout

      • Description Max seconds to wait. None means wait indefinitely.

      • Type None

  • Returns

    • Description (contact_detected, pose).

    • Type tuple[bool, CartesianPose]

  • Raises

    • Type TimeoutError

    • Description If timeout is reached.

RobotOperationalState

Description: An enumeration.

  • UNKNOWN= 0

  • IDLE= 1

  • RUNNING= 2

  • JOGGING= 3

  • FREEDRIVE= 4

  • STOPPING= 5

  • NON_OPERATIONAL= 6

  • MOVE_UNTIL= 7

RobotSafetyState

Description: An enumeration.

  • UNKNOWN= 0

  • NORMAL= 1

  • EMERGENCY_STOP= 2

  • REDUCED_SPEED= 3

  • RECOVERABLE_FAULT= 4

GenericJointConstraint

A representation of a generic joint constraint. To be used within the compute_inverse_kinematics method of a robot.

joint_index                

  • Description The 1-based index of the robot joint

  • Type int

max_position                

  • Description The maximum position a joint can reach

  • Type float

min_position                

  • Description The mininum position a joint can reach

  • Type float

DigitalInput

A software representation of an DigitalInput. It is not recommended that you construct this object yourself. Rather, you should query it from a Machine instance. DigitalInput peripherals can be connected to the controller via the following devices: - IO Module - Push Button Module - Conveyor Motor

configuration                

state                

  • Description          The state of the DigitalInput.        

  • Type DigitalInputState

from machinelogic import Machine

machine = Machine()

# Get input by friendly name
# Input peripherals can be connected to the controller via the following devices:
#  - IO Module
#  - Push Button Module
#  - Conveyor Motor

my_input = machine.get_input("Input")

if my_input.state.value:
    print(f"{my_input.configuration.name} is HIGH")
else:
    print(f"{my_input.configuration.name} is LOW")

print("Timestamp: ", my_input.state.timestamp)

on_state_change                

  • Description Adds a change listener to execute when the DigitalInput state changes.

  • Parameters

    • callback

      • Description The callback to be called when the DigitalInput state changes. The first argument is the new value and the second argument is the DigitalInput itself.

      • Type Callable[[bool, DigitalInput], None]

import time

from machinelogic import Machine

machine = Machine()

# We are assuming here that New DigitalInput is in the MachineLogic configuration
my_input = machine.get_input("Input")


# this "callback" function will be called every time the digital input value changes.
def on_input_state_change(value, digital_input):
    if value:
        print("input value is now HIGH")
    else:
        print("input value is now LOW")


my_input.on_state_change(on_input_state_change)

while True:
    # ...
    time.sleep(1)

DigitalInputState

Representation of the current state of an DigitalInput/DigitalOutput instance.

timestamp                

  • Description          Timestamp of the last state update.         Returns None if no update has been received yet.        

  • Type typing.Optional[datetime.datetime]

value                

  • Description          The current value of the IO pin. True means high, while False means low. This is different from         active/inactive, which depends on the active_high configuration.        

  • Type bool

DigitalInputConfiguration

Representation of the configuration of an DigitalInput/DigitalOutput. This configuration is established by the configuration page in MachineLogic.

active_high                

  • Description The value that needs to be set to consider the DigitalInput/DigitalOutput as active.

  • Type bool

controller_id                

  • Description The MachineMotion controller id of the DigitalInput/DigitalOutput.

  • Type str

controller_port                

  • Description The MachineMotion controller port of the device that the DigitalInput/DigitalOutput is connected to.

  • Type int

device_id                

  • Description The device number of the device that the DigitalInput/DigitalOutput is connected to.

  • Type int

device_type                

  • Description The device type string (e.g. 'digitalIOModule', 'pushButtonModule', 'powerSwitchModule', 'motor').

  • Type str

name                

  • Description The name of the DigitalInput/DigitalOutput.

  • Type str

pin                

  • Description The pin number or letter of the DigitalInput/DigitalOutput.

  • Type typing.Union[int, typing.Literal['A', 'B']]

uuid                

  • Description The unique ID of the DigitalInput/DigitalOutput.

  • Type str

DigitalOutput

A software representation of an Output. It is not recommended that you construct this object yourself. Rather, you should query it from a Machine instance.

configuration                

write                

  • Description Writes the value into the Output, with True being high and False being low.

  • Parameters

    • value

      • Description The value to write to the Output.

      • Type bool

from machinelogic import Machine

machine = Machine()
my_output = machine.get_output("Output")

my_output.write(True)  # Write "true" to the Output
my_output.write(False)  # Write "false" to the Output

DigitalOutputConfiguration

Representation of the configuration of an DigitalInput/DigitalOutput. This configuration is established by the configuration page in MachineLogic.

active_high                

  • Description The value that needs to be set to consider the DigitalInput/DigitalOutput as active.

  • Type bool

controller_id                

  • Description The MachineMotion controller id of the DigitalInput/DigitalOutput.

  • Type str

controller_port                

  • Description The MachineMotion controller port of the device that the DigitalInput/DigitalOutput is connected to.

  • Type int

device_id                

  • Description The device number of the device that the DigitalInput/DigitalOutput is connected to.

  • Type int

device_type                

  • Description The device type string (e.g. 'digitalIOModule', 'pushButtonModule', 'powerSwitchModule', 'motor').

  • Type str

name                

  • Description The name of the DigitalInput/DigitalOutput.

  • Type str

pin                

  • Description The pin number or letter of the DigitalInput/DigitalOutput.

  • Type typing.Union[int, typing.Literal['A', 'B']]

uuid                

  • Description The unique ID of the DigitalInput/DigitalOutput.

  • Type str

Pneumatic

A software representation of a Pneumatic. It is not recommended that you construct this object yourself. Rather, you should query it from a Machine instance:

E.g.:


machine = Machine()
my_pneumatic = machine.get_pneumatic("Pneumatic")

In this example, "Pneumatic" is the friendly name assigned to a Pneumatic in the MachineLogic configuration page.

configuration                

state                

  • Description          The state of the actuator.        

  • Type typing.Literal['pushed', 'pulled', 'transition', 'unknown']

idle_async                

  • Description Idles the Pneumatic.

  • Raises

    • Type PneumaticException

    • Description If the idle was unsuccessful.

pull_async                

  • Description Pulls the Pneumatic.

  • Raises

    • Type PneumaticException

    • Description If the pull was unsuccessful.

push_async                

  • Description Pushes the Pneumatic.

  • Raises

    • Type PneumaticException

    • Description If the push was unsuccessful.

PneumaticConfiguration

Representation of a Pneumatic configuration.

controller_id                

  • Description The MachineMotion controller id.

  • Type str

controller_port                

  • Description The MachineMotion controller port of the io module that controls the pneumatic axis.

  • Type int

device_id                

  • Description The device id of the io module that controls the pneumatic axis.

  • Type int

input_pin_pull                

  • Description The optional pull in pin.

  • Type typing.Optional[int]

input_pin_push                

  • Description The optional push in pin.

  • Type typing.Optional[int]

name                

  • Description The name of the Pneumatic.

  • Type str

output_pin_pull                

  • Description The pull out pin of the axis.

  • Type int

output_pin_push                

  • Description The push out pin of the axis.

  • Type int

uuid                

  • Description The ID of the Pneumatic.

  • Type str

ACMotor

A software representation of an AC Motor. It is not recommended that you construct this object yourself. Rather, you should query it from a Machine instance:

E.g.:


machine = Machine()
my_ac_motor = machine.get_ac_motor("AC Motor")

In this example, "AC Motor" is the friendly name assigned to an AC Motor in the MachineLogic configuration page.

configuration                

move_forward                

  • Description Begins moving the AC Motor forward.

  • Raises

    • Type ACMotorException

    • Description If the move was unsuccessful.

from time import sleep

from machinelogic import Machine

machine = Machine()
my_ac_motor = machine.get_ac_motor("AC Motor")

my_ac_motor.move_forward()
sleep(10)
my_ac_motor.stop()

move_reverse                

  • Description Begins moving the AC Motor in reverse.

  • Raises

    • Type ACMotorException

    • Description If the move was unsuccessful.

import time

from machinelogic import Machine

machine = Machine()
my_ac_motor = machine.get_ac_motor("AC Motor")

# Move the AC motor in reverse
my_ac_motor.move_reverse()

# The AC motor will stop moving if the program terminates
time.sleep(10)

stop                

  • Description Stops the movement of the AC Motor.

  • Raises

    • Type ACMotorException

    • Description If the stop was unsuccessful.

import time

from machinelogic import Machine

machine = Machine()

my_ac_motor = machine.get_ac_motor("AC Motor")

# Move the AC Motor forwards
my_ac_motor.move_forward()

# Do something here
time.sleep(10)

my_ac_motor.stop()

ACMotorConfiguration

Representation of a ACMotor configuration.

controller_id                

  • Description The MachineMotion controller id

  • Type str

controller_port                

  • Description The MachineMotion controller port of the io module that controls the ac_motor.

  • Type int

device_id                

  • Description The device id of the io module of the ac_motor.

  • Type int

name                

  • Description The name of the Pneumatic.

  • Type str

output_pin_direction                

  • Description The push out pin of the axis.

  • Type typing.Optional[int]

output_pin_move                

  • Description The pull out pin of the axis.

  • Type int

uuid                

  • Description The ID of the Pneumatic.

  • Type str

Scene

A software representation of the scene containing assets that describe and define reference frames and targets for robots.

Only a single instance of this object should exist in your program.

get_calibration_frame                

  • Description Gets a calibration frame from scene assets by name

  • Parameters

    • name

      • Description Friendly name of the calibration frame asset

      • Type str

  • Raises

    • Type SceneException

    • Description If the scene asset is not found

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a calibration frame defined
# in Scene Assets called "New Calibration Frame"
calibration_frame = scene.get_calibration_frame("New Calibration Frame")

default_value = calibration_frame.get_default_value()

print(default_value)

get_cartesian_target                

  • Description Gets a cartesian target from scene assets by name

  • Parameters

    • name

      • Description Friendly name of the cartesian target asset

      • Type str

  • Raises

    • Type SceneException

    • Description If the scene asset is not found

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a cartesian target defined
# in Scene Assets called "New Cartesian Target"
cartesian_target = scene.get_cartesian_target("New Cartesian Target")

# Use the cartesian target instance to get the position relative to its parent reference frame.
# Note: see the get_position example in the CartesianTarget class documentation for
# more details on the get_position method.
default_position = cartesian_target.get_position()

print(default_position)

get_joint_target                

  • Description Gets a joint target from scene assets by name

  • Parameters

    • name

      • Description Friendly name of the joint target asset

      • Type str

  • Returns

  • Raises

    • Type SceneException

    • Description If the scene asset is not found

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a joint target defined
# in Scene Assets called "New Joint Target"
joint_target = scene.get_joint_target("New Joint Target")

joint_angles = joint_target.get_joint_angles()

print(joint_angles)

get_reference_frame                

  • Description Gets a reference frame from scene assets by name

  • Parameters

    • name

      • Description Friendly name of the reference frame asset

      • Type str

  • Raises

    • Type SceneException

    • Description If the scene asset is not found

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a reference frame defined
# in Scene Assets called "New Reference Frame"
reference_frame = scene.get_reference_frame("New Reference Frame")

# Use the reference frame instance to get its position relative to its parent reference frame.
# Note: see the get_position example in the ReferenceFrame class documentation for
# more details on the get_position method.
default_position = reference_frame.get_position()

print(default_position)

CalibrationFrame

A calibration frame, as defined in the scene assets pane, is represented in software. It is measured in millimeters and degrees, with angles given as extrinsic Euler angles in XYZ order.

get_calibrated_value                

  • Description Gets the calibration frame's calibrated values. Returns None until the frame has been calibrated at runtime (for example by a camera calibration routine or by set_calibrated_value). Always fall back to the nominal value when no calibration exists:      pose = frame.get_calibrated_value() or frame.get_default_value()  Passing the result of get_calibrated_value() directly into a robot move is not recommended: if the frame has not been calibrated the value is None and the move will fail.

  • Returns

    • Description The calibrated value of the calibration frame in mm and degrees, where the angles are extrinsic Euler angles in XYZ order, or None if the frame has not been calibrated.

    • Type Union[CartesianPose, None]

  • Raises

    • Type SceneException

    • Description If failed to get the calibrated value

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a calibration frame defined
# in Scene Assets called "New Calibration Frame"
calibration_frame = scene.get_calibration_frame("New Calibration Frame")

calibrated_value = calibration_frame.get_calibrated_value()

print(calibrated_value)

get_default_value                

  • Description Gets the calibration frame's default (nominal) value, as defined in the scene. This value is always available and is the safe fallback when get_calibrated_value() returns None.

  • Returns

    • Description The nominal value of the calibration frame in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

    • Type CartesianPose

  • Raises

    • Type SceneException

    • Description If failed to get the default value

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a calibration frame defined
# in Scene Assets called "New Calibration Frame"
calibration_frame = scene.get_calibration_frame("New Calibration Frame")

default_value = calibration_frame.get_default_value()

print(default_value)

set_calibrated_value                

  • Description Sets the calibration frame's calibrated values.

  • Parameters

    • frame

      • Description The calibrated values of the Calibration Frame in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

      • Type CartesionPose

  • Raises

    • Type SceneException

    • Description If failed to set the calibrated value

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a calibration frame defined
# in Scene Assets called "New Calibration Frame"
calibration_frame = scene.get_calibration_frame("New Calibration Frame")

# CartesianPose in mm and degrees, where the angles are
# extrinsic Euler angles in XYZ order.
calibrated_cartesian_pose = [100, 100, 50, 90, 90, 0]

calibration_frame.set_calibrated_value(calibrated_cartesian_pose)

ReferenceFrame

A reference frame, as defined in the scene assets pane, is represented in software. It is measured in millimeters and degrees, with angles given as extrinsic Euler angles in XYZ order.

get_position                

  • Description Gets the reference frame's position. If the reference frame underwhich the position is requested is calibrated, the position is returned in the calibrated reference frame's position.

  • Parameters

    • relative_to

      • Description The reference frame's position relative to the robot base or its parent reference frame. Defaults to "parent".

      • Type Literal["robot_base", "parent"]

  • Returns

    • Description The position of the reference frame in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

    • Type CartesianPose

  • Raises

    • Type SceneException

    • Description If failed to get the position

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a reference frame defined
# in Scene Assets called "New Reference Frame"
reference_frame = scene.get_reference_frame("New Reference Frame")

# You can specify the relative_to parameter to get the position
# relative its "parent" frame or the "robot_base" frame. Default is "parent".
reference_frame_wrt_parent = reference_frame.get_position(relative_to="parent")
print(reference_frame_wrt_parent)

reference_frame_wrt_robot_base = reference_frame.get_position(relative_to="robot_base")
print(reference_frame_wrt_robot_base)

CartesianTarget

A cartesian target, as defined in the scene assets pane, is represented in software. It is measured in millimeters and degrees, with angles given as extrinsic Euler angles in XYZ order.

get_position                

  • Description Gets the cartesian target's pose values. If the reference frame underwich the position is requested is calibrated, the position is returned in the calibrated reference frame's position.

  • Parameters

    • relative_to

      • Description The reference frame to which the position is relative. Defaults to "parent".

      • Type Literal["robot_base", "parent"]

  • Returns

    • Description The pose of the cartesian target in mm and degrees, where the angles are extrinsic Euler angles in XYZ order.

    • Type CartesianPose

  • Raises

    • Type SceneException

    • Description If failed to get the default value

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a cartesian target defined
# in Scene Assets called "New Cartesian Target"
cartesian_target = scene.get_cartesian_target("New Cartesian Target")

# You can specify the relative_to parameter to get the position
# relative its "parent" frame or the "robot_base" frame. Default is "parent".
cartesian_target_wrt_parent = cartesian_target.get_position(relative_to="parent")
print(cartesian_target_wrt_parent)

cartesian_target_wrt_robot_base = cartesian_target.get_position(
    relative_to="robot_base"
)
print(cartesian_target_wrt_robot_base)

# Important: In order to move to the position obtained from the Cartesian Target, you must use the
# value obtained from the position relative to the robot_base:
my_robot = machine.get_robot("Robot")
my_robot.movel(cartesian_target_wrt_robot_base)

JointTarget

A joint target is a representation of a target position for a robot's joints. It is defined by the joint angles in degrees.

get_joint_angles                

  • Description Gets the joint target's default values.

  • Returns

    • Description The nominal value of the joint target in degrees.

    • Type JointAnglesDegrees [j1_deg, j2_deg, j3_deg, j4_deg, j5_deg, j6_deg]

  • Raises

    • Type SceneException

    • Description If failed to get the default value

from machinelogic import Machine

machine = Machine()
scene = machine.get_scene()

# Assuming we have a joint target defined
# in Scene Assets called "New Joint Target"
joint_target = scene.get_joint_target("New Joint Target")

joint_angles = joint_target.get_joint_angles()

print(joint_angles)

ActuatorException

An exception thrown by an Actuator

Args:


VentionException (VentionException): Super class

with_traceback                

  • Description Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

MachineException

An exception thrown by the Machine

Args:


Exception (VentionException): Super class

with_traceback                

  • Description Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

RobotException

An exception thrown by a Robot

Args:


VentionException (VentionException): Super class

with_traceback                

  • Description Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

MachineMotionException

An exeption thrown by a MachineMotion

Args:


VentionException (VentionException): Super class

with_traceback                

  • Description Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

DigitalInputException

An exception thrown by an INput

Args:


VentionException (VentionException): Super class

with_traceback                

  • Description Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

DigitalOutputException

An exception thrown by an Output

Args:


VentionException (VentionException): Super class

with_traceback                

  • Description Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

ActuatorGroupException

An exception thrown by an ActuatorGroup

Args:


VentionException (VentionException): Super class

with_traceback                

  • Description Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.