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

KinovaGen3 issue in IK solver: OverflowError: high-low range exceeds valid bounds #475

Open
AnkeLinus opened this issue Feb 3, 2025 · 0 comments

Comments

@AnkeLinus
Copy link

Hello everybody,

I have a problem using the KinovaGen3 with the IK solvers. Below is the bug and the code that caused it.
This bug has been investigated for other robot models as well, as noted in "additional context". What's curious to me is that this code works fine for robots like Panda, Mico, LBR, Puma560 and YuMi. This can be reproduced by setting the model to these parameters. e.g. "rtb.models.URDF.Panda()".
I tried to set the available parameters as shown in line 41 (#inverse = kinova.inkine_LM(...)). Unfortunately this didn't solve the problem either.

Additional explorations:
Printing ets and i in IK.py line 436 showed that no abnormalities between working and bugged models.

I don't know how to solve the problem. Does anyone have a suggestion? Thanks for your reply in advance.

The bug:

Traceback (most recent call last):
File "/home/hirac/hirac/workspace/src/control_switch/control_switch/roboticstoolbox_interface.py", line 80, in
inverse = trtb.robot_ik(translation, quaternions)
File "/home/hirac/hirac/workspace/src/control_switch/control_switch/roboticstoolbox_interface.py", line 68, in robot_ik
inverse = kinova.ikine_LM(Tep)
File "/home/hirac/hirac/workspace/src/robotics-toolbox-python/roboticstoolbox/robot/RobotKinematics.py", line 1181, in ikine_LM
return self.ets(start, end).ikine_LM(
File "/home/hirac/hirac/workspace/src/robotics-toolbox-python/roboticstoolbox/robot/ETS.py", line 2584, in ikine_LM
return solver.solve(ets=self, Tep=Tep, q0=q0)
File "/home/hirac/hirac/workspace/src/robotics-toolbox-python/roboticstoolbox/robot/IK.py", line 224, in solve
q0_method[:, ets.jindices] = self._random_q(ets, self.slimit)
File "/home/hirac/hirac/workspace/src/robotics-toolbox-python/roboticstoolbox/robot/IK.py", line 469, in _random_q
q[j, i] = self._private_random.uniform(
File "_generator.pyx", line 954, in numpy.random._generator.Generator.uniform
OverflowError: high - low range exceeds valid bounds

The Code:

import numpy as np
import roboticstoolbox as rtb


class TryingRoboticToolbox():
    def robot_ik(self, translation, quaternions):
 
        kinova = rtb.models.URDF.KinovaGen3()
        print("Robot model:")
        print(kinova)

        init_pose = np.zeros(7) 

        # Convert quaternion to rotation matrix
        qw = quaternions[3]
        qx = quaternions[0]
        qy = quaternions[1]
        qz = quaternions[2]

        R = np.array([
            [1.0 - 2.0 * (qy**2 + qz**2), 2.0 * (qx * qy - qw * qz), 2.0 * (qx * qz + qw * qy)],
            [2.0 * (qx * qy + qw * qz), 1.0 - 2.0 * (qx**2 + qz**2), 2.0 * (qy * qz - qw * qx)],
            [2.0 * (qx * qz - qw * qy), 2.0 * (qy * qz + qw * qx), 1.0 - 2.0 * (qx**2 + qy**2)]
        ])

        print("Rotation Matrix:")
        print(R)
        
        # Initialize a 4x4 identity matrix
        Tep = kinova.fkine(init_pose)
        print("TEP init pose:")
        print(Tep)
        
        # Set the rotation part
        Tep.R = R
        Tep.t = translation

        print("TEP new pose:")
        print(Tep)
        print(kinova.qz)
        #inverse = kinova.ikine_LM(Tep, start = 'shoulder_link', end = 'bracelet_link',q0 = kinova.qz, ilimit = 10, slimit=70, tol = 0.2, joint_limits = False)
        inverse = kinova.ikine_LM(Tep)        
        print(inverse)

        return inverse

if __name__ == "__main__": 

    trtb = TryingRoboticToolbox()

    translation = [0.43892, 0.13330, 0.57540]
    quaternions = [0.0, 0.0, 0.0, 1.0]
    
    inverse = trtb.robot_ik(translation, quaternions)

Version information
This bug occurs in both cases. When roboticstoolbox is installedusing pip and with the github installation as stated in the readme.
Github commit hash 2a8111b (currently latest version)
Swift 1.1.0
SpatialMath 1.1.13

To Reproduce
Start up the program above. I called it roboticstoolbox_interface.py

Expected behavior
The above error might occur.

Environment (please complete the following information):
It runs on a Ubuntu 22.04 VM
Python 3.10.12

Additional context
This error is with this code reproducable for robot models: Fetch, PR2, px100, px150, rx150, rx200, vx300, vx300s, wx200, wx250, wx 250s.

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