Color for pointcloud in occupancyMap3d
5 views (last 30 days)
Show older comments
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
4 Comments
Mann Baidi
on 19 Feb 2024
Is the image above of "pc"(PointCloud)?
if yes, what is the issue with the color?
Answers (0)
See Also
Categories
Find more on Specialized Messages 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!