This repository contains the development of the inverse kinematics of the pincher x100 robot1, as well as a simple trajectory to perform a pick and place task.
- ROS Noetic
- ROS toolbox for MATLAB
- Robotics toolbox for MATLAB 2
- Type 1 and type 2 parts
- Pynput library for python (
pip install pynput
orpip3 install pynput
) - PincherX 100 Robot arm 1
- Pincher X100 description package
To find the inverse kinematics of the pincher x100 a geometrical approach with a wrist decoupling is used, the following diagram is used for this purpose:
Note: For a more detailed view of the location of the frames and the dimensions of the robot see the README file of the px100_description package.
It is trivial to see that being a planar mechanism the value of
where
In order to reduce the number of variables, the wrist is decoupled from the last joint. Therefore, the position of the TCP is moved a distance of
where
With all these simplifications made, the problem of the inverse kinematics of the robot is reduced to that of a 2R mechanism. This mechanism has two possible solutions, elbow up and elbow down.
the equations of the 2R mechanism are:
To define the elbow up and elbow down solution, the following equations are used:
Joint | Elbow up | Elbow down |
---|---|---|
Once the angles of the waist, shoulder and elbow are defined, the wrist is reattached and the angle of the wrist is defined as:
where
Note: The development of this equations is done in ikine funtion for matlab or PXrobot ikine method for python.
the workspace can be represented in a plane as shown in the image below, and with this figure we can make a revolution in the
We found six methods for determining inverse kinematics with roboticstoolbox in python, its methods are going to describe one by one:
-
ikine_6s
: inverse kinematics for 6-axis spherical wrist revolute robot, for more information you can make clic here. -
ikine_LM
: This method use the numerical inverse kinematics by Levenberg-Marquadt optimization and return the inverse kinematic solution of the robot, also this method can be used for robots with any number of degrees of freedom. For more information you can make clic here. -
ikine_LMS
: This method return the inverse kinematic solution using numerical inverse kinematics by Levenberg-Marquadt optimization. For more information you can make clic here. -
ikine_global
: In this moment the method ikine_global is for using SciPy global optimizers. For more information you can make clic here. -
ikine_min
: This method allows to find Inverse kinematics by optimization with joint limits.For more information you can make clic here. -
ikine_a
: This method use an analytic inverse kinematic solution to return a joint angle vector in radians. For more information you can make clic here.
The robot has 4 DOF, 3 of them are used for position but the measurement of the fourth DOF is the angle that rotates around the open axis.
The phantom x robot has two possible solutions, the first is denominate "elbow up" and the second is called "elbow down". We can see the two configurations in the image of 2R mechanism.
The reachable workspace is the volume whereby the end effector is capable of reaching each point within the space in at least one orientation while the dextrous workspace has the end effector capable of reaching all points in all orientations3.
For the development of a pick and place routine, the following parts were 3D printed:
Part type 1 is initially located to the right of the robot, and part type 2 to the left. The challenge is to pick piece type 1 and place it in front, then take piece 2 and insert it into piece 1 which is now in front.
For this we developed a code in python, using the robotics toolbox by Peter Corke where initially the robot was created with the DHrobot
class, and then 3 homogeneous transformation matrices where the robot is going to move, these are:
-
$T_{p_1}$ : The transformation matrix that locates the TCP in Part 1. -
$T_{p_2}$ : The transformation matrix that locates the TCP in Part 2. -
$T_{p_g}$ : The transformation matrix that locates the TCP in the goal pose (front of the robot).
One constraint is that the movements must be vertical for ascending and descending, and horizontal for moving, therefore, a safe zone height (
-
$T_{p_1h}$ : The transformation matrix that locates the TCP above Part 1 at the height of the safe zone. -
$T_{p_2h}$ : The transformation matrix that locates the TCP above Part 2 at the height of the safe zone. -
$T_{p_gh}$ : The transformation matrix that locates the TCP above Part 1 at the height of the safe zone.
Once these transformation matrices are defined, the robot inverse kinematics method is used to know the state of the joints corresponding to each matrix, this in order to use the jtraj
function of the toolbox to interpolate in the joint space, this function has the following syntax:
q = rtb.jtraj(q0, qg, n)
Where
$T_{home}\to T_{p_1h}$ $T_{p_1h}\to T_{p_1}$ $T_{p_1}\to T_{p_1h}$ $T_{p_1h}\to T_{p_gh}$ $T_{p_gh}\to T_{p_g}$ $T_{p_g}\to T_{p_gh}$ $T_{p_gh}\to T_{p_2h}$ $T_{p_2h}\to T_{p_2}$ $T_{p_2}\to T_{p_2h}$ $T_{p_2h}\to T_{p_gh}$ $T_{p_gh}\to T_{p_g}$ $T_{p_g}\to T_{p_gh}$ $T_{p_gh}\to T_{home}$
Finally, to operate the griper, closing commands are sent after moves 2 and 8 (grasp), and opening commands after moves 5 and 11 (release). This is done with the service dynamixel_workbench/dynamixel_command
.
Now, an algorithm is performed to move the robot in the workspace. As the pincher x100 is a 4 DOF robot, a pure motion is performed on its 4 axes:
- Translation in X -
trax
- Translation in Y -
tray
- Translation in Z -
traz
- Rotation about the O axis of TCP -
rot
These movements are performed from keyboard commands using the pynput library. The available commands are:
- w: Select next axis.
- s: Select previous axis.
- a: Move the establish step in positive direction along the selected axis.
- d: Move the establish step in negative direction along the selected axis.
To calculate the movements in the workspace, first the step is defined, this is:
-
$0.02~m$ for translational motion. -
$0.002~rad$ for rotational motion
Then, the current state of the joints is read using the /joint_states topic and with the fkine
function of the toolbox it is possible to calculate the TCP transformation matrix. Depending on the axis of motion that is being controlled the transformation matrix goal is calculated, if they are the translational motion axes the step is added (or subtracted in case it moves in positive direction) in the corresponding translation component:
While for the rotation, the transformation matrix is multiplied by a pure rotation on the y-axis.
With the origin and goal matrices established, we must interpolate between the two, for this we use the function ctraj
which interpolates in Cartesian space (unlike jtraj
which interpolates in joint space). This function receives three parameters just like jtraj
:
T = rtb.ctraj(T0,Tg,n)
the difference is that this one receives the transformation matrices but keeps the
Finally, to each of the interpolation matrices we do inverse kinematics to find q and with the sendJoints
function we send the target position to each motor.
in order to view the robot in rviz the same configuration file of the px100_description package is used and the state of the joints are mapped from the topical /dynamixel_workbench/joint_states to /joint_states.
The correct elaboration of the inverse kinematics is of utmost importance because in a simulation the robot can cross its own links, but in reality if this happens while using the robot in a physical way it can suffer serious damage. On the other hand, although the inverse kinematics yields the exact joint configuration to achieve a given pose, care must be taken as the quality of the sensors affects the measurement and therefore arrive at an approximate pose but not the real one as was the case in the pick and place task.