-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
112 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function [ fullCloud ] = Local2GlobalMap( localCloud , MotionGlobal ,s ,mergeGrid ) | ||
%LOCAL2GLOBALMAP 此处显示有关此函数的摘要 | ||
% 此处显示详细说明 | ||
fullCloud=localCloud{1}; | ||
for tar=2:length(localCloud) | ||
transMotion=MotionGlobal{tar}; | ||
transMotion(1:3,4)=MotionGlobal{tar}(1:3,4)./s; | ||
TranCData= transMotion*[localCloud{tar}.Location';ones(1,localCloud{tar}.Count)]; | ||
tcloud=pointCloud( TranCData(1:3,:)'); | ||
fullCloud=pcmerge(fullCloud,tcloud,mergeGrid); | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,80 @@ | ||
|
||
clc;clear;close all; | ||
gridStep=0.04; | ||
gridStep=0.025; | ||
load Clear_OutSide; | ||
load outside_regis_motion_result; | ||
load outside_GRT; | ||
addpath('./flann'); | ||
addpath('./estimateRigidTransform/'); | ||
|
||
fullPointCloud=clouds{1}; | ||
mergeGrid=0.002; | ||
% fullPointCloud=clouds{1}; | ||
overlap=0.4; | ||
res=10; | ||
|
||
for i=2:N | ||
if(i~=22) | ||
transMatrix=p(i).M'; | ||
transMatrix(4,1:3)=transMatrix(4,1:3)./s; | ||
transFormCloud{i}=pctransform(clouds{i},affine3d(transMatrix)); | ||
fullPointCloud=pcmerge(fullPointCloud,transFormCloud{i},0.002); | ||
fullPointCloud=Local2GlobalMap(clouds,GrtM,s,mergeGrid); | ||
[tarDesp,tarSeed,tarNorm] = extractEig(fullPointCloud,gridStep); | ||
for tar= 12 | ||
|
||
|
||
% for i=2:N | ||
% if(i~=tar) | ||
% transMatrix=p(i).M'; | ||
% transMatrix(4,1:3)=transMatrix(4,1:3)./s; | ||
% transFormCloud{i}=pctransform(clouds{i},affine3d(transMatrix)); | ||
% fullPointCloud=pcmerge(fullPointCloud,transFormCloud{i},0.002); | ||
% end | ||
% end | ||
|
||
tic | ||
[srcDesp,srcSeed,srcNorm] = extractEig(clouds{tar},gridStep); | ||
T = eigMatch(tarDesp,srcDesp,tarSeed,srcSeed,tarNorm,srcNorm,overlap,gridStep); | ||
T = inv(T); | ||
R0= T(1:3,1:3); | ||
t0= T(1:3,4)*s; | ||
|
||
% | ||
Model= fullPointCloud.Location(1:res:end,:)'*s; | ||
Data= clouds{tar}.Location(1:res:end,:)'*s; | ||
% TData = transform_to_global(Data, R0, t0); | ||
[MSE,R,t,TData,PCorr, Dthr] = TrICP(Model, Data, R0, t0, 100, overlap); | ||
Motion=Rt2M(R,t); | ||
MotionbackUp=Motion; | ||
toc | ||
disp(['cloud ' num2str(tar) ' tested']); | ||
RotErr=norm((MotionbackUp(1:3,1:3)-GrtM{tar}(1:3,1:3)),'fro') | ||
|
||
TranErr=norm((MotionbackUp(1:3,4)-GrtM{tar}(1:3,4)),2) | ||
if(RotErr>0.1||TranErr>0.1) | ||
disp(['cannot relocate cloud ' num2str(tar)]); | ||
end | ||
end | ||
|
||
tic | ||
[tarDesp,tarSeed,tarNorm] = extractEig(fullPointCloud,gridStep); | ||
[srcDesp,srcSeed,srcNorm] = extractEig(clouds{22},gridStep); | ||
T = eigMatch(tarDesp,srcDesp,tarSeed,srcSeed,tarNorm,srcNorm,overlap,gridStep); | ||
T = inv(T); | ||
R0= T(1:3,1:3); | ||
t0= T(1:3,4)*s; | ||
|
||
|
||
Model= fullPointCloud.Location(1:res:end,:)'*s; | ||
Data= clouds{22}.Location(1:res:end,:)'*s; | ||
% TData = transform_to_global(Data, R0, t0); | ||
[MSE,R,t,TData,PCorr, Dthr] = TrICP(Model, Data, R0, t0, 100, overlap); | ||
Motion=Rt2M(R,t); | ||
MotionbackUp=Motion; | ||
toc | ||
|
||
RotErr=norm((MotionbackUp(1:3,1:3)-GrtM{22}(1:3,1:3)),'fro') | ||
|
||
TranErr=norm((MotionbackUp(1:3,4)./s-GrtM{22}(1:3,4)),2) | ||
|
||
|
||
% | ||
Motion=MotionbackUp; | ||
pnum=clouds{22}.Count; | ||
toshow=pointCloud(clouds{22}.Location,'Color',uint8([ zeros(pnum,1) ones(pnum,1) zeros(pnum,1)])); | ||
pnum=clouds{tar}.Count; | ||
toshow=pointCloud(clouds{tar}.Location,'Color',uint8([ zeros(pnum,1) ones(pnum,1) zeros(pnum,1)])); | ||
Motion=Motion'; | ||
Motion(4,1:3)=Motion(4,1:3)./s; | ||
pcshow( pctransform(toshow, affine3d(Motion))); | ||
hold on | ||
|
||
pcshow(fullPointCloud); | ||
xlabel('x'); | ||
ylabel('y'); | ||
zlabel('z'); | ||
axis([-1 1 -1 1 -0.2 0.6 ]); | ||
%չʾ·¾¶Í¼ | ||
figure; | ||
% figure; | ||
for i=1:N | ||
if(i~=22) | ||
cameraPosition(i,:)=p(i).M(1:3,4)'; | ||
if(i~=tar) | ||
cameraPosition(i,:)=GrtM{i}(1:3,4)'./s; | ||
else | ||
cameraPosition(i,:)=cameraPosition(i-1,:); | ||
end | ||
|
||
end | ||
plot(cameraPosition(:,1),cameraPosition(:,2),'-*') | ||
plot3(cameraPosition(:,1),cameraPosition(:,2),cameraPosition(:,3),'r-*'); | ||
hold on; | ||
plot(MotionbackUp(1,4),MotionbackUp(2,4),'bo') | ||
xlabel('x'); | ||
ylabel('y'); | ||
|
||
% axis([-0.5 0.5 -0.5 0.5 ]); | ||
plot3(MotionbackUp(1,4)/s,MotionbackUp(2,4)/s,MotionbackUp(3,4)/s,'bo'); | ||
% xlabel('x'); | ||
% ylabel('y'); | ||
% | ||
% % axis([-0.5 0.5 -0.5 0.5 ]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
function fullPointCloud = readCloudAsOne(filepath,prefix,readNum,mergeGridStep,s,relocoNUm) | ||
function fullPointCloud = readCloudAsOne(filepath,prefix,readNum,mergeGridStep,s,relocoNUm,GrtM) | ||
%READCLOUDASONE 此处显示有关此函数的摘要 | ||
% 此处显示详细说明 | ||
readNum=readNum-1; | ||
clouds=readCloudCsv(filepath,prefix,readNum,0,s); | ||
fullPointCloud=clouds{1}; | ||
for i=2:length(clouds) | ||
% if i~=relocoNUm | ||
fullPointCloud=pcmerge(fullPointCloud,clouds{i},mergeGridStep); | ||
disp([ 'cloud ' num2str(i) ' merged!'] ); | ||
% end | ||
end | ||
fullPointCloud=Local2GlobalMap(clouds,GrtM,s,mergeGridStep); | ||
|
||
% for i=2:length(clouds) | ||
% % if i~=relocoNUm | ||
% fullPointCloud=pcmerge(fullPointCloud,clouds{i},mergeGridStep); | ||
% disp([ 'cloud ' num2str(i) ' merged!'] ); | ||
% % end | ||
% end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters