Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with inverse kinematics #142

Open
VovaStelmashchuk opened this issue May 16, 2023 · 0 comments
Open

Problem with inverse kinematics #142

VovaStelmashchuk opened this issue May 16, 2023 · 0 comments

Comments

@VovaStelmashchuk
Copy link

Inverse kinematics doesn't work my robot. The inverse_kinematics function returns wrong values for joints (sush as 1.1111e-12, or other value around zero).

I checked the robot can achive the target point.

The robot is a simple two arms robot based on rotation plate. Rotation plate attach to movable plate which has ability to move by x and y.

My UDRF file:

<robot name="robot_arm">

    <link name="base_link">
        <visual>
            <origin xyz="1.5 0 0" rpy="0 0 0"/>
            <geometry>
                <box size="3 0.05 0.05"/>
            </geometry>
        </visual>
    </link>
        
    <link name="y">
        <visual>
        <origin xyz="0 1.5 0" rpy="0 0 0"/>
            <geometry>
                <box size="0.05 3 0.05"/>
            </geometry>
        </visual>
    </link>
    
    <joint name="y_to_x" type="prismatic">
        <parent link="base_link"/>
        <child link="y"/>
        <origin xyz="0 0 0.05" rpy="0 0 0"/>
        <axis xyz="1 0 0"/>
        <limit lower="0" upper="3"></limit>
    </joint>
    
        
    <link name="robotbase">
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0"/>
            <geometry>
                <cylinder length="0.05" radius="0.1"/>
            </geometry>
            <material name="Red"/>
        </visual>
    </link>

    <joint name="robot_base_to_xy" type="prismatic">
        <parent link="y"/>
        <child link="robotbase"/>
        <origin xyz="0 0 0.05" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
        <limit lower="0" upper="3"></limit>
    </joint>
    
    <link name="robot_rotation_base">
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0"/>
            <geometry>
                <box size="0.1 0.1 0.1"/>
            </geometry>
            <material name="Green"/>
        </visual>
    </link>
    
    <joint name="robot_rotation" type="revolute">
        <parent link="robotbase"/>
        <child link="robot_rotation_base"/>
        <origin xyz="0 0 0.05" rpy="0 0 1"/>
        <axis xyz="0 0 1"/>
    </joint>
    
        <link name="arm1">
        <visual>
            <origin xyz="0 0 0.5" rpy="0 0 0"/>
            <geometry>
                <box size="0.05 0.05 1"/>
            </geometry>            
            <material name="Blue"/>
        </visual>
    </link>

    <joint name="arm1_rotation" type="revolute">
        <parent link="robot_rotation_base"/>
        <child link="arm1"/>
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
        <limit lower="-1.25" upper="1.25"></limit>
    </joint>

    <link name="arm2">
        <visual>
            <origin xyz="0 0 0.5" rpy="0 0 0"/>
            <geometry>
                <box size="0.05 0.05 1"/>
            </geometry>            
            <material name="Pure"/>
        </visual>
    </link>
        
    <joint name="arm_to_arm" type="revolute">
        <parent link="arm1"/>
        <child link="arm2"/>
        <origin xyz="0 0 1" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
    </joint>
    
    <material name="Red">
        <color rgba="1.0 0 0 1.0"/>
    </material>
    
    <material name="Green">
        <color rgba="0 1.0 0 1.0"/>
    </material>

    <material name="Blue">
        <color rgba="0 0 1.0 1.0"/>
    </material>

    <material name="Pure">
        <color rgba="1.0 0 1.0 1.0"/>
    </material>

</robot>

My python code:

from ikpy.chain import Chain
from ikpy.link import OriginLink, URDFLink
import numpy as np

my_chain = Chain.from_urdf_file("arm_urdf.urdf")

target_position = [1, 1.5, 1.5]

joint_angles = my_chain.inverse_kinematics(target_position)

print("The angles of each joints are : ", joint_angles)

The python code returns the following:

The angles of each joints are :  [0.00000000e+00 1.65911074e-10 1.98866611e-10 0.00000000e+00
 4.95022040e-11 0.00000000e+00]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant