@@ -13,43 +13,81 @@ using BSON
1313using Test
1414using Pkg
1515
16- import Caesar. _PCL: FieldMapper, createMapping, PointCloud, PointField, PCLPointCloud2, Header, asType, _PCL_POINTFIELD_FORMAT, FieldMapping, MsgFieldMap, FieldMatches
16+ # import Caesar._PCL: FieldMapper, createMapping, PointCloud, PointField, PCLPointCloud2, Header, asType, _PCL_POINTFIELD_FORMAT, FieldMapping, MsgFieldMap, FieldMatches
1717
1818
1919# #
2020@testset " test Caesar._PCL.PCLPointCloud2 to Caesar._PCL.PointCloud converter." begin
2121# #
2222
23- testdatafile = joinpath ( dirname (dirname (Pkg. pathof (Caesar))), " test" , " testdata" , " _PCLPointCloud2.bson" )
24-
23+ # testdatafile = joinpath( dirname(dirname(Pkg.pathof(Caesar))), "test", "testdata", "_PCLPointCloud2.bson")
2524# load presaved test data to test the coverter
26- BSON. @load testdatafile PointCloudRef PointCloudTest
25+ # BSON.@load testdatafile PointCloudRef PointCloudTest
26+
27+ # # build PCLPointCloud2 to be converted
28+
29+ datafile = joinpath ( dirname (dirname (Pkg. pathof (Caesar))), " test" , " testdata" , " _PCLPointCloud2_15776.dat" )
30+ fid = open (datafile," r" )
31+ data = read (fid)
32+ close (fid)
33+
34+ # #
35+
36+ pc2 = Caesar. _PCL. PCLPointCloud2 (;
37+ header = Caesar. _PCL. Header (;
38+ seq = 92147 ,
39+ stamp = 0x0005b24647c4af10 ,
40+ frame_id = " velodyne"
41+ ),
42+ height = 1 ,
43+ width = 493 ,
44+ fields = [
45+ Caesar. _PCL. PointField (" x" , 0x00000000 , Caesar. _PCL. _PCL_FLOAT32, 0x00000001 ),
46+ Caesar. _PCL. PointField (" y" , 0x00000004 , Caesar. _PCL. _PCL_FLOAT32, 0x00000001 ),
47+ Caesar. _PCL. PointField (" z" , 0x00000008 , Caesar. _PCL. _PCL_FLOAT32, 0x00000001 ),
48+ Caesar. _PCL. PointField (" intensity" , 0x00000010 , Caesar. _PCL. _PCL_FLOAT32, 0x00000001 )
49+ ],
50+ point_step = 32 ,
51+ row_step = 15776 ,
52+ is_dense = 1 ,
53+ data
54+ )
55+
2756
28- show (PointCloudTest[1 ])
57+ # #
58+
59+ show (pc2)
2960
3061# test major unpacking / type conversion needed by ROS.sensor_msgs.pointcloud2
31- pc = Caesar. _PCL. PointCloud (PointCloudTest[1 ])
62+ pc = Caesar. _PCL. PointCloud (pc2)
63+
64+ show (pc)
3265
3366@test pc. height == 1
3467@test pc. width == 493
3568@test pc. is_dense
3669
37- @test_broken length (pc. points) == 493
70+ @test length (pc. points) == 493
71+
72+ # #
73+
74+ # truncated copy of reference data on good to 1e-3
75+ @test isapprox ( [- 0 ,0 ,0 ], pc. points[1 ]. data[1 : 3 ], atol= 5e-3 )
76+ @test isapprox ( [- 1.56486 ,1.09851 ,0 ], pc. points[2 ]. data[1 : 3 ], atol= 5e-3 )
77+ @test isapprox ( [- 793.383 ,556.945 ,0 ], pc. points[3 ]. data[1 : 3 ], atol= 5e-3 )
78+ @test isapprox ( [- 0 ,0 ,0 ], pc. points[4 ]. data[1 : 3 ], atol= 5e-3 )
79+ @test isapprox ( [- 1.56148 ,1.10331 ,0 ], pc. points[5 ]. data[1 : 3 ], atol= 5e-3 )
80+ @test isapprox ( [- 788.548 ,557.169 ,0 ], pc. points[6 ]. data[1 : 3 ], atol= 5e-3 )
81+ @test isapprox ( [- 790.109 ,558.273 ,0 ], pc. points[7 ]. data[1 : 3 ], atol= 5e-3 )
82+ @test isapprox ( [- 791.671 ,559.376 ,0 ], pc. points[8 ]. data[1 : 3 ], atol= 5e-3 )
83+ @test isapprox ( [- 793.232 ,560.479 ,0 ], pc. points[9 ]. data[1 : 3 ], atol= 5e-3 )
84+ @test isapprox ( [- 794.794 ,561.583 ,0 ], pc. points[10 ]. data[1 : 3 ], atol= 5e-3 )
3885
39- for (i,pt) in enumerate (pc. points)
40- @test isapprox ( PointCloudRef[1 ][1 ,:], pt. data; atol= 1e-6 )
41- end
4286
43- # 231 fromPCLPointCloud2 (msg, cloud, field_map);
44- # (gdb) print field_map
45- # $7 = std::vector of length 1, capacity 4 = {{serialized_offset = 0,
46- # struct_offset = 0, size = 12}}
87+ # for (i,pt) in enumerate(pc.points)
88+ # @test isapprox( PointCloudRef[1][i,1:3], pt.data[1:3]; atol=1e-6)
89+ # end
4790
48- # (gdb) print cloud.points[0]
49- # $43 = {<pcl::_PointXYZ> = {{data = {-0, 0, 0, 1}, {x = -0, y = 0,
50- # z = 0}}}, <No data fields>}
51- # (gdb) print sizeof(cloud.points[0])
52- # $44 = 16
5391
5492# #
5593end
0 commit comments