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

Inverse solution ---Tool coordinates #88

Open
jinzhouchu opened this issue Mar 30, 2024 · 4 comments
Open

Inverse solution ---Tool coordinates #88

jinzhouchu opened this issue Mar 30, 2024 · 4 comments

Comments

@jinzhouchu
Copy link

Hello!
When using the RL library for inverse kinematics, I found that the rotation of joint "c" is not aligned with the direction of the tool axis. Do I need to modify any parameters? I intend to use the tool coordinate to control the robotic arm.
The demo I referred to is rlCoachMdl.
b3b02dcebd177a0a00c57388153e19d

@jinzhouchu
Copy link
Author

When I adjust the C value, the robotic arm rotates around the blue line.

@rickertm
Copy link
Member

The values in the operational widget refer to the operational position and orientation of the robot's end effector in world coordinates. In order to specify changes in the tool frame, you can calculate the robot's Jacobian matrix in tool coordinates, see rl::mdl::Kinematic::calculateJacobian().

@jinzhouchu
Copy link
Author

Thank you for your answer, but I'm a beginner in RL. Could you please guide me on how to modify this code to achieve the desired effect? I appreciate your assistance.

`
bool RLConvertAPI::SetIndexedInverseValue(const int &index, const double &value)
{
if (rl::mdl::Kinematic* kinematic = dynamic_castrl::mdl::Kinematic*(aReaderAPI->JointModel.get()))
{

    rl::math::Transform transform = kinematic->getOperationalPosition(0);

    rl::math::Vector3 orientation = transform.linear().eulerAngles(2, 1, 0).reverse();

    switch (index)
    {
    case 0:
    case 1:
    case 2:
        transform.translation()(index) = value;
        break;
    case 3:
        transform.linear() = (
                    rl::math::AngleAxis(orientation.z(), rl::math::Vector3::UnitZ()) *
                    rl::math::AngleAxis(orientation.y(), rl::math::Vector3::UnitY()) *
                    rl::math::AngleAxis(value * rl::math::constants::deg2rad, rl::math::Vector3::UnitX())
                    ).toRotationMatrix();
        break;
    case 4:
        transform.linear() = (
                    rl::math::AngleAxis(orientation.z(), rl::math::Vector3::UnitZ()) *
                    rl::math::AngleAxis(value * rl::math::constants::deg2rad, rl::math::Vector3::UnitY()) *
                    rl::math::AngleAxis(orientation.x(), rl::math::Vector3::UnitX())
                    ).toRotationMatrix();
        break;
    case 5:
        transform.linear() = (
                    rl::math::AngleAxis(value * rl::math::constants::deg2rad, rl::math::Vector3::UnitZ()) *
                    rl::math::AngleAxis(orientation.y(), rl::math::Vector3::UnitY()) *
                    rl::math::AngleAxis(orientation.x(), rl::math::Vector3::UnitX())
                    ).toRotationMatrix();
        break;
    default:
        break;
    }

    rl::math::Vector q = kinematic->getPosition();

    rl::mdl::InverseKinematics* aInverse = new rl::mdl::JacobianInverseKinematics(kinematic);

    aInverse->addGoal(transform, 0);

    bool solved = aInverse->solve();

    if (solved)
    {
        rl::math::Vector currentPos = kinematic->getPosition();


        SetJointValue(currentPos);

        delete aInverse;

        return true;

    }
    else
    {
        kinematic->setPosition(q);

        kinematic->forwardPosition();

        delete aInverse;

        return false;
    }
}
return false;

}

`

@jinzhouchu
Copy link
Author

Looking forward to your reply

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

2 participants