Pose Conversion
Using the robot’s kinematics, it is possible to convert poses from joint space to Cartesian space and back. The robot does not move during a conversion.
Note
Pose conversion is currently only available for robots of the Victor Robot Behavior Group.
Convert a Joint Pose to a Cartesian Pose
Use convert_joint_pose_to_cartesian_pose_v() to convert a JointPose to a CartesianPose.
It returns the Cartesian pose and its corresponding configuration vector.
cartesian_pose, configuration_vector = (
robot.convert_joint_pose_to_cartesian_pose_v(joint_pose)
)
The method accepts the following optional arguments:
tool_transformation: Pose of the tool endpoint in flange coordinates.tool_transformation_offset: Offset from the tool endpoint in tool coordinates.output_cs: Coordinate system of the resulting pose.
By default, the method uses no tool transformation and no offset, and returns the pose of the robot’s flange in robot coordinates.
flange_pose, configuration_vector = (
robot.convert_joint_pose_to_cartesian_pose_v(HOME)
)
To get the tool center point (TCP) pose of the selected tool, use convert_joint_pose_to_tcp_pose_v().
See Tools for more information about tool selection.
tcp_pose, configuration_vector = (
robot.convert_joint_pose_to_tcp_pose_v(joint_pose)
)
For a tool that is not configured on the robot, pass its tool_transformation:
tool_transformation = CartesianPose(z=0.1)
custom_tcp_pose, _ = robot.convert_joint_pose_to_cartesian_pose_v(
HOME, tool_transformation
)
Convert a Cartesian Pose to a Joint Pose
Use convert_cartesian_pose_to_joint_pose_v() to convert a CartesianPose to a JointPose.
It requires a configuration vector, which selects one of the joint poses that reach the Cartesian pose.
joint_home_pose = robot.convert_cartesian_pose_to_joint_pose_v(
cartesian_pose, configuration_vector
)
The method accepts the same optional arguments:
tool_transformation: Pose of the tool endpoint in flange coordinates.tool_transformation_offset: Offset from the tool endpoint in tool coordinates.input_cs: Coordinate system of the Cartesian pose.
To convert a TCP pose of the selected tool to a joint pose, use convert_tcp_pose_to_joint_pose_v().
tcp_joint_home_pose = robot.convert_tcp_pose_to_joint_pose_v(
tcp_pose, configuration_vector
)
An unreachable pose raises a RobotArmError with the reason reported by the robot control. Catch it to check a pose
before moving to it:
unreachable_pose = cartesian_home_pose + CartesianPose(x=10)
try:
robot.convert_cartesian_pose_to_joint_pose_v(
unreachable_pose, configuration_vector
)
except RobotArmError as error:
_logger.info("Not converted: %s", error)
Full Example of Converting Poses
The following example shows a simple application that converts poses:
Pose Conversion Example
"""A simple example on how to convert between joint and Cartesian poses."""
from logging import Logger, getLogger
from math import radians
from voraus_robot_arm import (
CartesianPose,
JointPose,
PoseConversionVictorTrait,
RobotArmError,
VorausErrorHandler,
VorausIndustrialRobotArm,
configure_logging,
)
_logger: Logger = getLogger(__name__)
VORAUS_CORE_HOST = "localhost"
VORAUS_CORE_PORT = 48401
HOME = JointPose().from_list(
[radians(d) for d in [0, -90, 90, -90, -90, 0]]
)
def run_conversion_example(robot: PoseConversionVictorTrait) -> None:
"""Example application converting poses on a Victor robot."""
joint_pose = HOME
cartesian_pose, configuration_vector = (
robot.convert_joint_pose_to_cartesian_pose_v(joint_pose)
)
_logger.info("Cartesian home pose: %s", cartesian_pose)
joint_home_pose = robot.convert_cartesian_pose_to_joint_pose_v(
cartesian_pose, configuration_vector
)
_logger.info("Joint home pose: %s", joint_home_pose)
tcp_pose, configuration_vector = (
robot.convert_joint_pose_to_tcp_pose_v(joint_pose)
)
_logger.info("TCP home pose: %s", tcp_pose)
tcp_joint_home_pose = robot.convert_tcp_pose_to_joint_pose_v(
tcp_pose, configuration_vector
)
_logger.info("TCP joint home pose: %s", tcp_joint_home_pose)
def run_tool_conversion_example(robot: PoseConversionVictorTrait) -> None:
"""Example application converting poses for different tools."""
# The flange pose in home position
flange_pose, configuration_vector = (
robot.convert_joint_pose_to_cartesian_pose_v(HOME)
)
_logger.info(
"Flange pose: %s, configuration: %s",
flange_pose,
configuration_vector,
)
# The TCP pose of a custom tool in home position
tool_transformation = CartesianPose(z=0.1)
custom_tcp_pose, _ = robot.convert_joint_pose_to_cartesian_pose_v(
HOME, tool_transformation
)
_logger.info("Custom TCP pose: %s", custom_tcp_pose)
def run_unreachable_pose_example(robot: PoseConversionVictorTrait) -> None:
"""Example application converting a pose out of reach."""
cartesian_home_pose, configuration_vector = (
robot.convert_joint_pose_to_cartesian_pose_v(HOME)
)
# A pose out of reach has no joint pose
unreachable_pose = cartesian_home_pose + CartesianPose(x=10)
try:
robot.convert_cartesian_pose_to_joint_pose_v(
unreachable_pose, configuration_vector
)
except RobotArmError as error:
_logger.info("Not converted: %s", error)
if __name__ == "__main__":
configure_logging()
robot = VorausIndustrialRobotArm()
error_handler = VorausErrorHandler()
with robot.connect(host=VORAUS_CORE_HOST, port=VORAUS_CORE_PORT):
run_conversion_example(robot)
run_tool_conversion_example(robot)
run_unreachable_pose_example(robot)
Definition of the Pose Conversion Methods
The pose conversion methods are defined in the PoseConversionVictorTrait:
PoseConversionVictorTrait
- protocol PoseConversionVictorTrait
Trait to convert between joint and Cartesian poses using the robot kinematics for Victor robots.
This protocol is runtime checkable.
Classes that implement this protocol must have the following methods / attributes:
- abstractmethod convert_joint_pose_to_cartesian_pose_v(joint_pose, tool_transformation=None, tool_transformation_offset=None, output_cs=CSVictor.ROBOT)
Convert a joint pose into a Cartesian pose using the robots forward kinematics.
- Parameters:
joint_pose (
JointPose) – The joint pose to convert.tool_transformation (
CartesianPose|None) – Transformation from the flange to the tool endpoint. Defaults to no transformation.tool_transformation_offset (
CartesianPose|None) – Additional offset from the tool endpoint, in tool coordinates. Defaults to no offset.output_cs (
CSVictor) – The coordinate system of the resulting pose. Tool and camera cs are not supported.
- Raises:
RobotArmError – If output_cs is not supported or the robot control rejects the computation.
- Return type:
tuple[CartesianPose,tuple[Configuration,...]]- Returns:
The Cartesian pose in the requested coordinate system and the configuration vector.
- abstractmethod convert_joint_pose_to_tcp_pose_v(joint_pose, output_cs=CSVictor.ROBOT)
Convert a joint pose into the Cartesian pose of the TCP using the robot kinematics.
- Parameters:
- Raises:
RobotArmError – If output_cs is not supported or the robot control rejects the computation.
- Return type:
tuple[CartesianPose,tuple[Configuration,...]]- Returns:
The Cartesian pose in the requested coordinate system and the configuration vector.
- abstractmethod convert_cartesian_pose_to_joint_pose_v(cartesian_pose, configuration_vector, tool_transformation=None, tool_transformation_offset=None, input_cs=CSVictor.ROBOT)
Convert a Cartesian pose into a joint pose using the robots inverse kinematics.
- Parameters:
cartesian_pose (
CartesianPose) – The Cartesian pose to convert.configuration_vector (
tuple[Configuration,...]) – Resolves the posture ambiguity at the Cartesian pose. A Cartesian pose might be reachable by several postures, and the configuration vector specifies which one is used.tool_transformation (
CartesianPose|None) – Transformation from the flange to the tool endpoint. Defaults to no transformation.tool_transformation_offset (
CartesianPose|None) – Additional offset from the tool endpoint, in tool coordinates. Defaults to no offset.input_cs (
CSVictor) – The coordinate system in which cartesian_pose is defined. Tool and camera cs are not supported.
- Raises:
RobotArmError – If input_cs is not supported or the robot control rejects the computation.
- Return type:
- Returns:
The joint pose reaching the Cartesian pose.
- abstractmethod convert_tcp_pose_to_joint_pose_v(tcp_pose, configuration_vector, input_cs=CSVictor.ROBOT)
Convert a TCP pose using the selected tool into a joint pose.
- Parameters:
tcp_pose (
CartesianPose) – The tool center point pose to convert.configuration_vector (
tuple[Configuration,...]) – Resolves the posture ambiguity at the Cartesian pose. A Cartesian pose might be reachable by several postures, and the configuration vector specifies which one is used.input_cs (
CSVictor) – The coordinate system in which tcp_pose is defined. Tool and camera cs are not supported.
- Raises:
RobotArmError – If input_cs is not supported or the robot control rejects the computation.
- Return type:
- Returns:
The joint pose reaching the Cartesian pose.