Kinematics Functions for Robotics - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Kinematics Functions for Robotics (/thread-14207.html) |
Kinematics Functions for Robotics - hamorabi - 12-21-2019 10:43 PM Hello, I am relatively new to the prime. I am sharing some functions I created that can be pretty useful for someone studying Robotics, particularly Robot kinematics. Here's a list of the functions and brief explanation of what they do: 1. atan_2(x,y): This is the tan inverse function that takes into account the quadrant. For example, the angle returned for atan_2(3/4) is different from the angle returned for atan_2(-3/-4). This is necessary in Robotics as we want to avoid any ambiguity regarding the angle of rotation of a joint. The matrices that we deal with in Robotics are usually 4x4 (known as the homogeneous matrix). The upper left 3x3 matrix defines the orientation of body in space. The upper right 3x1 matrix defines the relative position of the body from some location. 2. Trans(x,y,z): This function returns a 4x4 translation matrix x units in the x direction, y units in the y direction, and z units in the z direction. 3. Rot(ang,ax): This function returns a 4x4 rotation matrix for a body rotated by an angle "ang" about the axis "ax". To make things simple, if the rotation is about the x axis, use Rot(ang,1). If the rotation is about the y axis, use Rot(ang,2), and Rot(ang,3) for rotation about the z axis. Here's an example of how the two functions above can prove useful. Suppose we have a body that is currently at the origin. Suppose the body undergoes the following transformations: 1. Rotation of 90° about the z-axis, 2. Followed by a rotation of 90° about the new y-axis, 3. Followed by a translation of [4,-3,7] with respect to the fixed axis. What is the orientation and location of the body relative to the origin? Take a guess about the x,y,z location of the body. You will likely not get the correct answer because of all the rotations and change of direction of the unit axes as the body rotates. We can calculate the orientation and location by compounding the transformation matrices as shown below. Transformations with respect to the new axis are multiplied on the left while transformations with respect to the fixed axis are multiplied on the right: PHP Code: Rot(90,2)*Rot(90,3)*Trans(4,-3,7) 3. dh(v): This is a function that calculates the transformation matrix that will align one joint with the next one. We use it as follows: PHP Code: dh(θ,d,α,a) 4. EulerMatrix(Φ,θ,ψ,ax): This functions does gives us the orientation of a body that has undergone three successive rotations given by Φ, θ, and ψ about three axis. For example EulerMatrix(90,60,30,213) means rotate the body by 90 degrees about the fixed y axis, then rotate by 60 degrees about the fixed x axis, then rotate by 30 degrees about the fixed z axis. 5. EulerAngle(m,ax): Suppose we have a body that has undergone some rotations. How can we know the angles relative to the axes that we need to rotate the body so that its orientation is just as it was before any rotation? This function takes a 3x3 orientation matrix and tells gives you the angles you can rotate the body by to return it to its default orientation. For instance, EulerAngle(matrix,212) means tell me the three angles with which I need to rotate the body first with respect to the y axis, then with respect to the x axis, and finally with respect to the y axis again. PHP Code: #cas RE: Kinematics Functions for Robotics - stevensito - 05-04-2022 10:42 PM It seems that id does not work. What firmware version are you using? |