Color for pointcloud in occupancyMap3d
조회 수: 2 (최근 30일)
이전 댓글 표시
I want to make a 3d map with odometry + pointcloud, and for that im using this example (using pointcloud instead of just points). My robot gives me the pc in pointcloud2 format but i need the pointcloud format, so i just change it by doing
pc = pointCloud(pc_face.readXYZ, 'Color', pc_face.readRGB); %pc_face (pointcloud2)/ pc (pointcloud)
This works, but for some reason, the colors are not working for the pointcloud (photo at the end).
rosshutdown;
rosinit('http://192.168.123.161:11311');
go1_odom = rossubscriber('/tf');
fqGet = 1000; %frequency for getting topics
maxRange = 2;
go1_pc_face = rossubscriber('/camera1/point_cloud_face');
tStartOdom = tic;
[odomTF, status1, statusText1] = receive(go1_odom);
[pc_face, status2, statusText2] = receive(go1_pc_face);
map3D = occupancyMap3D(20);
while 1
[go1_test_msg, status1, statusText1] = receive(go1_odom);
if strcmp(go1_test_msg.Transforms.ChildFrameId, 'trunk')
odomTF = go1_test_msg;
end
tEndOdom = toc(tStartOdom);
%disp(1/tEndOdom)
if round(1/tEndOdom) <= fqGet
[pc_face, status2, statusText2] = receive(go1_pc_face);
%showdetails(odomTF);
%showdetails(pc_face);
xPos = odomTF.Transforms.Transform.Translation.X;
yPos = odomTF.Transforms.Transform.Translation.Y;
zPos = odomTF.Transforms.Transform.Translation.Z;
xRot = odomTF.Transforms.Transform.Rotation.X;
yRot = odomTF.Transforms.Transform.Rotation.Y;
zRot = odomTF.Transforms.Transform.Rotation.Z;
wRot = odomTF.Transforms.Transform.Rotation.W;
pose = [ xPos yPos zPos wRot xRot yRot zRot];
points = readXYZ(pc_face);
pc = pointCloud(pc_face.readXYZ, 'Color', pc_face.readRGB);
insertPointCloud(map3D,pose,pc,maxRange);
show(map3D);
fprintf('%d HZ\n',round(1/tEndOdom));
disp('-------------------------------------------------');
tStartOdom = tic;
end
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1618423/image.jpeg)
댓글 수: 4
Mann Baidi
2024년 2월 19일
Is the image above of "pc"(PointCloud)?
if yes, what is the issue with the color?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Specialized Messages에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!