Matlab Robot Toolbox (1) DH parameters and forward and inverse kinematics

The author is a junior student. This blog is used while learning. Please forgive me if there are any mistakes.

Attach the code at the end of the article.

1. DH parameters

The front coordinate system corresponds to the improved version: modified

The post coordinate system corresponds to the standard version: standard

Because most of the learning process is the front coordinate system, this article only discusses the front coordinate system.

2. Link function

The most commonly used code is the following:

 L =Link([theta D A alpha sigma offset], CONVENTION)

The parameter ‘alpha’ represents the torsion angle, the parameter ‘A’ represents the length of the member, the parameter ‘theta’ represents the joint angle, the parameter ‘D’ represents the transverse distance, and the parameter ‘sigma’ represents the joint type: 0 represents a rotating joint, non-0 represents movement joint.

The parameter CONVENTION can be ‘standard’ and ‘modified’, where ‘standard’ means using standard D-H parameters, and ‘modified’ means using improved D-H parameters.

Generally, it starts with four parameters. If less than six parameters are entered, the first few parameters are taken in sequence.

The moving axis of the moving joint is the Z axis. Remember to pay special attention when transforming.

Operation function

% A link transformation matrix
% RP joint type: ‘R’ or ‘P’
% friction friction
% nofriction Friction is ignored

% dyn displays kinetic parameters
% islimit tests whether the joint exceeds the soft limit
% isrevolute tests whether it is a rotating joint
% isprismatic tests whether it is a moving joint
% display Connecting rod parameters are displayed in table form
% char converted to string

For example:

3. SerialLink function

L(1) = Link([theta1, D1, A1, alpha1, sigma1,offset1], 'modified');
L(2) = Link([theta2, D2, A2, alpha2, sigma2,offset2], 'modified');
L(3) = Link([theta3, D3, A3, alpha3, sigma3,offset3], 'modified');
L(4) = Link([theta4, D4, A4, alpha4, sigma4,offset4], 'modified');
robot = SerialLink(L,'name','four');

This creation is relatively simple.

Operation function

% plot displays the robot graphically

% teach drives the robot

% isspherical tests whether the robot has a ball wrist joint

% islimit tests whether the robot reaches the joint limit

% fkine forward kinematics solution

% Inverse kinematics solution of ikine6s 6-axis ball wrist joint robot

% ikine3 Inverse kinematics solution for 3-axis robot

% ikine Inverse kinematics solution using iterative methods

% jacob0 Jacobian matrix described in the world coordinate system

% jacobn The Jacobian matrix described in the tool coordinate system

% maniplty Manipulability

% jtraj joint space trajectory

% accel joint acceleration

% coriolis joint Coriolis force

% dyn displays the dynamic properties of the connecting rod

% fdyn joint motion

% friction friction

% gravload joint gravity

% inertia joint inertia matrix

% nofriction sets friction to 0

% rne joint force/moment

% payload adds load to the end coordinate system

% perturb randomly perturbs the dynamic parameters of the connecting rod

For example:

robot.plot([0 0 0 0]);
robot.teach();

(Follow the code above)

Correct solution fkine

When entering unknown parameters, data overflow will occur, so I checked the source code of fkine

The following is the analysis of the source code

This function is used to calculate the pose of the robot’s end effector for a given joint configuration. Here are some key parts of the function explained:

  • Among the input parameters, robot is a SerialLink object, and q is the joint coordinates. If q is a matrix, the end-effector pose corresponding to each joint coordinate is calculated and the resulting three-dimensional matrix is returned.
  • If opt.deg is true, joint coordinates are assumed to be in degrees rather than radians (default is false).
  • If you need to output the pose of each joint coordinate system corresponding to all joint coordinates, you can set nargout to be greater than 1.
  • L is the joint chain information of the robot.
  • If q is a column vector (joint coordinates), the transformation matrix corresponding to each joint coordinate will be calculated sequentially and multiplied by the previous transformation matrix.
  • If q is a matrix (multiple joint coordinates), the transformation matrix corresponding to each joint coordinate will be calculated in a loop and the result will be stored in t.

The function of this function is to calculate the pose of the robot’s end effector based on the given joint coordinates. It can be calculated based on a single joint coordinate or multiple joint coordinates. And when the symbolic function is received, the matrix will be converted into a symbolic matrix for operation.

In other words, data overflow should not actually occur. Then why is this?

In fact, it is caused by floating point number operations.

If a matrix of floating point numbers is multiplied by a matrix containing symbolic variables, and the operation happens to involve 0, data overflow and other situations will occur. (The conclusion is drawn based on actual operation. I don’t know the specific principle. Welcome to discuss it in the comment area)

This week’s assignment is a forward kinematics solution with four joint degrees of freedom, and the final result is represented by symbolic parameters. I wrote the following code.

syms s1 s2 s3 s4 l0 l2 d4 real;
theta(1) = 0; D(1) = 0; A(1) = 0; alpha(1) = 0; sigma(1)=0; offset(1) = 0;
theta(2) = 0; D(2) = 0; A(2) = 0; alpha(2) = pi/2; sigma(2)=0; offset(2) = 0;
theta(3) = 0; D(3) = 0; A(3) = 1; alpha(3) = 0; sigma(3)=0; offset(3) = 0;
theta(4) = 0; D(4) = 1; A(4) = 0; alpha(4) = pi/2; sigma(4)=1; offset(4) = 0;
%DH method to establish model, joint angle, joint distance, connecting rod length, connecting rod angle, joint type (0 rotation, (1) movement), 'standard': establish standard D-H parameters
L((1)) = Link([theta(1), D(1), A(1), alpha(1), sigma(1),offset(1)], 'modified');
L((2)) = Link([theta(2), D(2), A(2), alpha(2), sigma(2),offset(2)], 'modified');
L((3)) = Link([theta(3), D(3), A(3), alpha(3), sigma(3),offset(3)], 'modified');
L((4)) = Link([theta(4), D(4), A(4), alpha(4), sigma(4),offset(4)], 'modified');
robot = SerialLink(L,'name','four');
robot.plot([0 0 0 0],'workspace',[-10,10,-10,10,-10,10)];
robot.teach();


 

Inverse solution ikine

This function is used to solve the inverse kinematics problem of the robot, that is, to calculate the robot joint angle value based on the position and attitude of the robot’s end effector. It mainly introduces how to use functions and the meaning of parameters and return values, including:

  1. Input parameters:
  • T: Represents the position and attitude of the end effector, which is a 4×4 homogeneous transformation matrix.
  • Q0: Indicates the initial estimated robot joint angle value (optional parameter, default is 0).
  • M: Represents the mask matrix, used to specify the ignored degrees of freedom (optional parameter).
  • OPTIONS: Indicates optimization options (optional parameters).
  1. return value:
  • Q: Represents the calculated robot joint angle value, which is an MxN matrix.

Among them, M represents the number of end effector positions and postures, and N represents the number of degrees of freedom of the robot.

In addition, the comments also introduce some considerations, such as:

  • This function uses pseudoinverse methods and iterative algorithms to solve inverse kinematics problems.
  • The inverse kinematics solution is not unique and depends on the initial estimate.
  • The pseudo-inverse method can obtain solutions at singular points, but the joint angle values in the null space are arbitrary.

In addition, the ikine function cannot accept a T matrix containing function parameters for operation, so some problems will occur and errors will be reported.

This means that when expressing parameters, you can only rub them by hand.

Is the assignment to find the inverse operation of a six-degree-of-freedom robotic arm, or is it represented by parameters? Does the question maker really use his or her brain?

Finish!

The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. Algorithm skill tree Home page Overview 57,300 people are learning the system