MachineLogic Python Programming v1.0
Python limitations in MachineLogic
When executing your Python code in simulation, the script will run in a restricted environment to avoid abuses. Only a few Modules are allowed and some Built-in Functions are not available.
The following Built-in Functions are currently restricted in simulation.
- compile
- dir
- eval
- exec
- globals
- input
- locals
- memoryview
- object
- open
- vars
The following Modules are allowed in simulation.
- machinelogic
- time
- math
- copy
- json
- abc
- random
- numpy
Motion Features
When the Python program ends, any motion that is still executing will continue their execution. If you want to wait for a motion to complete, you should call:
actuator.wait_for_move_completion()
Asynchronous moves will not wait for the motion to complete before terminating the program.
The ‘continuous_move’ function will run forever if not stopped by the program.
MachineLogic Python Programming v1.0 Interface
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, bag grippers, 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, you can simply write:
machine = Machine()
You should only ever have a single instance of this object in your program.
-
Description Retrieves an AC Motor by name.
-
Parameters
-
name
- Description The name of the AC Motor.
- Type str
-
name
-
Returns
- Description The AC Motor that was found.
- Type IACMotor
-
Raises
-
Type MachineMotionException
- Description If it is not found.
-
Type MachineMotionException
-
Parameters
-
Description Retrieves an Actuator by name.
-
Parameters
-
name
- Description The name of the Actuator.
- Type str
-
name
-
Returns
- Description The Actuator that was found.
- Type IActuator
-
Raises
-
Type MachineException
- Description If we cannot find the Actuator.
-
Type MachineException
-
Parameters
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
# Always home the actuator before starting to ensure position is properly calibrated.
actuator.home(timeout=10)
start_position = actuator.state.position
print("starting at position:", start_position)
target_distance = 150.0 # mm
actuator.move_relative(
distance=target_distance,
timeout=10, # seconds
)
# first_move_end_position is approx. equal to start_position + target_distance.
first_move_end_position = actuator.state.position
print("first move finished at position:", first_move_end_position)
# move back to starting position
target_distance = -1 * target_distance
actuator.move_relative(
distance=target_distance,
timeout=10, # seconds
)
# approx. equal to start_position,
end_position = actuator.state.position
print("finshed back at position:", end_position)
-
Description Retrieves a Bag Gripper by name.
-
Parameters
-
name
- Description The name of the Bag Gripper
- Type str
-
name
-
Returns
- Description The Bag Gripper that was found.
- Type IBagGripper
-
Raises
-
Type MachineMotionException
- Description If it is not found.
-
Type MachineMotionException
-
Parameters
from machinelogic import Machine, MachineException
machine = Machine()
try:
bag_gripper = machine.get_bag_gripper(
"New bag gripper"
) # Returns the bag gripper or throws
# ...Use the bag gripper here
# Open the bag gripper
bag_gripper.open_async()
except MachineException as err:
print(f"Failed to find bag gripper with name 'New bag gripper'. Reason: {str(err)}")
-
Description Retrieves an DigitalInput by name.
-
Parameters
-
name
- Description The name of the DigitalInput.
- Type str
-
name
-
Returns
- Description The DigitalInput that was found.
- Type IDigitalInput
-
Raises
-
Type MachineException
- Description If we cannot find the DigitalInput.
-
Type MachineException
-
Parameters
from machinelogic import Machine
machine = Machine()
# We are assuming here that New DigitalInput is in the MachineLogic configuration
input1 = machine.get_input("New DigitalInput")
if input1.state.value() == True:
print("input1 is HIGH")
else:
print("input1 is LOW")
-
Description Retrieves an IMachineMotion instance by name.
-
Parameters
-
name
- Description The name of the MachineMotion.
- Type str
-
name
-
Returns
- Description The MachineMotion that was found.
- Type IMachineMotion
-
Raises
-
Type MachineException
- Description If we cannot find the MachineMotion.
-
Type MachineException
-
Parameters
from machinelogic import Machine, MachineException
machine = Machine()
machine_motion = machine.get_machine_motion("Controller #1")
configuration = machine_motion.configuration
print("Name:", configuration.name)
print("IP Address:", configuration.ip_address)
-
Description Retrieves an Output by name.
-
Parameters
-
name
- Description The name of the Output
- Type str
-
name
-
Returns
- Description The Output that was found.
- Type IOutput
-
Raises
-
Type MachineException
- Description If we cannot find the Output.
-
Type MachineException
-
Parameters
from machinelogic import DigitalOutputException, Machine, MachineException
machine = Machine()
output1 = machine.get_output("New Output")
output1.write(True) # Write "true" to the Output
output1.write(False) # Write "false" to the Output
-
Description Retrieves a Pneumatic by name.
-
Parameters
-
name
- Description The name of the Pneumatic.
- Type str
-
name
-
Returns
- Description The Pneumatic that was found.
- Type IPneumatic
-
Raises
-
Type MachineException
- Description If we cannot find the Pneumatic.
-
Type MachineException
-
Parameters
from machinelogic import Machine
from time import sleep
machine = Machine()
pneumatic1 = machine.get_pneumatic("Pneumatic #1")
# Idle
pneumatic1.idle_async()
sleep(1)
# Push
pneumatic1.push_async()
sleep(1)
# Pull
pneumatic1.pull_async()
sleep(1)
-
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
-
Description The Robot name. If it’s
-
name
-
Returns
- Description The Robot that was found.
- Type IRobot
-
Raises
-
Type MachineException
- Description If the Robot is not found.
-
Type MachineException
-
Parameters
-
Description Attach a callback function to an MQTT topic.
-
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.
- Type Union[Callable[[str, str], None], None]
-
topic
-
Parameters
from machinelogic import Machine
from time import sleep
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)
machine.on_mqtt_event(my_event_topic, event_callback)
machine.publish_mqtt_event(my_event_topic, "my message")
sleep(2)
machine.on_mqtt_event(my_event_topic, None) # remove the callback.
-
Description Publish an MQTT event.
-
Parameters
-
topic
- Description Topic to publish.
- Type str
-
message
- Description Optional message.
- Type Optional[str]
- Default None
-
topic
-
Parameters
import time
from machinelogic import Machine
machine = Machine()
my_controller__1 = machine.get_machine_motion("Controller #1")
my_new_actuator = my_controller__1.get_actuator("New actuator")
while True:
machine.publish_mqtt_event(
"application/cycle-start",
"{'applicationId':'e3f32b06-82ca-4f9a-b2a4-3bd6f96c9017', \
'cycleId':'default'}",
)
print("Cycle Start")
time.sleep(5)
machine.publish_mqtt_event(
"application/cycle-end",
"{'applicationId':'e3f32b06-82ca-4f9a-b2a4-3bd6f96c9017', \
'cycleId':'default'}",
)
time.sleep(1)
print("Cycle end")
MachineMotion
A software representation of a MachineMotion controller. The MachineMotion is comprised of many actuators, inputs, outputs, pneumatics, ac motors, and bag grippers. 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 intance to provide you with a list of the available MachineMotions.
- Description MachineMotionConfiguration: The representation of the configuraiton associated with this MachineMotion.
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()
actuator = machine.get_actuator("New actuator")
In this example, “New actuator” is the friendly name assigned to the Actuator in the MachineLogic configuration page.
- Description ActuatorConfiguration: The representation of the configuration associated with this MachineMotion.
-
Description Home the Actuator synchronously.
-
Parameters
-
timeout
- Description The timeout in seconds.
- Type float
-
timeout
-
Raises
-
Type ActuatorException
- Description If the home was unsuccessful or request timed out.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
actuator.home(timeout=10)
-
Description Locks the brakes on this Actuator.
-
Raises
-
Type ActuatorException
- Description If the brakes failed to lock.
-
Type ActuatorException
-
Raises
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
actuator.unlock_brakes()
# Home the actuator before starting to ensure position is properly calibrated
actuator.home(timeout=10)
actuator.move_relative(distance=100.0)
actuator.lock_brakes()
# This move will fail because the brakes are now locked.
actuator.move_relative(distance=-100.0)
-
Description Moves absolute synchronously to the specified position.
-
Parameters
-
position
- Description The position to move to.
- Type float
-
timeout
- Description The timeout in seconds.
- Type float
-
position
-
Raises
-
Type ActuatorException
- Description If the move was unsuccessful.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
# Always home the actuator before starting to ensure position is properly calibrated.
actuator.home(timeout=10)
actuator.move_absolute(
position=150.0, # millimeters
timeout=10, # seconds
)
-
Description Moves absolute asynchronously.
-
Parameters
-
position
- Description The position to move to.
- Type float
-
position
-
Raises
-
Type ActuatorException
- Description If the move was unsuccessful.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
from time import sleep
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
# Always home the actuator before starting to ensure position is properly calibrated.
actuator.home(timeout=10)
target_position = 150.0 # millimeters
# move_*_async will start the move and return without waiting for the move to complete.
actuator.move_absolute_async(target_position)
while actuator.state.move_in_progress:
print("move is in progress...")
sleep(1)
# end_position will be approx. equal to target_position.
end_position = actuator.state.position
print("finished at position", end_position)
-
Description Starts a continuous move. The Actuator will keep moving until it is stopped.
-
Parameters
-
speed
- Description The speed to move with.
- Type float
- Default 100.0
-
acceleration
- Description The acceleration to move with.
- Type float
- Default 100.0
-
speed
-
Raises
-
Type ActuatorException
- Description If the move was unsuccessful.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
from time import sleep
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
# Always home the actuator before starting to ensure position is properly calibrated.
actuator.home(timeout=10)
target_speed = 100.0 # mm/s
target_acceleration = 500.0 # mm/s^2
target_decceleration = 600.0 # mm/s^2
# move_*_async will start the move and return without waiting for the move to complete.
actuator.move_continuous_async(target_speed, target_acceleration)
sleep(10) # move continuously for ~10 seconds.
actuator.stop(target_decceleration) # deccelerate to stopped.
-
Description Moves relative synchronously by the specified distance.
-
Parameters
-
distance
- Description The distance to move.
- Type float
-
timeout
- Description The timeout in seconds.
- Type float
-
distance
-
Raises
-
Type ActuatorException
- Description If the move was unsuccessful.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
# Always home the actuator before starting to ensure position is properly calibrated.
actuator.home(timeout=10)
start_position = actuator.state.position
print("starting at position:", start_position)
target_distance = 150.0 # mm
actuator.move_relative(
distance=target_distance,
timeout=10, # seconds
)
# first_move_end_position is approx. equal to start_position + target_distance.
first_move_end_position = actuator.state.position
print("first move finished at position:", first_move_end_position)
# move back to starting position
target_distance = -1 * target_distance
actuator.move_relative(
distance=target_distance,
timeout=10, # seconds
)
# approx. equal to start_position,
end_position = actuator.state.position
print("finshed back at position:", end_position)
-
Description Moves relative asynchronously by the specified distance.
-
Parameters
-
distance
- Description The distance to move.
- Type float
-
distance
-
Raises
-
Type ActuatorException
- Description If the move was unsuccessful.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
from time import sleep
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
# Always home the actuator before starting to ensure position is properly calibrated.
actuator.home(timeout=10)
start_position = actuator.state.position
print("starting at position:", start_position)
target_distance = 150.0 # mm
# move_*_async will start the move and return without waiting for the move to complete.
actuator.move_relative_async(distance=150.0)
while actuator.state.move_in_progress:
print("move is in progress...")
sleep(1)
# end_position will be approx. equal to start_position + target_distance.
end_position = actuator.state.position
print("finished at position", end_position)
-
Description Sets the max acceleration for the Actuator.
-
Parameters
-
acceleration
- Description The new acceleration.
- Type float
-
acceleration
-
Raises
-
Type ActuatorException
- Description If the request was unsuccessful.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
target_speed = 100.0 # mm/s
target_acceleration = 500.0 # mm/s^2
actuator.set_speed(target_speed)
actuator.set_acceleration(target_acceleration)
-
Description Sets the max speed for the Actuator.
-
Parameters
-
speed
- Description The new speed.
- Type float
-
speed
-
Raises
-
Type ActuatorException
- Description If the request was unsuccessful.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
target_speed = 100.0 # mm/s
target_acceleration = 500.0 # mm/s^2
actuator.set_speed(target_speed)
actuator.set_acceleration(target_acceleration)
- Description ActuatorState: The representation of the current state of this MachineMotion.
-
Description Stops movement on this Actuator. If no argument is provided, then a quickstop is emitted which will abruptly stop the motion. Otherwise, the actuator will decelerate following the provided acceleration.
-
Parameters
-
acceleration
- Description Deceleration speed.
- Type float
-
acceleration
-
Raises
-
Type ActuatorException
- Description If the Actuator failed to stop.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
actuator.stop()
-
Description Unlocks the brakes on this Actuator.
-
Raises
-
Type ActuatorException
- Description If the brakes failed to unlock.
-
Type ActuatorException
-
Raises
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
actuator.unlock_brakes()
# Home the actuator before starting to ensure position is properly calibrated
actuator.home(timeout=10)
actuator.move_relative(distance=100.0)
actuator.lock_brakes()
# This move will fail because the brakes are now locked.
actuator.move_relative(distance=-100.0)
-
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
-
timeout
-
Raises
-
Type ActuatorException
- Description If the request fails or the move did not complete in the allocated amount of time.
-
Type ActuatorException
-
Parameters
from machinelogic import Machine
from time import sleep
machine = Machine()
actuator = machine.get_actuator("Actuator #1")
# Always home the actuator before starting to ensure position is properly calibrated.
actuator.home(timeout=10)
target_position = 150.0 # millimeters
# move_*_async will start the move and return without waiting for the move to complete.
actuator.move_absolute_async(target_position)
print("move started...")
actuator.wait_for_move_completion(timeout=10)
print("motion complete.")
# end_position will be approx. equal to target_position.
end_position = 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.
- Description float: The current state of the brakes of the Actuator. Set to 1 if locked, otherwise 0.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.state.brakes)
- Description Tuple[bool, bool]: A tuple representing the state of the [ home, end ] sensors.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.state.end_sensors)
- Description bool: The boolean is True if a move is in progress, otherwise False.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.state.move_in_progress)
- Description dict[str, float]: The current torque output of the Actuator.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.state.output_torque)
- Description float: The current position of the Actuator.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.state.position)
- Description float: The current speed of the Actuator.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(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.
- Description ActuatorType: The type of the Actuator.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.configuration.actuator_type)
- Description Literal[“A”, “B”]: The home sensor port, either A or B.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.configuration.home_sensor)
- Description str: The IP address of the Actuator.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.configuration.ip_address)
- Description str: The name of the Actuator.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.configuration.name)
- Description Literal[“deg”, “mm”]: The units that the Actuator functions in.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(actuator.configuration.units)
- Description str: The Actuator’s ID.
from machinelogic import Machine
machine = Machine()
actuator = machine.get_actuator("New actuator")
print(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.
An example usage would be:
machine = Machine()
actuator1 = machine.get_actuator("Actuator 1")
actuator2 = machine.get_actuator("Actuator 2")
actuator_group = ActuatorGroup(actuator1, actuator2)
-
Description Locks the brakes for all Actuators in the group.
-
Raises
-
Type ActuatorGroupException
- Description If the brakes failed to lock on a single Actuator in the group.
-
Type ActuatorGroupException
-
Raises
from machinelogic import Machine, ActuatorGroup
machine = Machine()
actuator1 = machine.get_actuator("Actuator #1")
actuator2 = machine.get_actuator("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)
actuator_group.set_speed(100.0) # mm/s
actuator_group.set_acceleration(500.0) # mm/s^2
actuator_group.lock_brakes()
# This move will fail because the brakes are locked.
actuator_group.move_absolute((50.0, 120.0), timeout=10)
-
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, …]
-
timeout
- Description The timeout in seconds after which an exception is thrown.
- Type float
- Default DEFAULT_MOVEMENT_TIMEOUT_SECONDS
-
position
-
Raises
-
Type ActuatorGroupException
- Description If the request fails or the timeout occurs.
-
Type ActuatorGroupException
-
Parameters
from machinelogic import Machine, ActuatorGroup
machine = Machine()
actuator1 = machine.get_actuator("Actuator #1")
actuator2 = machine.get_actuator("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)
actuator_group.set_speed(100.0) # mm/s
actuator_group.set_acceleration(500.0) # mm/s^2
target_positions = (100.0, 200.0) # (mm - actuator1, mm - actuator2)
actuator_group.move_absolute(target_positions, timeout=10)
-
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, …]
-
distance
-
Raises
-
Type ActuatorGroupException
- Description If the request fails.
-
Type ActuatorGroupException
-
Parameters
from machinelogic import Machine, ActuatorGroup
machine = Machine()
actuator1 = machine.get_actuator("Actuator #1")
actuator2 = machine.get_actuator("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)
actuator_group.set_speed(100.0) # mm/s
actuator_group.set_acceleration(500.0) # mm/s^2
target_positions = (75.0, 158.0) # (mm - actuator1, mm - actuator2)
# move_*_async will start the move and return without waiting for the move to complete.
actuator_group.move_absolute_async(target_positions, timeout=10)
print("move started..")
actuator_group.wait_for_move_completion()
print("motion completed.")
-
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, …]
-
timeout
- Description The timeout in seconds after which an exception is thrown.
- Type float
- Default DEFAULT_MOVEMENT_TIMEOUT_SECONDS
-
distance
-
Raises
-
Type ActuatorGroupException
- Description If the request fails or the timeout occurs
-
Type ActuatorGroupException
-
Parameters
from machinelogic import Machine, ActuatorGroup
machine = Machine()
actuator1 = machine.get_actuator("Actuator #1")
actuator2 = machine.get_actuator("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)
actuator_group.set_speed(100.0) # mm/s
actuator_group.set_acceleration(500.0) # mm/s^2
target_distances = (-120.0, 240.0) # (mm - actuator1, mm - actuator2)
actuator_group.move_relative(target_distances, timeout=10)
-
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, …]
-
distance
-
Raises
-
Type ActuatorGroupException
- Description If the request fails.
-
Type ActuatorGroupException
-
Parameters
from machinelogic import Machine, ActuatorGroup
from time import sleep
machine = Machine()
actuator1 = machine.get_actuator("Actuator #1")
actuator2 = machine.get_actuator("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)
actuator_group.set_speed(100.0) # mm/s
actuator_group.set_acceleration(500.0) # mm/s^2
target_distances = (-120.0, 240.0) # (mm - actuator1, mm - actuator2)
# move_*_async will start the move and return without waiting for the move to complete.
actuator_group.move_relative_async(target_distances, timeout=10)
while actuator_group.move_in_progress:
print("motion is in progress..")
sleep(1)
print("motion complete")
-
Description Sets the acceleration on all Actuators in the group.
-
Parameters
-
acceleration
- Description The acceleration to set on all Actuators in the group.
- Type float
-
acceleration
-
Raises
-
Type ActuatorGroupException
- Description If the acceleration failed to set on any Actuator in the group.
-
Type ActuatorGroupException
-
Parameters
-
Description Sets the speed on all Actuators in the group.
-
Parameters
-
speed
- Description The speed to set on all Actuators in the group.
- Type float
-
speed
-
Raises
-
Type ActuatorGroupException
- Description If the speed failed to set on any Actuator in the group.
-
Type ActuatorGroupException
-
Parameters
- Description ActuatorGroupState: The state of the ActuatorGroup.
-
Description Stops movement on all Actuators in the group.
-
Raises
-
Type ActuatorGroupException
- Description If any of the Actuators in the group failed to stop.
-
Type ActuatorGroupException
-
Raises
-
Description Unlocks the brakes on all Actuators in the group.
-
Raises
-
Type ActuatorGroupException
- Description If the brakes failed to unlock on a single Actuator in the group.
-
Type ActuatorGroupException
-
Raises
from machinelogic import Machine, ActuatorGroup
machine = Machine()
actuator1 = machine.get_actuator("Actuator #1")
actuator2 = machine.get_actuator("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)
actuator_group.set_speed(100.0) # mm/s
actuator_group.set_acceleration(500.0) # mm/s^2
actuator_group.lock_brakes()
# This move will fail because the brakes are locked.
actuator_group.move_absolute((50.0, 120.0), timeout=10)
-
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
-
timeout
-
Raises
-
Type ActuatorGroupException
- Description If the request fails or the move did not complete in the allocated amount of time.
-
Type ActuatorGroupException
-
Parameters
from machinelogic import Machine, ActuatorGroup
machine = Machine()
actuator1 = machine.get_actuator("Actuator #1")
actuator2 = machine.get_actuator("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)
actuator_group.set_speed(100.0) # mm/s
actuator_group.set_acceleration(500.0) # mm/s^2
target_positions = (75.0, 158.0) # (mm - actuator1, mm - actuator2)
# move_*_async will start the move and return without waiting for the move to complete.
actuator_group.move_absolute_async(target_positions, timeout=10)
print("move started..")
actuator_group.wait_for_move_completion()
print("motion completed.")
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()
robot = machine.get_robot("New robot")
In this example, “New robot” is the friendly name assigned to the actuator in the MachineLogic configuration page.
-
Description Computes the forward kinematics from joint angles.
-
Parameters
-
joint_angles
- Description The 6 joint angles, in degrees.
- Type JointAnglesDegrees
-
joint_angles
-
Returns
- Description Cartesian pose, in mm and degrees
- Type CartesianPose
-
Raises
-
Type ValueError
- Description Throws an error if the joint angles are invalid.
-
Type ValueError
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New 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 = robot.compute_forward_kinematics(joint_angles)
print(computed_robot_pose)
-
Description Computes the inverse kinematics from a Cartesian pose.
-
Parameters
-
cartesian_position
-
Description The Cartesian pose, in mm and degrees,
where the angles are extrinsic Euler angles in XYZ order. - Type CartesianPose
-
Description The Cartesian pose, in mm and degrees,
-
cartesian_position
-
Returns
- Description Joint angles, in degrees.
- Type JointAnglesDegrees
-
Raises
-
Type ValueError
- Description Throws an error if the inverse kinematic solver fails.
-
Type ValueError
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
cartesian_position = [
648.71, # x in millimeters
-313.3, # y in millimeters
159.28, # z in millimeters
107.143, # rx in degrees
-145.87, # ry in degrees
15.1261, # rz in degrees
]
computed_joint_angles = robot.compute_inverse_kinematics(cartesian_position)
print(computed_joint_angles)
- Description The Robot configuration.
-
Description Creates a sequence-builder object for building a sequence of robot movements. This method is expected to be used with the
append_*
methods.-
Returns
- Description A sequence builder object.
- Type SequenceBuilder
-
Returns
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
# Create an arbitrary Cartesian waypoint, that is 10mm or 10 degrees away from the current position
cartesian_waypoint = [i + 10 for i in robot.state.cartesian_position]
# Create an arbitrary joint waypoint, that is 10 degrees away from the current joint angles
joint_waypoint = [i + 10 for i in robot.state.joint_angles]
cartesian_velocity = 100.0 # millimeters per second
cartesian_acceleration = 100.0 # millimeters per second squared
blend_factor_1 = 0.5
joint_velocity = 10.0 # degrees per second
joint_acceleration = 10.0 # degrees per second squared
blend_factor_2 = 0.5
with robot.create_sequence() as seq:
seq.append_movel(
cartesian_waypoint, cartesian_velocity, cartesian_acceleration, blend_factor_1
)
seq.append_movej(joint_waypoint, joint_velocity, joint_acceleration, blend_factor_2)
# Alternate Form:
seq = robot.create_sequence()
seq.append_movel(cartesian_waypoint)
seq.append_movej(joint_waypoint)
robot.execute_sequence(seq)
-
Description Moves the robot through a specific sequence of joint and linear motions.
-
Parameters
-
sequence
- Description The sequence of target points.
- Type SequenceBuilder
-
sequence
-
Returns
- Description True if successful.
- Type bool
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
# Create an arbitrary Cartesian waypoint, that is 10mm or 10 degrees away from the current position
cartesian_waypoint = [i + 10 for i in robot.state.cartesian_position]
# Create an arbitrary joint waypoint, that is 10 degrees away from the current joint angles
joint_waypoint = [i + 10 for i in robot.state.joint_angles]
cartesian_velocity = 100.0 # millimeters per second
cartesian_acceleration = 100.0 # millimeters per second squared
blend_factor_1 = 0.5
joint_velocity = 10.0 # degrees per second
joint_acceleration = 10.0 # degrees per second squared
blend_factor_2 = 0.5
seq = robot.create_sequence()
seq.append_movel(
cartesian_waypoint, cartesian_velocity, cartesian_acceleration, blend_factor_1
)
seq.append_movej(joint_waypoint, joint_velocity, joint_acceleration, blend_factor_2)
robot.execute_sequence(seq)
-
Description Stops the robot current movement.
-
Returns
- Description True if the robot was successfully stopped, False otherwise.
- Type bool
-
Returns
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
robot.move_stop()
-
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
-
Description The joint acceleration to move at, in
-
target
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New 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
]
robot.movej(
joint_angles,
joint_velocity,
joint_acceleration,
)
-
Description Moves the robot to a specified Cartesian position.
-
Parameters
-
target
- Description The target Cartesian position, in mm and degrees.
- 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 CartesianPose
-
Description The reference frame to move relative to. If None,
-
target
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New 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 = [
-1267.8, # x in millimeters
-89.2, # y in millimeters
277.4, # z in millimeters
-167.8, # rx in degrees
179.7, # 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, # rz in degrees
]
robot.movel(
cartesian_pose,
linear_velocity, # Optional
linear_acceleration, # Optional
reference_frame, # Optional
)
-
Description Set a callback to the log alarm.
-
Parameters
-
callback
- Description A callback function to be called when a robot alarm is received.
- Type Callable[[RobotAlarm], None]
-
callback
-
Returns
- Description The callback ID.
- Type int
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
# The functon defined here is called when the specified alarm occurs
def handle_log_alarm(alarm):
print(alarm.level, alarm.error_code, alarm.description)
robot.on_log_alarm(handle_log_alarm)
-
Description Registers a callback for system state changes.
-
Parameters
-
callback
- Description The callback function.
- Type Callable[[RobotOperationalState, RobotSafetyState], None]
-
callback
-
Returns
- Description The callback ID.
- Type int
-
Parameters
from machinelogic import Machine
from machinelogic.machinelogic.robot import RobotOperationalState, RobotSafetyState
machine = Machine()
robot = machine.get_robot("New robot")
# The function defined here is called when the specified state change occurs
def handle_state_change(robot_operational_state: RobotOperationalState, safety_state: RobotSafetyState):
"""
A function that is called when the specified state change occurs.
Args:
robot_operational_state (RobotOperationalState): The current operational state of the robot.
safety_state (RobotSafetyState): The current safety state of the robot.
"""
print(robot_operational_state, safety_state)
callback_id = robot.on_system_state_change(handle_state_change)
print(callback_id)
-
Description Attempts to reset the robot to a normal operational state.
-
Returns
- Description True if successful.
- Type bool
-
Returns
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
did_reset = robot.reset()
print(did_reset)
# Robot state should be 'Normal'
print(robot.state.operational_state)
-
Description Sets the payload of the robot.
-
Parameters
-
payload
- Description The payload, in kg.
- Type Kilograms
-
payload
-
Returns
- Description True if successful.
- Type bool
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
# Weight in Kilograms
weight = 2.76
is_successful = robot.set_payload(weight)
print(is_successful)
-
Description Sets the tool center point offset.
-
Parameters
-
tcp_offset
-
Description The TCP offset, in mm and degrees, where the angles
are extrinsic Euler angles in XYZ order. - Type CartesianPose
-
Description The TCP offset, in mm and degrees, where the angles
-
tcp_offset
-
Returns
- Description True if the TCP offset was successfully set, False otherwise.
- Type bool
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
cartesian_offset = [
10.87, # x in millimeters
-15.75, # y in millimeters
200.56, # z in millimeters
0.31, # rx degrees
0.65, # ry degrees
0, # rz degrees
]
is_successful = robot.set_tcp_offset(cartesian_offset)
print(is_successful)
-
Description Sets the value of a tool digital output.
-
Parameters
-
pin
- Description The pin number.
- Type int
-
value
- Description The value to set, where 1 is high and 0 is low.
- Type int
-
pin
-
Returns
- Description True if successful.
- Type bool
-
Parameters
from machinelogic import Machine
machine = Machine()
# New robot must be configured in the Configuration pane
robot = machine.get_robot("New robot")
# digital output identifier
output_pin = 1
value = 0
is_successful = robot.set_tool_digital_output(output_pin, value)
print(is_successful)
- Description The current Robot state.
-
Description Put the robot into teach mode (i.e., freedrive).
-
Returns
- Description A context manager that will exit teach mode when it is closed.
- Type _WithTeach
-
Returns
import time
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
with robot.teach_mode(): # When all arguments inside this statement are complete, teach mode ends automatically
print("Robot is now in teach mode for 5 seconds")
time.sleep(5)
# Robot should be in 'Freedrive'
print(robot.state.operational_state)
time.sleep(1)
time.sleep(1)
# Robot should be back to 'Normal'
print(robot.state.operational_state)
RobotState
A representation of the robot current state.
- Description The current Cartesian position of the robot, in mm and degrees.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.state.cartesian_position)
-
Description Returns the value of a digital input at a given pin.
-
Parameters
-
pin
- Description The pin number.
- Type int
-
pin
-
Returns
- Description True if the pin is high, False otherwise.
- Type None
-
Parameters
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.state.get_digital_input_value(0))
- Description The robot current joint angles.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.state.joint_angles)
- Description The current robot operational state.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.state.operational_state)
- Description The current robot safety state.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.state.safety_state)
RobotModel
Supported robot models.
Possible values:
CRX_10IA
CRX_25IA
M710_IC45M
M20_ID35
DOOSAN_H2017
UR3_E
UR5_E
UR10_E
RobotConfiguration
A representation of the configuration of a Robot instance. This configuration defines what your Robot is and how it should behave when work is requested from it.
- Description The maximum Cartesian velocity of the robot, in mm/s.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.configuration.cartesian_velocity_limit)
- Description The robot joints’ maximum angular velocity, in deg/s.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.configuration.joint_velocity_limit)
- Description The friendly name of the robot.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.configuration.name)
- Description The robot’s type.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.configuration.robot_type)
- Description The robot’s ID.
from machinelogic import Machine
machine = Machine()
robot = machine.get_robot("New robot")
print(robot.configuration.uuid)
RobotOperationalState
The robot’s operational state.
Possible values:
Offline
NonOperational
Freedrive
Normal
RobotSafetyState
The robot’s safety state.
Possible values:
Normal
ProtectiveStop
EmergencyStop
ReducedSpeed
SafeguardStop
Unknown
SequenceBuilder
A builder for a sequence of moves.
-
Description Append a movej to the sequence.
-
Parameters
-
target
- Description The target joint angles, in degrees.
- Type JointAngles
-
velocity
- Description The velocity of the move, in degrees per second.
- Type DegreesPerSecond
- Default 10.0
-
acceleration
- Description The acceleration of the move, in degrees per second squared.
- Type DegreesPerSecondSquared
- Default 10.0
-
blend_radius
- Description The blend radius of the move, in millimeters.
- Type Millimeters
- Default 0.0
-
target
-
Returns
- Description The builder.
- Type SequenceBuilder
-
Parameters
-
Description Append a movel to the sequence.
-
Parameters
-
target
- Description The target pose.
- Type CartesianPose
-
velocity
- Description The velocity of the move, in millimeters per second.
- Type MillimetersPerSecond
- Default 100.0
-
acceleration
- Description The acceleration of the move, in millimeters per second squared.
- Type MillimetersPerSecondSquared
- Default 100.0
-
blend_radius
- Description The blend radius of the move, in millimeters.
- Type Millimeters
- Default 0.0
-
reference_frame
- Description The reference frame for the target pose.
- Type CartesianPose
- Default None
-
target
-
Returns
- Description The builder.
- Type SequenceBuilder
-
Parameters
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.
- Description DigitalInputConfiguration: The configuration of the DigitalInput.
- Description DigitalInputState: The state of the DigitalInput.
from machinelogic import Machine
machine = Machine()
# We are assuming here that New DigitalInput is in the MachineLogic configuration
input1 = machine.get_input("New DigitalInput")
if input1.state.value() == True:
print("input1 is HIGH")
else:
print("input1 is LOW")
DigitalInputState
Representation of the current state of an DigitalInput/DigitalOutput instance.
- Description bool: 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.
DigitalInputConfiguration
Representation of the configuration of an DigitalInput/DigitalOutput. This configuration is established by the configuration page in MachineLogic.
- Description bool: The value that needs to be set to consider the DigitalInput/DigitalOutput as active.
- Description int: The device number of the DigitalInput/DigitalOutput.
- Description str: The ip address of the DigitalInput/DigitalOutput.
- Description str: The name of the DigitalInput/DigitalOutput.
- Description int: The port number of the DigitalInput/DigitalOutput.
- Description str: The unique ID of the DigitalInput/DigitalOutput.
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.
- Description OutputConfiguration: The configuration of the Output.
-
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
-
value
-
Raises
-
Type DigitalOutputException
- Description If we fail to write the value to the Output.
-
Type DigitalOutputException
-
Parameters
from machinelogic import DigitalOutputException, Machine, MachineException
machine = Machine()
output1 = machine.get_output("New Output")
output1.write(True) # Write "true" to the Output
output1.write(False) # Write "false" to the Output
DigitalOutputState
Representation of the current state of an DigitalInput/DigitalOutput instance.
- Description bool: 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.
DigitalOutputConfiguration
Representation of the configuration of an DigitalInput/DigitalOutput. This configuration is established by the configuration page in MachineLogic.
- Description bool: The value that needs to be set to consider the DigitalInput/DigitalOutput as active.
- Description int: The device number of the DigitalInput/DigitalOutput.
- Description str: The ip address of the DigitalInput/DigitalOutput.
- Description str: The name of the DigitalInput/DigitalOutput.
- Description int: The port number of the DigitalInput/DigitalOutput.
- Description str: The unique ID of the DigitalInput/DigitalOutput.
Exceptions
ActuatorException
An exception thrown by an Actuator
Args:
VentionException (VentionException): Super class
- Description
- 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
- Description
- 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
- Description
- 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
- Description
- 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
- Description
- 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
- Description
- 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
- Description
- Description Exception.with_traceback(tb) – set self.traceback to tb and return self.
EstopException
An exception thrown by the Machine
Args:
Exception (VentionException): Super class
- Description
- Description Exception.with_traceback(tb) – set self.traceback to tb and return self.
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()
pneumatic1 = machine.get_pneumatic("New Pneumatic")
In this example, “New Pneumatic” is the friendly name assigned to a Pneumatic in the MachineLogic configuration page.
- Description PneumaticConfiguration: The configuration of the actuator.
-
Description Idles the Pneumatic.
-
Raises
-
Type PneumaticException
- Description If the idle was unsuccessful.
-
Type PneumaticException
-
Raises
-
Description Pulls the Pneumatic.
-
Raises
-
Type PneumaticException
- Description If the pull was unsuccessful.
-
Type PneumaticException
-
Raises
-
Description Pushes the Pneumatic.
-
Raises
-
Type PneumaticException
- Description If the push was unsuccessful.
-
Type PneumaticException
-
Raises
- Description PneumaticState: The state of the actuator.
PneumaticConfiguration
Representation of a Pneumatic configuration.
- Description int: The device of the axis.
- Description Optional[int]: The optional pull in pin.
- Description Optional[int]: The optional push in pin.
- Description str: The IP address of the axis.
- Description str: The name of the Pneumatic.
- Description int: The pull out pin of the axis.
- Description int: The push out pin of the axis.
- Description str: The ID of the Pneumatic.
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()
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.
- Description ACMotorConfiguration: The configuration of the ACMotor.
-
Description Begins moving the AC Motor forward.
-
Raises
-
Type ACMotorException
- Description If the move was unssuccessful.
-
Type ACMotorException
-
Raises
from time import sleep
from machinelogic import Machine
machine = Machine()
ac_motor1 = machine.get_ac_motor("AC Motor #1")
ac_motor1.move_forward()
sleep(10)
ac_motor1.stop()
-
Description Begins moving the AC Motor in reverse.
-
Raises
-
Type ACMotorException
- Description If the move was unssuccessful.
-
Type ACMotorException
-
Raises
from time import sleep
from machinelogic import Machine
machine = Machine()
ac_motor1 = machine.get_ac_motor("AC Motor #1")
# Move the AC motor in reverse
ac_motor1.move_reverse()
# The AC motor will stop moving if the program terminates
sleep(10)
-
Description Stops the movement of the AC Motor.
-
Raises
-
Type ACMotorException
- Description If the stop was unssuccessful.
-
Type ACMotorException
-
Raises
from time import sleep
from machinelogic import Machine
machine = Machine()
ac_motor1 = machine.get_ac_motor("AC Motor #1")
# Move the AC Motor forwards
ac_motor1.move_forward()
# Do something here
sleep(10)
ac_motor1.stop()
ACMotorConfiguration
Representation of a ACMotor configuration.
- Description int: The device of the axis.
- Description str: The IP address of the axis.
- Description str: The name of the Pneumatic.
- Description int: The push out pin of the axis.
- Description int: The pull out pin of the axis.
- Description str: The ID of the Pneumatic.
BagGripper
A software representation of a Bag Gripper. It is not recommended that you construct this object yourself. Rather, you should query it from a Machine instance:
E.g.:
machine = Machine()
gripper1 = machine.get_bag_gripper("New Gripper")
In this example, “New Gripper” is the friendly name assigned to a Bag Gripper in the MachineLogic configuration page.
-
Description Closes the Bag Gripper.
-
Raises
-
Type BagGripperException
- Description If the Bag Gripper fails to close.
-
Type BagGripperException
-
Raises
from time import sleep
from machinelogic import Machine
machine = Machine()
bag_gripper1 = machine.get_bag_gripper("Bag Gripper #1")
# Open the Bag Gripper
bag_gripper1.open_async()
# You can do something while the Bag Gripper is open
sleep(10)
# Close the Bag Gripper
bag_gripper1.close_async()
- Description BagGripperConfiguration: The configuration of the actuator.
-
Description Opens the Bag Gripper.
-
Raises
-
Type BagGripperException
- Description If the Bag Gripper fails to open.
-
Type BagGripperException
-
Raises
from time import sleep
from machinelogic import Machine
machine = Machine()
bag_gripper1 = machine.get_bag_gripper("Bag Gripper #1")
bag_gripper1.open(wait_for_move_completion=True)
print("bag_gripper1 is now open.")
sleep(5)
bag_gripper1.close(wait_for_move_completion=True)
print("bag_gripper1 is now closed.")
- Description BagGripperState: The state of the actuator.
BagGripperConfiguration
Representation of a Bag gripper configuration.
- Description int: The device of the Bag gripper.
- Description int: The close in pin of the Bag gripper.
- Description int: The open in pin of the Bag gripper.
- Description str: The IP address of the Bag gripper.
- Description str: The name of the Bag gripper.
- Description int: The close out pin of the Bag gripper.
- Description int: The open out pin of the Bag gripper.
- Description str: The ID of the Bag gripper.