How does Forward kinematik work in Robotics System Toolbox?
2 Comments
Hi @Peter Abt ,
When you loaded a robot model using `loadrobot`, it created a `rigidBodyTree` object which encapsulated the kinematic and dynamic properties of the robot which includes predefined joint limits, gravity and other characteristics that are not present when you manually defined the robot's kinematics using DH parameters. Also, your DH parameters are defined based on the robot's geometry and do not change with or without loading robot.
After going through loadrobot function defined in link below
https://www.mathworks.com/help/robotics/ref/loadrobot.html
I found out how gravity was defined in rigidBodyTree with properties of your robot, and it indicated the absence of gravity in your model ([0 0 0]) which implied that the calculations were performed in a zero-gravity environment, which really simplifies the kinematic analysis but may not reflect real-world conditions.
%% get robot model
close all
gen3 = loadrobot("kinovaGen3");
disp(gen3);
rigidBodyTree with properties:
NumBodies: 8
Bodies: {1x8 cell}
Base: [1x1 rigidBody]
BodyNames: {1x8 cell}
BaseName: 'base_link'
Gravity: [0 0 0]
DataFormat: 'struct'
Also, it show that dynamic effects are not being considered during calculations when the robot is loaded. So, based on attached results after this time experimenting with your code, it provided the following matrices as follows:
DH Matrix ( H_{DH} )
0.9806 -0.0749 0.1814 -0.5673
0.1771 -0.0603 -0.9823 -0.0830
0.0845 0.9954 -0.0459 0.2077
0 0 0 1.0000Model Matrix ( H_{mod} )
0.9806 -0.0749 0.1814 -0.5674
0.1771 -0.0603 -0.9823 -0.0810
0.0845 0.9954 -0.0459 0.2075
0 0 0 1.0000Here is my analysis of the differences mentioned below.
As you will notice that the first three columns of both matrices are identical, indicating that the rotation components are consistent across both methods. This suggests that the orientation of the end effector is accurately represented in both cases. However, the discrepancies found in the last column of the matrices shows H_DH has a value of (-0.5673) and (-0.0830) in the last column while H_mod has values of (-0.5674) and (-0.0810) which you noted and shared with us. After careful analysis, these differences, while seemingly minor, can have significant implications in applications requiring high precision, such as robotic manipulation tasks. Also, this shows that robot's physical constraints might be introducing slight offsets and the `loadrobot` function incorporates additional details about the robot’s geometry that are not captured in your manual DH parameter definitions. So, at this point, to further investigate these discrepancies, try modifying the gravity settings in your `rigidBodyTree` and observe how it affects your forward kinematics results and consider importing a different robot model using URDF or SDF formats to see if this yields different results compared to manually defined DH parameters. Also, utilizing visualization tools within MATLAB to compare positions graphically. This could provide intuitive insights into where and why offsets occur. By understanding these internal workings and exploring the various factors influencing kinematic computations, you can achieve more accurate results aligned with real-world scenarios in robotic applications.
I forgot to address your query about dynamic simulations of joint stiffness since you raised a question about it. While the toolbox does allow for dynamic modeling (e.g., simulating forces due to gravity or inertia), if your model is set to zero gravity, these effects won't be accounted for. If you want to analyze dynamics, consider enabling gravity and observing how it affects your calculations. So, I will suggest import your own robot model to see compare the results by using importrobot function in code below.
https://www.mathworks.com/help/robotics/ref/importrobot.html
I would like @Garmit Pant to share his opinion on this as well. Hope this helps. Please let me know if you have any further questions.
Hi @Peter Abt,
Forgot to attached plots of visualization of robot arm and experimentation with your code.





Hope, these plots will help you visualize the results better. Like I mentioned in my comments, “utilizing visualization tools within MATLAB to compare positions graphically” to help resolve issues especially when dealing with degree of freedom.
Accepted Answer
More Answers (2)
Hi @Peter Abt ,
Addressing your query regarding, “How does the Robot System Toolbox work internally? “
Begin with the “User’s Guide” for a holistic understanding followed by the “Reference” document for deeper insights into specific functions by clicking the link below. This approach will provide both a broad overview and detailed technical information necessary for grasping how the Robot System Toolbox operates internally in MATLAB.
https://www.mathworks.com/help/pdf_doc/robotics/index.html
Now, coming back to, “I noticed some small offset in the results of the Forward Kinematics if I compare the result of getTransform with the plain geometric Forward Kinematics calculated with the parameters from the Datasheet (p. 61). The offset also seems to be dynamic. So I wonder what the reason could be. Is there some kind of dynamic simulation of the joints stiffnes?”
The getTransform function expects the joint angles in radians, while the code snippet uses a division by 180 and multiplication by π to convert degrees to radians. However, the conversion is applied incorrectly in the context of the getTransform function call.
In the line:
H_mod = getTransform(gen3, q/180*pi', eeName)
The joint angles are being transposed ('), which is unnecessary and may lead to incorrect dimensions. The correct approach should be:
H_mod = getTransform(gen3, q * (pi / 180), eeName)
This change will make sure that the joint angles are correctly interpreted by the getTransform function, potentially eliminating the observed offset. Hope this helps. Please let me know if you have any further questions.
3 Comments
0 votes
Hi @Peter Abt ,
When you loaded a robot model using `loadrobot`, it created a `rigidBodyTree` object which encapsulated the kinematic and dynamic properties of the robot which includes predefined joint limits, gravity and other characteristics that are not present when you manually defined the robot's kinematics using DH parameters. Also, your DH parameters are defined based on the robot's geometry and do not change with or without loading robot.
After going through loadrobot function defined in link below
https://www.mathworks.com/help/robotics/ref/loadrobot.html
I found out how gravity was defined in rigidBodyTree with properties of your robot, and it indicated the absence of gravity in your model ([0 0 0]) which implied that the calculations were performed in a zero-gravity environment, which really simplifies the kinematic analysis but may not reflect real-world conditions.
%% get robot model
close all
gen3 = loadrobot("kinovaGen3");
disp(gen3);
rigidBodyTree with properties:
NumBodies: 8
Bodies: {1x8 cell}
Base: [1x1 rigidBody]
BodyNames: {1x8 cell}
BaseName: 'base_link'
Gravity: [0 0 0]
DataFormat: 'struct'
Also, it show that dynamic effects are not being considered during calculations when the robot is loaded. So, based on attached results after this time experimenting with your code, it provided the following matrices as follows:
DH Matrix ( H_{DH} )
0.9806 -0.0749 0.1814 -0.5673
0.1771 -0.0603 -0.9823 -0.0830
0.0845 0.9954 -0.0459 0.2077
0 0 0 1.0000Model Matrix ( H_{mod} )
0.9806 -0.0749 0.1814 -0.5674
0.1771 -0.0603 -0.9823 -0.0810
0.0845 0.9954 -0.0459 0.2075
0 0 0 1.0000Here is my analysis of the differences mentioned below.
As you will notice that the first three columns of both matrices are identical, indicating that the rotation components are consistent across both methods. This suggests that the orientation of the end effector is accurately represented in both cases. However, the discrepancies found in the last column of the matrices shows H_DH has a value of (-0.5673) and (-0.0830) in the last column while H_mod has values of (-0.5674) and (-0.0810) which you noted and shared with us. After careful analysis, these differences, while seemingly minor, can have significant implications in applications requiring high precision, such as robotic manipulation tasks. Also, this shows that robot's physical constraints might be introducing slight offsets and the `loadrobot` function incorporates additional details about the robot’s geometry that are not captured in your manual DH parameter definitions. So, at this point, to further investigate these discrepancies, try modifying the gravity settings in your `rigidBodyTree` and observe how it affects your forward kinematics results and consider importing a different robot model using URDF or SDF formats to see if this yields different results compared to manually defined DH parameters. Also, utilizing visualization tools within MATLAB to compare positions graphically. This could provide intuitive insights into where and why offsets occur. By understanding these internal workings and exploring the various factors influencing kinematic computations, you can achieve more accurate results aligned with real-world scenarios in robotic applications.
I forgot to address your query about dynamic simulations of joint stiffness since you raised a question about it. While the toolbox does allow for dynamic modeling (e.g., simulating forces due to gravity or inertia), if your model is set to zero gravity, these effects won't be accounted for. If you want to analyze dynamics, consider enabling gravity and observing how it affects your calculations. So, I will suggest import your own robot model to see compare the results by using importrobot function in code below.
https://www.mathworks.com/help/robotics/ref/importrobot.html
I would like @Garmit Pant to share his opinion on this as well. Hope this helps. Please let me know if you have any further questions.
Categories
Find more on Manipulator Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!