diff --git a/docs/backends/ros/files/04_ik_allow_collision.py b/docs/backends/ros/files/04_ik_allow_collision.py index dbd118e25..0430dff5f 100644 --- a/docs/backends/ros/files/04_ik_allow_collision.py +++ b/docs/backends/ros/files/04_ik_allow_collision.py @@ -1,3 +1,6 @@ +from typing import Any +from typing import Dict + from compas.geometry import Box from compas.geometry import Frame @@ -25,15 +28,16 @@ # Create a target frame with the ROBOT mode frame_WCF = Frame([0.3, 0.1, 0.5], [1, 0, 0], [0, 1, 0]) target = FrameTarget(frame_WCF, TargetMode.ROBOT) - print("Target frame with Robot Mode: {}".format(target)) + print(f"Target frame with Robot Mode: {target}") # Calculate inverse kinematics - def calculate(options): + def calculate(options: Dict[str, Any]) -> None: + """Helper function to solve IK for the target frame and print the outcome.""" try: configuration = planner.inverse_kinematics(target, start_state, options=options) - print(" Found configuration: ", configuration) + print(f" Found configuration: {configuration}") except InverseKinematicsError as e: - print(" Failed to find a configuration: ", e) + print(f" Failed to find a configuration: {e}") print("Inverse kinematics with collision check enabled: (by default)") calculate({}) @@ -46,7 +50,7 @@ def calculate(options): Output: >>> Target frame with Robot Mode: FrameTarget(Frame(point=Point(x=0.300, y=0.100, z=0.500), xaxis=Vector(x=1.000, y=0.000, z=0.000), yaxis=Vector(x=0.000, y=1.000, z=0.000)), ROBOT) >>> Inverse kinematics with collision check enabled: (by default) ->>> Failed to find a configuration: No inverse kinematics solution found. +>>> Failed to find a configuration: No inverse kinematics solution found. >>> Inverse kinematics with collision check disabled: ->>> Found configuration: Configuration((-0.031, -2.025, 2.161, 4.576, -4.712, -1.540), (0, 0, 0, 0, 0, 0), ('shoulder_pan_joint', 'shoulder_lift_joint', 'elbow_joint', 'wrist_1_joint', 'wrist_2_joint', 'wrist_3_joint')) +>>> Found configuration: Configuration((-0.031, -2.025, 2.161, 4.576, -4.712, -1.540), (0, 0, 0, 0, 0, 0), ('shoulder_pan_joint', 'shoulder_lift_joint', 'elbow_joint', 'wrist_1_joint', 'wrist_2_joint', 'wrist_3_joint')) """