Skip to content

compas_fab.backends.kinematics.backend_features ¤

Backend feature implementations for the analytical kinematics backend.

Classes¤

AnalyticalForwardKinematics ¤

AnalyticalForwardKinematics(client=None)

Backend feature to calculate the robot's forward kinematics for a given joint configuration.

This mixin is used by AnalyticalKinematicsPlanner. The kinematical solver in the planner must implement the method forward.

Methods:¤

forward_kinematics ¤
forward_kinematics(
    robot_cell_state: RobotCellState,
    target_mode: TargetMode,
    scale: float | None = None,
    group: str | None = None,
    options: dict | None = None,
) -> Frame

Calculate the forward kinematics for a given joint configuration.

forward_kinematics_to_link(
    robot_cell_state: RobotCellState,
    link_name: str,
    scale: float | None = None,
    group: str | None = None,
    options: dict | None = None,
) -> Frame

Calculate the forward kinematics for a given joint configuration to a specific link.

This method is not supported by AnalyticalKinematicsPlanner.

AnalyticalInverseKinematics ¤

AnalyticalInverseKinematics()

Callable to calculate the robot's inverse kinematics for a given frame.

Notes

This works only for industrial robot arms with six revolute joints. If check_collision is True, it is required to use a client that supports "check_collision", so for now only the PyBulletClient.

Methods:¤

inverse_kinematics ¤
inverse_kinematics(
    target: Target,
    robot_cell_state: RobotCellState | None = None,
    group: str | None = None,
    options: dict | None = None,
) -> Configuration

Calculate the robot's inverse kinematic for a given frame.

The default implementation is based on the iter_inverse_kinematics method. Calling this method will return the first solution found by the iterator, subsequent calls will return the next solution from the iterator. Once all solutions have been exhausted, the iterator will be re-initialized.

The starting state describes the robot cell's state at the moment of the calculation. The robot's configuration is taken as the starting configuration. If a tool is attached to the planning group, the tool's coordinate frame is used.

Parameters:

  • target (Target) –

    The target to calculate the inverse kinematics for.

  • robot_cell_state (RobotCellState | None, default: None ) –

    The starting state to calculate the inverse kinematics for. The robot's configuration in the scene is taken as the starting configuration.

  • group (str | None, default: None ) –

    The planning group used for calculation.

  • options (dict | None, default: None ) –

    Dictionary containing kwargs for arguments specific to the client being queried.

    • "verbose": (:obj:bool, optional) Whether or not to print verbose output. Defaults to False.

Raises:

  • :class:`compas_fab.backends.exceptions.InverseKinematicsError`

    If no configuration can be found.

Returns:

  • obj:`compas_robots.Configuration`

    The calculated configuration.

inverse_kinematics_ordered ¤
inverse_kinematics_ordered(
    frame_WCF: Frame, group: str | None = None, options: dict | None = None
) -> Generator[Configuration | None, None, None]

Calculate the robot's inverse kinematic (IK) for a given frame.

The IK for 6-axis industrial robots returns by default 8 possible solutions. These solutions have an order. That means that if you call IK on two subsequent frames and compare the 8 configurations of the first frame with the 8 configurations of the second frame at their respective indices, then these configurations are "close" to one another. For this reason, for certain use cases, e.g. for cartesian path planning, it makes sense to keep the order of solutions. This can be achieved by setting the optional parameter keep_order to True. The configurations that are in collision or outside joint boundaries are then not removed from the list of solutions, they are set to None.

Parameters:

  • frame_WCF (Frame) –

    The frame to calculate the inverse for.

  • group (str | None, default: None ) –

    The planning group used for determining the end effector and labeling the start_configuration. Defaults to the robot's main planning group.

  • options (dict | None, default: None ) –

    Dictionary containing the following key-value pairs:

    • "solver": (:obj:str) The solver to use to calculate IK.
    • "check_collision": (:obj:str, optional ) When True, checks if the robot is in collision. Defaults to False.
    • "keep_order": (:obj:str, optional ) When False, removes the None- solutions. Defaults to False.

Yields:

  • obj:`compas_robots.Configuration`

    One of the possible IK configurations that reaches the target. If "keep_order" is True result may contain None.

Notes

This will only work with robots that have 6 revolute joints. This function will yield exactly 8 times, if "keep_order" is True.

Raises:

  • ValueError

    If the solver to solve the kinematics has not been passed.

  • InverseKinematicsError

    If no IK solution could be found by the kinematic solver.

iter_inverse_kinematics ¤
iter_inverse_kinematics(
    target: Target,
    start_state: RobotCellState,
    group: str | None = None,
    options: dict | None = None,
) -> Generator[Configuration | None, None, None]

Calculate the robot's inverse kinematic for a given target.

An iterator is returned that yields configurations.

AnalyticalPlanCartesianMotion ¤

AnalyticalPlanCartesianMotion(client=None)

Methods:¤

plan_cartesian_motion ¤
plan_cartesian_motion(
    waypoints: Waypoints,
    start_state: RobotCellState,
    group: str | None = None,
    options: dict | None = None,
) -> JointTrajectory

Calculates a cartesian motion path (linear in tool space).

Parameters:

  • waypoints (Waypoints) –

    The waypoints for the robot to follow.

  • start_state (RobotCellState) –

    The starting state of the robot cell at the beginning of the motion. The attribute robot_configuration, must be provided.

  • group (str | None, default: None ) –

    The planning group used for calculation.

  • options (dict | None, default: None ) –

    Dictionary containing the key-value pairs that are passed to PlannerInterface.iter_inverse_kinematics

Returns:

  • class:`compas_fab.robots.JointTrajectory`

    The calculated trajectory.

Notes

This will only work with robots that have 6 revolute joints.

AnalyticalPybulletInverseKinematics ¤

AnalyticalPybulletInverseKinematics()

Callable to calculate the robot's inverse kinematics for a given frame.

Includes the ability to use PyBullet for collision checking.

Notes

This works only for industrial robot arms with six revolute joints. If check_collision is True, it is required to use a client that supports "check_collision", so for now only the PyBulletClient.

Methods:¤

inverse_kinematics ¤
inverse_kinematics(
    target: Target,
    robot_cell_state: RobotCellState | None = None,
    group: str | None = None,
    options: dict | None = None,
) -> Configuration

Calculate the robot's inverse kinematic for a given frame.

The default implementation is based on the iter_inverse_kinematics method. Calling this method will return the first solution found by the iterator, subsequent calls will return the next solution from the iterator. Once all solutions have been exhausted, the iterator will be re-initialized.

The starting state describes the robot cell's state at the moment of the calculation. The robot's configuration is taken as the starting configuration. If a tool is attached to the planning group, the tool's coordinate frame is used.

Parameters:

  • target (Target) –

    The target to calculate the inverse kinematics for.

  • robot_cell_state (RobotCellState | None, default: None ) –

    The starting state to calculate the inverse kinematics for. The robot's configuration in the scene is taken as the starting configuration.

  • group (str | None, default: None ) –

    The planning group used for calculation.

  • options (dict | None, default: None ) –

    Dictionary containing kwargs for arguments specific to the client being queried.

    • "verbose": (:obj:bool, optional) Whether or not to print verbose output. Defaults to False.

Raises:

  • :class:`compas_fab.backends.exceptions.InverseKinematicsError`

    If no configuration can be found.

Returns:

  • obj:`compas_robots.Configuration`

    The calculated configuration.

inverse_kinematics_ordered ¤
inverse_kinematics_ordered(
    frame_WCF: Frame, group: str | None = None, options: dict | None = None
) -> Generator[Configuration | None, None, None]

Calculate the robot's inverse kinematic (IK) for a given frame.

The IK for 6-axis industrial robots returns by default 8 possible solutions. These solutions have an order. That means that if you call IK on two subsequent frames and compare the 8 configurations of the first frame with the 8 configurations of the second frame at their respective indices, then these configurations are "close" to one another. For this reason, for certain use cases, e.g. for cartesian path planning, it makes sense to keep the order of solutions. This can be achieved by setting the optional parameter keep_order to True. The configurations that are in collision or outside joint boundaries are then not removed from the list of solutions, they are set to None.

Parameters:

  • frame_WCF (Frame) –

    The frame to calculate the inverse for.

  • group (str | None, default: None ) –

    The planning group used for determining the end effector and labeling the start_configuration. Defaults to the robot's main planning group.

  • options (dict | None, default: None ) –

    Dictionary containing the following key-value pairs:

    • "solver": (:obj:str) The solver to use to calculate IK.
    • "check_collision": (:obj:str, optional ) When True, checks if the robot is in collision. Defaults to False.
    • "keep_order": (:obj:str, optional ) When False, removes the None- solutions. Defaults to False.

Yields:

  • obj:`compas_robots.Configuration`

    One of the possible IK configurations that reaches the target. If "keep_order" is True result may contain None.

Notes

This will only work with robots that have 6 revolute joints. This function will yield exactly 8 times, if "keep_order" is True.

Raises:

  • ValueError

    If the solver to solve the kinematics has not been passed.

  • InverseKinematicsError

    If no IK solution could be found by the kinematic solver.

iter_inverse_kinematics ¤
iter_inverse_kinematics(
    target: Target,
    start_state: RobotCellState = None,
    group: str | None = None,
    options: dict | None = None,
) -> Generator[Configuration | None, None, None]

Calculate the robot's inverse kinematic for a given target.

An iterator is returned that yields configurations.

AnalyticalSetRobotCell ¤

AnalyticalSetRobotCell(client=None)

Methods:¤

set_robot_cell ¤
set_robot_cell(
    robot_cell: RobotCell,
    robot_cell_state: RobotCellState = None,
    options: dict | None = None,
)

Pass the models in the robot cell to the Analytical Planner.

The planner will use the tool information for frame transformation.

Note that the Analytical Planner does not support collision checking. Therefore, the geometry of the robot, tools and rigid bodies in the robot cell are not checked.

Parameters:

  • robot_cell (RobotCell) –

    The robot cell to set for the planner.

  • robot_cell_state (RobotCellState, default: None ) –

    The robot cell state to set for the planner.

  • options (dict | None, default: None ) –

    This input is not used by the AnalyticalClient.

Notes

If the robot_cell_state is provided, it will be stored in the client for later use.

AnalyticalSetRobotCellState ¤

AnalyticalSetRobotCellState(client=None)

Methods:¤

set_robot_cell_state ¤
set_robot_cell_state(robot_cell_state: RobotCellState)

The Analytical Planner does not have collision checking ability, therefore it does not really need the robot cell state. This function simply serves as the landing point for other BackendFeature to safely call planner.set_robot_cell_state without having to check if the planner actually supports it.

The given RobotCellState object is stored on the client by reference. Pass robot_cell_state.copy() if you intend to mutate the object after this call.