Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to industrial robot

Discussion in 'Scripting' started by SebWei, Jun 25, 2020.

  1. SebWei

    SebWei

    Joined:
    Mar 19, 2020
    Posts:
    7
    Hello everyone,

    I try to build up a true industrial robot with 6 DOF and run into a few issues. Most of the script works perfectly fine and without any rigging or something.
    But when I calculate the angle of axis five (counted from bottom to top) it gives me wrong results if it's close to 180°.
    The strange thing here is, it works perfect on axis two and three, where I use the same formula.
    For comparison it's c^2 = a^2 + b^2 - 2ab - cos (gamma)
    Is unity a little bit inaccurate in small numbers? The problem is not effected by switching between double and float.

    Thanks
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,589
    Unity is about as accurate as floats or doubles are. Are you using euler angles or quaternions for your rotation calculations? Euler angles have an intrinsic problem with gimbal lock, which you may be experiencing.
     
  3. SebWei

    SebWei

    Joined:
    Mar 19, 2020
    Posts:
    7
    I use quaternion.Euler to set the rotation of the axis

    SA5.transform.localRotation = Quaternion.Euler(0, Axis5Angle, 0);
     
  4. SebWei

    SebWei

    Joined:
    Mar 19, 2020
    Posts:
    7
    Solved!
    The numbers were to small in this particular case. I changed the calculus on this part form float to double and everything works.