Pause and Continue
Pausing the robot’s movement can be useful to react to external events during program execution. When a pause command is sent, the robot decelerates along its current path until it comes to a complete stop. While paused, new instructions can still be registered, but they will only be executed once the pause signal is revoked.
Pausing the Robot’s Movement
To pause the robot, the pause_motion() command must be called, which takes an optional timeout parameter to define the
maximum time the robot is given to settle. If no explicit value is defined, it will default to 5 seconds. The
pause_motion() method will only return after the robot has come to a stop or will raise an error in case of a failure
to stop in due time. It can be send either in standstill or while the robot is moving:
robot.move_ptp(HOME).result()
robot.move_ptp(ZERO)
do_some_work()
robot.pause_motion()
Note that the motion instruction to the ZERO pose is called asynchronously, which allows a pause during movement. The
do_some_work() method is a placeholder, which in this case only waits until the robot starts moving.
After invoking pause_motion() the execution of new motion instructions (in this case a motion to the VERTICAL pose) is
blocked. However, they are added to the instruction queue.
robot.pause_motion()
vertical_command = robot.move_ptp(VERTICAL)
do_some_work()
robot.continue_motion()
vertical_command.result()
Only after the continue_motion() command is called, the robot continues the execution of all queued motion
instructions, which means it first moves to the ZERO pose and afterwards to the VERTICAL pose.
Here is an example of how to use the pause and continue methods:
Complete Example for Pausing a Robot
"""A simple example on how to pause the robot and continue again."""
from math import radians
from time import sleep
from typing import Protocol, runtime_checkable
from voraus_robot_arm import (
JointPose,
MovePTPTrait,
PauseContinueTrait,
VorausIndustrialRobotArm,
configure_logging,
)
VORAUS_CORE_HOST = "localhost"
VORAUS_CORE_PORT = 48401
HOME = JointPose().from_list(
[radians(d) for d in [0, -90, 90, -90, -90, 0]]
)
VERTICAL = JointPose().from_list(
[radians(d) for d in [0, -90, 0, -90, -90, 0]]
)
ZERO = JointPose().from_list([radians(d) for d in [0, 0, 0, 0, 0, 0]])
@runtime_checkable
class _RequiredRobotTraits(PauseContinueTrait, MovePTPTrait, Protocol): ...
def run_my_application(robot: _RequiredRobotTraits) -> None:
"""Example showing how to pause and continue the robot's motion."""
robot.move_ptp(HOME).result()
robot.move_ptp(ZERO)
do_some_work()
robot.pause_motion()
vertical_command = robot.move_ptp(VERTICAL)
do_some_work()
robot.continue_motion()
vertical_command.result()
def do_some_work() -> None:
"""This is a placeholder method to simulate something happening."""
sleep(1)
if __name__ == "__main__":
configure_logging()
robot = VorausIndustrialRobotArm()
with robot.connect(host=VORAUS_CORE_HOST, port=VORAUS_CORE_PORT):
robot.enable()
run_my_application(robot)
Definition of the Pause and Continue Methods
The pause and continue methods are defined in the PauseContinueTrait:
PauseContinueTrait
- protocol PauseContinueTrait
Trait to pause and continue the motion of a robot.
This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
- abstractmethod pause_motion(timeout_s=5.0)
Pause the robot’s motion.
The robot will decelerate on the planned path until standstill. Instructions can still be issued, but the robot will only execute the remaining instructions after
continue_motion()is called.A pause blocks until the robot has settled. Depending on the robot dynamics, this may take some time. If the robot does not stop, a RobotArmError is raised.
This method is thread safe. It is valid to call it from another thread than the instruction issuing thread.
If the robot was already stopped with
stop_motiona pause has no effect.- Parameters:
timeout_s (
float) – Maximum time in seconds for the robot to settle. Defaults to 5 seconds.- Return type:
None
- abstractmethod continue_motion()
Continue the robot motion after it has been stopped by the
pause_motioncommand.- Return type:
None