Reading the Robot State
The current robot state is defined by various metrics.
The most basic and universally supported one is the provision of joint positions.
Whether a robot supports other metrics such as the provision of the Tool Center Point (TCP) pose and TCP velocity depends on the robot and the underlying robot control.
Reading the Main State of the Robot
In addition to the lifecycle state, a robot may also provide more specific states.
For example a robot with Victor behavior can be in one of the following states:
Definition of the RobotStateVictor
- class RobotStateVictor(value)
An enum representing the robot main state of a robot with Victor behavior.
- INIT = 0
Starting phase, initialization of robot and waiting for peripheral hardware.
- STANDBY = 1
Robot is initialized and ready to turn regulators on. Robot can not move.
- READY = 2
Regulators are turned on, but robot is not moving. Waiting for user input
- STOPPING = 3
Not implemented.
- ERROR = 4
Error has occurred, robot comes to standstill as fast as possible and remains in this state until reset.
- ACTIVE = 5
Robot is moving. Position, velocity and acceleration of each axis module is provided by the interpolator.
- RESET = 6
Attempt to clear errors. Fieldbus connection is re-established if it was lost.
- GRAVCOMP = 7
Robot is in gravitation compensation mode.
- SHUTDOWN = 8
Transit the robot into standstill and turns off regulators. Terminates the robot control process.
- COLLISIONREACTION = 9
A collision has been detected by the robot. Robot will execute the configured collision reaction.
These states can be read using the get_robot_state_v() method.
Note
Note that those states are specific to a robot behavior group and may require additional effort when porting to another robot. If possible, stick to the lifecycle states, as those are available on every robot.
Reading the Joint Pose
Reading the joint pose can be done using the method get_joint_pose().
It will return the most recent joint pose reported by the robot control in radians.
joint_pose = robot.get_joint_pose()
_logger.info("The current joint pose is %s", joint_pose)
If you run the code, the log output should look like the following:
[INFO ] The current joint pose is [0.0, -1.57..., 1.57..., -1.57..., -1.57..., 0.0]
Note that the method makes no assumption whether the values are actually measured or inferred but delegates this issue to the respective robot control.
Definition of the GetJointPoseTrait
- protocol GetJointPoseTrait
Trait to get the current joint pose.
This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
- abstractmethod get_joint_pose()
Get the current joint pose of the robot in radians.
- Return type:
- Returns:
The current joint pose in radians.
Reading the Joint Velocities
Reading the joint velocities can be done using the method get_joint_velocities().
It will return the most recent joint velocities reported by the robot control in radians per second.
joint_velocities = robot.get_joint_velocities()
_logger.info("The current joint velocities are %s", joint_velocities)
If you run the code, the log output should look like the following:
[INFO ] The current velocities are (0.0, 0.0, -1.57..., 0.0, 0.0, 0.0)
Note that the method makes no assumption whether the values are actually measured or inferred but delegates this issue to the respective robot control.
Definition of the GetJointVelocitiesTrait
- protocol GetJointVelocitiesTrait
Trait to retrieve joint velocities from the robot.
This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
- abstractmethod get_joint_velocities()
Get the current joint velocities of the robot in rad/s.
- Return type:
tuple[float,...]- Returns:
The current joint velocities in rad/s.
Reading the Joint Accelerations
Reading the joint accelerations can be done using the method get_joint_accelerations().
It will return the most recent joint accelerations reported by the robot control in radians per second squared.
joint_accelerations = robot.get_joint_accelerations()
_logger.info(
"The current joint accelerations are %s", joint_accelerations
)
If you run the code, the log output should look like the following:
[INFO ] The current accelerations are (0.0, 0.0, -3.66..., 0.0, 0.0, 0.0)
Note that the method makes no assumption whether the values are actually measured or inferred but delegates this issue to the respective robot control.
Definition of the GetJointAccelerationsTrait
- protocol GetJointAccelerationsTrait
Trait to retrieve joint acceleration data from the robot.
This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
- abstractmethod get_joint_accelerations()
Get the current joint accelerations of the robot in rad/s².
- Return type:
tuple[float,...]- Returns:
The current joint accelerations in rad/s².
Reading the TCP Pose
Reading the TCP pose can be done using the method get_tcp_pose().
It returns the current TCP pose reported by the robot control in meters for the translational part
and in radians for the rotational part.
tcp_pose = robot.get_tcp_pose()
_logger.info("The current TCP pose is %s", tcp_pose)
If you run the code, the log output should look like the following:
[INFO ] The current TCP pose is [0.54..., -0.13..., 0.29..., -3.14..., 0.0..., 1.57...]
Note that the method makes no assumption about the coordinate system of the returned pose but delegates this issue to the respective robot control.
Definition of the GetTcpPoseTrait
- protocol GetTcpPoseTrait
Trait to get the tool center point (TCP) pose from the robot.
This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
- abstractmethod get_tcp_pose()
Get the current tool center point (TCP) pose of the robot.
- Return type:
- Returns:
The current TCP pose in meter for the translational part and radian for the orientational part.
Reading the TCP Velocity
Reading the TCP velocity can be done using the method get_tcp_velocity().
It returns the current TCP velocity reported by the robot control in meters per second for the translational part
and in radians per second for the rotational part.
tcp_velocity = robot.get_tcp_velocity()
_logger.info("The current TCP velocity is %s", tcp_velocity)
If you run the code, the log output should look like the following:
[INFO ] The current TCP velocity is (0.19..., 0.0, 0.99..., 0.0, -1.58..., 0.0)
GetTcpVelocityTrait
- protocol GetTcpVelocityTrait
Trait to get the the tool center point (TCP) velocity of the robot.
This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
- abstractmethod get_tcp_velocity()
Get the current tool center point (TCP) velocity of the robot.
- Return type:
- Returns:
The current TCP velocity in m/s for the translational part and rad/s for the rotational part.
Full Example of Reading the Robot States
The following example shows a simple application in which the robot states are being read.
Complete Example for Reading the Robot States
"""This is an example for the reading of robot states."""
import logging
from math import radians
from time import sleep
from typing import Protocol
from voraus_robot_arm import (
GetJointAccelerationsTrait,
GetJointPoseTrait,
GetJointVelocitiesTrait,
GetTcpPoseTrait,
GetTcpVelocityTrait,
JointPose,
MovePTPTrait,
VorausIndustrialRobotArm,
configure_logging,
)
_logger = logging.getLogger()
VORAUS_CORE_HOST = "localhost"
VORAUS_ROBOT_CONTROL_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]]
)
class _RequiredRobotTraits(
MovePTPTrait,
GetJointPoseTrait,
GetJointVelocitiesTrait,
GetJointAccelerationsTrait,
GetTcpPoseTrait,
GetTcpVelocityTrait,
Protocol,
): ...
def run_my_application(robot: _RequiredRobotTraits) -> None:
"""Example application to demonstrate the reading of robot states."""
# Move the robot and wait for it to reach the pose
robot.move_ptp(HOME).result()
# Read the joint pose
joint_pose = robot.get_joint_pose()
_logger.info("The current joint pose is %s", joint_pose)
# Read the TCP pose
tcp_pose = robot.get_tcp_pose()
_logger.info("The current TCP pose is %s", tcp_pose)
# Move the robot and read velocities and accelerations during movement
vertical_future = robot.move_ptp(VERTICAL)
sleep(0.5)
joint_velocities = robot.get_joint_velocities()
_logger.info("The current joint velocities are %s", joint_velocities)
tcp_velocity = robot.get_tcp_velocity()
_logger.info("The current TCP velocity is %s", tcp_velocity)
joint_accelerations = robot.get_joint_accelerations()
_logger.info(
"The current joint accelerations are %s", joint_accelerations
)
vertical_future.result()
if __name__ == "__main__":
configure_logging()
robot = VorausIndustrialRobotArm()
with robot.connect(VORAUS_CORE_HOST, VORAUS_ROBOT_CONTROL_PORT):
robot.enable()
run_my_application(robot)