Struggeling with Jacobian Inverse Kinematics











up vote
0
down vote

favorite
2












I am really struggling to find the right Jacobian for my 4DOF robot arm in 3D-space. First joint rotates around the y-axis, second around z-axis, third around z-axis and last one around the y-axis. All links are 1 unit long. My problem is probably the orientation vector zi because I know that my Forward Kinematics are correct. j1_pos-j4_pos are the positions of the joints. ee_pos is the end-effector. All positions are correct. My thought was just to multiply the respective axis vectors with the transformation matrices to get the orientation vectors zi.



Any advice would be much appreciated.



I am using the formula



J = [Jpi] = [zi x (pe - pi)]
[Joi] [ zi ]




def Jacobian(self,joint_angles):
jacobian = np.zeros((6,4))

j1_trans = self.link_transform_y(joint_angles[0])
j2_trans = self.link_transform_z(joint_angles[1])
j3_trans = self.link_transform_z(joint_angles[2])
j4_trans = self.link_transform_y(joint_angles[3])

ee_pos = (j1_trans*j2_trans*j3_trans*j4_trans)[0:3, 3]
j4_pos = (j1_trans*j2_trans*j3_trans)[0:3, 3]
j3_pos = (j1_trans*j2_trans)[0:3, 3]
j2_pos = (j1_trans)[0:3, 3]
j1_pos = np.zeros((3,1))

pos3D = np.zeros(3)

pos3D = (ee_pos-j1_pos).T
z0_vector = [0, 1, 0]
jacobian[0:3, 0] = np.cross(z0_vector, pos3D)
pos3D[0:3] = (ee_pos-j2_pos).T

z1_vector = (j1_trans*np.array([0, 0, 1, 0]).reshape(4,1))[0:3].T

jacobian[0:3, 1] = np.cross(z1_vector, pos3D)
pos3D[0:3] = (ee_pos-j3_pos).T

z2_vector = (j1_trans*j2_trans*np.array([0, 0, 1, 0]).reshape(4,1))[0:3].T

jacobian[0:3, 2] = np.cross(z2_vector, pos3D)
pos3D[0:3] = (ee_pos-j4_pos).T

z3_vector = (j1_trans*j2_trans*j3_trans*np.array([0, 1, 0, 0]).reshape(4,1))[0:3].T

jacobian[0:3, 3] = np.cross(z3_vector, pos3D)

jacobian[3:6, 0] = z0_vector
jacobian[3:6, 1] = z1_vector
jacobian[3:6, 2] = z2_vector
jacobian[3:6, 3] = z3_vector


return jacobian









share|improve this question




























    up vote
    0
    down vote

    favorite
    2












    I am really struggling to find the right Jacobian for my 4DOF robot arm in 3D-space. First joint rotates around the y-axis, second around z-axis, third around z-axis and last one around the y-axis. All links are 1 unit long. My problem is probably the orientation vector zi because I know that my Forward Kinematics are correct. j1_pos-j4_pos are the positions of the joints. ee_pos is the end-effector. All positions are correct. My thought was just to multiply the respective axis vectors with the transformation matrices to get the orientation vectors zi.



    Any advice would be much appreciated.



    I am using the formula



    J = [Jpi] = [zi x (pe - pi)]
    [Joi] [ zi ]




    def Jacobian(self,joint_angles):
    jacobian = np.zeros((6,4))

    j1_trans = self.link_transform_y(joint_angles[0])
    j2_trans = self.link_transform_z(joint_angles[1])
    j3_trans = self.link_transform_z(joint_angles[2])
    j4_trans = self.link_transform_y(joint_angles[3])

    ee_pos = (j1_trans*j2_trans*j3_trans*j4_trans)[0:3, 3]
    j4_pos = (j1_trans*j2_trans*j3_trans)[0:3, 3]
    j3_pos = (j1_trans*j2_trans)[0:3, 3]
    j2_pos = (j1_trans)[0:3, 3]
    j1_pos = np.zeros((3,1))

    pos3D = np.zeros(3)

    pos3D = (ee_pos-j1_pos).T
    z0_vector = [0, 1, 0]
    jacobian[0:3, 0] = np.cross(z0_vector, pos3D)
    pos3D[0:3] = (ee_pos-j2_pos).T

    z1_vector = (j1_trans*np.array([0, 0, 1, 0]).reshape(4,1))[0:3].T

    jacobian[0:3, 1] = np.cross(z1_vector, pos3D)
    pos3D[0:3] = (ee_pos-j3_pos).T

    z2_vector = (j1_trans*j2_trans*np.array([0, 0, 1, 0]).reshape(4,1))[0:3].T

    jacobian[0:3, 2] = np.cross(z2_vector, pos3D)
    pos3D[0:3] = (ee_pos-j4_pos).T

    z3_vector = (j1_trans*j2_trans*j3_trans*np.array([0, 1, 0, 0]).reshape(4,1))[0:3].T

    jacobian[0:3, 3] = np.cross(z3_vector, pos3D)

    jacobian[3:6, 0] = z0_vector
    jacobian[3:6, 1] = z1_vector
    jacobian[3:6, 2] = z2_vector
    jacobian[3:6, 3] = z3_vector


    return jacobian









    share|improve this question


























      up vote
      0
      down vote

      favorite
      2









      up vote
      0
      down vote

      favorite
      2






      2





      I am really struggling to find the right Jacobian for my 4DOF robot arm in 3D-space. First joint rotates around the y-axis, second around z-axis, third around z-axis and last one around the y-axis. All links are 1 unit long. My problem is probably the orientation vector zi because I know that my Forward Kinematics are correct. j1_pos-j4_pos are the positions of the joints. ee_pos is the end-effector. All positions are correct. My thought was just to multiply the respective axis vectors with the transformation matrices to get the orientation vectors zi.



      Any advice would be much appreciated.



      I am using the formula



      J = [Jpi] = [zi x (pe - pi)]
      [Joi] [ zi ]




      def Jacobian(self,joint_angles):
      jacobian = np.zeros((6,4))

      j1_trans = self.link_transform_y(joint_angles[0])
      j2_trans = self.link_transform_z(joint_angles[1])
      j3_trans = self.link_transform_z(joint_angles[2])
      j4_trans = self.link_transform_y(joint_angles[3])

      ee_pos = (j1_trans*j2_trans*j3_trans*j4_trans)[0:3, 3]
      j4_pos = (j1_trans*j2_trans*j3_trans)[0:3, 3]
      j3_pos = (j1_trans*j2_trans)[0:3, 3]
      j2_pos = (j1_trans)[0:3, 3]
      j1_pos = np.zeros((3,1))

      pos3D = np.zeros(3)

      pos3D = (ee_pos-j1_pos).T
      z0_vector = [0, 1, 0]
      jacobian[0:3, 0] = np.cross(z0_vector, pos3D)
      pos3D[0:3] = (ee_pos-j2_pos).T

      z1_vector = (j1_trans*np.array([0, 0, 1, 0]).reshape(4,1))[0:3].T

      jacobian[0:3, 1] = np.cross(z1_vector, pos3D)
      pos3D[0:3] = (ee_pos-j3_pos).T

      z2_vector = (j1_trans*j2_trans*np.array([0, 0, 1, 0]).reshape(4,1))[0:3].T

      jacobian[0:3, 2] = np.cross(z2_vector, pos3D)
      pos3D[0:3] = (ee_pos-j4_pos).T

      z3_vector = (j1_trans*j2_trans*j3_trans*np.array([0, 1, 0, 0]).reshape(4,1))[0:3].T

      jacobian[0:3, 3] = np.cross(z3_vector, pos3D)

      jacobian[3:6, 0] = z0_vector
      jacobian[3:6, 1] = z1_vector
      jacobian[3:6, 2] = z2_vector
      jacobian[3:6, 3] = z3_vector


      return jacobian









      share|improve this question















      I am really struggling to find the right Jacobian for my 4DOF robot arm in 3D-space. First joint rotates around the y-axis, second around z-axis, third around z-axis and last one around the y-axis. All links are 1 unit long. My problem is probably the orientation vector zi because I know that my Forward Kinematics are correct. j1_pos-j4_pos are the positions of the joints. ee_pos is the end-effector. All positions are correct. My thought was just to multiply the respective axis vectors with the transformation matrices to get the orientation vectors zi.



      Any advice would be much appreciated.



      I am using the formula



      J = [Jpi] = [zi x (pe - pi)]
      [Joi] [ zi ]




      def Jacobian(self,joint_angles):
      jacobian = np.zeros((6,4))

      j1_trans = self.link_transform_y(joint_angles[0])
      j2_trans = self.link_transform_z(joint_angles[1])
      j3_trans = self.link_transform_z(joint_angles[2])
      j4_trans = self.link_transform_y(joint_angles[3])

      ee_pos = (j1_trans*j2_trans*j3_trans*j4_trans)[0:3, 3]
      j4_pos = (j1_trans*j2_trans*j3_trans)[0:3, 3]
      j3_pos = (j1_trans*j2_trans)[0:3, 3]
      j2_pos = (j1_trans)[0:3, 3]
      j1_pos = np.zeros((3,1))

      pos3D = np.zeros(3)

      pos3D = (ee_pos-j1_pos).T
      z0_vector = [0, 1, 0]
      jacobian[0:3, 0] = np.cross(z0_vector, pos3D)
      pos3D[0:3] = (ee_pos-j2_pos).T

      z1_vector = (j1_trans*np.array([0, 0, 1, 0]).reshape(4,1))[0:3].T

      jacobian[0:3, 1] = np.cross(z1_vector, pos3D)
      pos3D[0:3] = (ee_pos-j3_pos).T

      z2_vector = (j1_trans*j2_trans*np.array([0, 0, 1, 0]).reshape(4,1))[0:3].T

      jacobian[0:3, 2] = np.cross(z2_vector, pos3D)
      pos3D[0:3] = (ee_pos-j4_pos).T

      z3_vector = (j1_trans*j2_trans*j3_trans*np.array([0, 1, 0, 0]).reshape(4,1))[0:3].T

      jacobian[0:3, 3] = np.cross(z3_vector, pos3D)

      jacobian[3:6, 0] = z0_vector
      jacobian[3:6, 1] = z1_vector
      jacobian[3:6, 2] = z2_vector
      jacobian[3:6, 3] = z3_vector


      return jacobian






      python robotics inverse-kinematics






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 at 1:13









      Thomas Fritsch

      4,630121833




      4,630121833










      asked Nov 10 at 15:19









      Frederik Kelbel

      13




      13





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240351%2fstruggeling-with-jacobian-inverse-kinematics%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240351%2fstruggeling-with-jacobian-inverse-kinematics%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Florida Star v. B. J. F.

          Danny Elfman

          Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues