Prompt
<INSTRUCTIONS>
You are tasked with producing a closed-form analytical solution for the inverse kinematics of the 2 degrees-of-freedom serial manipulator solving for the position and orientation of the TCP as detailed in the "DETAILS" section by completing the Python function provided in the "CODE" section. The "Position" and "Orientation" columns represent link coordinates in local space relative to their parent link. The positions are from the "xyz" attribute and the orientations are the "rpy" attribute from each link's "origin" element parsed from the URDF. The "Axis" column in the table represents the rotational axis of the revolute links; return their values in radians and their limits are in radians. Do not write any code to run or test the method, as this will be handled for you. Assume all targets given as inputs to the method will be reachable, and as such do not write code to check if the target is reachable. You may use any methods included in Python, NumPy, and SymPy to write your solution except for any optimization methods. You may respond by either completing the inverse kinematics method or calling either of the two provided functions to help you develop your solution. If you call a function, you will be provided another response and chance to complete the inverse kinematics method. You may only call a single function per response.
</INSTRUCTIONS>
<DETAILS>
Link | Position | Orientation | Axis | Limits
------------+---------------------+---------------+--------+-------------------------
Revolute 1 | [0, 0, 0] | [0, 0, 0] | Z | [-6.2831853, 6.2831853]
Revolute 2 | [0, 0.13585, 0] | [0, 0, 0] | Y | [-6.2831853, 6.2831853]
TCP | [0, -0.1197, 0.425] | [0, 0, 0] | |
</DETAILS>
<CODE>
def inverse_kinematics(p: tuple[float, float, float], r: tuple[float, float, float]) -> tuple[float, float]:
"""
Gets the joint values needed to reach position "p" and orientation "r".
:param p: The position to reach in the form [x, y, z].
:param r: The orientation to reach in radians in the form [x, y, z].
:return: A list of the values to set the links to for reaching position "p" and orientation "r".
"""
</CODE>when to use it
Community prompt sourced from the open-source GitHub repo StevenRice99/LLM-IK (MIT). A "Prompt" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
codingcommunitydeveloper
source
StevenRice99/LLM-IK · MIT
more in Coding
Coding✓ tested
Senior code review (strict mode)
senior staff engineer running a merciless but fair review
Coding✓ tested
Debug by hypothesis, not by guessing
debugging partner who forms theories before touching code
Coding✓ tested
Generate tests from described behavior
test engineer who writes tests that would actually catch regressions