-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with other URDF model with fixed joint and iiwa14 URDF model #23
Comments
Hello @yuying334, can you provide the code you using to compare the results of |
@yuying334 Unfortunately the fixed joint case is not supported for now , see #5. I will change the documentation to make it more explicit. |
Hello, I just change the file testJacobian.m to compare the results of urdf2casadi-matlab, iDynTree and geometricjacobian %% Choose a urdf model
close all
location_tests_folder = 'D:\urdf2casadi-matlab-master\urdf2casadi-matlab-master';
project_path=genpath(location_tests_folder);
addpath(project_path);
kuka_urdf = [location_tests_folder,'/URDFs/kr30_ha-identified.urdf'];
twoLink_urdf = [location_tests_folder,'/URDFs/twoLinks.urdf'];
kuka_kr210 = [location_tests_folder,'/URDFs/kuka_kr210.urdf'];
% dual_arm = [location_tests_folder,'/URDFs/model_left.urdf'];
iCub_r_leg = [location_tests_folder,'/URDFs/iCub_r_leg.urdf'];
iiwa14 = [location_tests_folder,'/URDFs/iiwa14.urdf'];
iCub_genova= [location_tests_folder,'/URDFs/iCubGenova9.urdf'];
%% Input urdf file to acquire robot structure
robot=importrobot('iiwa14.urdf');
robot.DataFormat='column';
robotURDFModel = iiwa14;
casadi_path='D:/casadi-windows-matlabR2016a-v3.5.5';
addpath(casadi_path)
urdf2casadi_path='D:/urdf2casadi-matlab-master';
addpath(urdf2casadi_path)
setenv("PATH",strcat("D:\conda\conda\envs\project-urdf2casadi\Library\bin", ";", getenv("PATH")));
addpath("D:\conda\conda\envs\project-urdf2casadi\Library\mex")
%% Generate functions
% Fix location folder to store the generated c and .mex files
location_generated_functions = [location_tests_folder,'/automaticallyGeneratedFunctions'];
opts.geneate_c_code = true;
opts.location_generated_fucntion = location_generated_functions;
opts.FrameVelocityRepresentation = "MIXED_REPRESENTATION";
[J_symb,X,XForce,S,O_X_ee] = urdf2casadi.Dynamics.auxiliarySymbolicDynamicsFunctions.createSpatialTransformsFunction(robotURDFModel,opts);
% IDynTree variables
mdlLoader = iDynTree.ModelCalibrationHelper();
mdlLoader.loadModelFromFile(robotURDFModel);
kinDynComp = iDynTree.KinDynComputations();
kinDynComp.loadRobotModel(mdlLoader.model());
% Set the body-fixed frame (left-trivialized velocity) representation
kinDynComp.setFrameVelocityRepresentation(iDynTree.MIXED_REPRESENTATION);
model_iDyn = kinDynComp.model();
nrOfJoints = model_iDyn.getNrOfJoints();
q_idyn = iDynTree.VectorDynSize(nrOfJoints);
dq_idyn = iDynTree.VectorDynSize(nrOfJoints);
grav = iDynTree.Vector3();
J_idyn = iDynTree.MatrixDynSize();
% Constants
gravityModulus = 9.80665;
baseFrame = 0;
eeFrame = 6;
nrOfTests = 10;
J_iDyn_list = zeros(6,nrOfJoints,nrOfTests);
J_symb_list = zeros(6,nrOfJoints,nrOfTests);
J_matlab_list= zeros(6,nrOfJoints,nrOfTests);
e_jac_DS = zeros(1,nrOfTests);
e_jac_GS = zeros(1,nrOfTests);
for i = 1:nrOfTests
jointPos = rand(nrOfJoints,1);
% Compute jacobian with iDynTree
q_idyn.fromMatlab(jointPos);
dq_idyn.fromMatlab(zeros(nrOfJoints,1));
grav.fromMatlab([0;0;-gravityModulus]);
kinDynComp.setRobotState(q_idyn, dq_idyn, grav);
kinDynComp.getRelativeJacobian(baseFrame, eeFrame, J_idyn);
J_tmp = J_idyn.toMatlab();
% Featherstone's notation considers first the angular part
J_iDyn_list(4:6,:,i) = J_tmp(1:3,:);
J_iDyn_list(1:3,:,i) = J_tmp(4:6,:);
% Compute Jacobian with symbolic function
J_symb_list(:,:,i) = full(J_symb(jointPos));
J_matlab_list(:,:,i) = full(geometricJacobian(robot,jointPos,robot.BodyNames{1,end}));
% Error in the norm of the difference of the Jacobians
e_jac_DS(:,i) = norm(J_symb_list(:,:,i) - J_iDyn_list(:,:,i));
e_jac_GS(:,i) = norm(J_iDyn_list(:,:,i) - J_matlab_list(:,:,i));
end
% Plot error
figure(1)
plot(e_jac_DS'); title('Error: norm(J_{symb} - J_{iDyn} )')
figure(2)
plot(e_jac_GS'); title('Error: norm(J_{symb} - J_{Geometric} )') |
@yuying334 Regarding the mismatch in the Jacobian computation the first thing that comes to my mind is to be sure to be using the same reference frame with respect to the Jacobian is computed. The notation I am using in this project and the algorithms come from the following sources:
I hope this can help a little in the debugging. |
Thank you for your support. I will cheack it out |
Hi, I still confused about the spatial motion transform from link i to any link j in its subtree: X{i}{1,j}, why it is a 6 by 6 matrix but not Homogeneous transformation martix namely 4 by 4 matrix? Thank you in advance. |
To which specific equation are you referring to? |
I can not finde the equation in the sources paper, I just want to figure out your code, for example, the function to calculate Kinematics in file "computeKinematics.m" with following code: % Import necessary functions %Gravity % smds.NB: The number of links excluding the base, which for now is considered |
@yuying334 This project uses the |
Hello,
There are some problems with the testing using URDF model like iiwa14. The jacobian matrix has significantly error using symbolic method comparing with using iDytree and with geometricjacobian in Matlab. Could you please add the literature for calculating jacobian that you refer to. And is there is fixed joint in urdf model, it can not work properly in file accountForFixedjoint. Thank you and looking forward to your response.
The text was updated successfully, but these errors were encountered: