Skip to content

Commit fe28af9

Browse files
authored
Merge pull request #984 from JuliaRobotics/23Q3/refac/lasioext
LasIOExt
2 parents 9ff48fe + 5d6ad66 commit fe28af9

File tree

6 files changed

+53
-16
lines changed

6 files changed

+53
-16
lines changed

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
3232
JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3"
3333
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
3434
KernelDensityEstimate = "2472808a-b354-52ea-a80e-1658a3c6056d"
35-
LasIO = "570499db-eae3-5eb6-bdd5-a5326f375e68"
3635
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3736
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
3837
MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411"
@@ -61,13 +60,15 @@ AprilTags = "f0fec3d5-a81e-5a6a-8c28-d2b34f3659de"
6160
ImageFeatures = "92ff4b2b-8094-53d3-b29d-97f740f06cef"
6261
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
6362
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
63+
LasIO = "570499db-eae3-5eb6-bdd5-a5326f375e68"
6464
ZMQ = "c2297ded-f4af-51ae-bb23-16f91089e4e1"
6565

6666
[extensions]
6767
CaesarAprilTagsExt = "AprilTags"
6868
CaesarImageFeaturesExt = "ImageFeatures"
6969
CaesarImageMagickExt = "ImageMagick"
7070
CaesarImagesExt = "Images"
71+
CaesarLasIOExt = "LasIO"
7172
CaesarZMQExt = "ZMQ"
7273

7374
[compat]
@@ -128,4 +129,4 @@ RobotOS = "22415677-39a4-5241-a37a-00beabbbdae8"
128129
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
129130

130131
[targets]
131-
test = ["AprilTags", "BSON", "DelimitedFiles", "Downloads", "GraphPlot", "Images", "PyCall", "Random", "RobotOS", "Test", "ZMQ"]
132+
test = ["AprilTags", "BSON", "DelimitedFiles", "Downloads", "GraphPlot", "Images", "LasIO", "PyCall", "Random", "RobotOS", "Test", "ZMQ"]

ext/CaesarLasIOExt.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module CaesarLasIOExt
2+
3+
using LasIO
4+
using FileIO
5+
using Dates
6+
using StaticArrays
7+
8+
import Caesar._PCL as _PCL
9+
10+
import Caesar: loadLAS, saveLAS
11+
12+
include("services/LasIOSupport.jl")
13+
14+
end

ext/WeakdepsPrototypes.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ export fetchDataImage
9494
function toFormat end
9595
function fetchDataImage end
9696

97+
## ==============================================
98+
# LasIO
99+
100+
function loadLAS end
101+
function saveLAS end
97102

98103
## ==============================================
99104
# CaesarZMQExt prototypes

src/3rdParty/_PCL/services/LasIOSupport.jl renamed to ext/services/LasIOSupport.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ function loadLAS(
2525
RGB(pnt.red, pnt.green, pnt.blue)
2626
end
2727

28-
colored_points = PointXYZ.(colors, pts)
29-
return PointCloud(;points=colored_points, width=UInt32(length(colored_points)), height=UInt32(1))
28+
colored_points = _PCL.PointXYZ.(colors, pts)
29+
return _PCL.PointCloud(;points=colored_points, width=UInt32(length(colored_points)), height=UInt32(1))
3030
end
3131

3232

3333
# TODO, make save LAS
3434
function saveLAS(
3535
filepath::Union{<:AbstractString, <:Stream},
36-
pc::PointCloud;
36+
pc::_PCL.PointCloud;
3737
scale=1000
3838
)
3939

src/3rdParty/_PCL/_PCL.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ using DistributedFactorGraphs
2727
using TensorCast
2828
using UUIDs
2929
using MultivariateStats
30-
using LasIO
3130

3231
# FIXME REMOVE, only used for legacy getDataPointCloud
3332
using Serialization
@@ -53,7 +52,6 @@ include("entities/PCLTypes.jl")
5352
# bring in further source code
5453
include("services/GeomBasicsUtils.jl")
5554
include("services/PointCloud.jl")
56-
include("services/LasIOSupport.jl")
5755
include("services/PointCloudUtils.jl")
5856
include("services/ConsolidateRigidTransform.jl")
5957
include("services/ICP_Simple.jl")

test/pcl/testPointCloud2.jl

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ using Pkg
1818
using Downloads
1919
using DelimitedFiles
2020

21+
using LasIO
22+
2123
# import Caesar._PCL: FieldMapper, createMapping, PointCloud, PointField, PCLPointCloud2, Header, asType, _PCL_POINTFIELD_FORMAT, FieldMapping, MsgFieldMap, FieldMatches
24+
2225
##
2326

2427
@info "download any necessary test data"
@@ -32,16 +35,21 @@ function downloadTestData(datafile, url)
3235
return datafile
3336
end
3437

35-
testdatafolder = "/tmp/caesar/testdata/"
38+
testdatafolder = joinpath(tempdir(), "caesar", "testdata") # "/tmp/caesar/testdata/"
39+
40+
radarpclfile = joinpath( testdatafolder,"radar", "convertedRadar", "_PCLPointCloud2_15776.dat")
41+
radarpcl_url = "https://github.com/JuliaRobotics/CaesarTestData.jl/raw/main/data/radar/convertedRadar/_PCLPointCloud2_15776.dat"
42+
downloadTestData(radarpclfile,radarpcl_url)
43+
44+
pandarfile = joinpath(testdatafolder,"lidar","simpleICP","_pandar_PCLPointCloud2.jldat")
45+
pandar_url = "https://github.com/JuliaRobotics/CaesarTestData.jl/raw/main/data/lidar/pandar/_pandar_PCLPointCloud2.jldat"
46+
downloadTestData(pandarfile,pandar_url)
3647

3748

3849
##
3950
@testset "test Caesar._PCL.PCLPointCloud2 to Caesar._PCL.PointCloud converter." begin
4051
##
4152

42-
radarpclfile = joinpath( testdatafolder,"radar", "convertedRadar", "_PCLPointCloud2_15776.dat")
43-
radarpcl_url = "https://github.com/JuliaRobotics/CaesarTestData.jl/raw/main/data/radar/convertedRadar/_PCLPointCloud2_15776.dat"
44-
downloadTestData(radarpclfile,radarpcl_url)
4553
# testdatafile = joinpath( pkgdir(Caesar), "test", "testdata", "_PCLPointCloud2.bson")
4654
# load presaved test data to test the coverter
4755
# BSON.@load testdatafile PointCloudRef PointCloudTest
@@ -131,6 +139,22 @@ pc_ = Caesar._PCL.apply(M, rPc, pc)
131139
@test isapprox( [1-794.794,561.583,0], pc_.points[10].data[1:3], atol=5e-3)
132140

133141

142+
##
143+
144+
@testset "Test CaesarLasIOExt" begin
145+
##
146+
147+
testlaspath = joinpath(testdatafolder, "radar", "convertedRadar", "PointCloud_15776.las")
148+
149+
Caesar.saveLAS(testlaspath, pc)
150+
151+
pc_load = Caesar.loadLAS(testlaspath)
152+
153+
show(pc_load)
154+
155+
##
156+
end
157+
134158
##
135159
end
136160

@@ -140,11 +164,6 @@ if v"1.7" <= VERSION
140164
@testset "PandarXT test point cloud conversion test" begin
141165
##
142166

143-
pandarfile = joinpath(testdatafolder,"lidar","simpleICP","_pandar_PCLPointCloud2.jldat")
144-
pandar_url = "https://github.com/JuliaRobotics/CaesarTestData.jl/raw/main/data/lidar/pandar/_pandar_PCLPointCloud2.jldat"
145-
downloadTestData(pandarfile,pandar_url)
146-
147-
148167
# Alternative approach, see more hardcoded test data example (only .data writen to binary) for _PCLPointCloud2_15776.dat"
149168
@info "Loading testdata/_pandar_PCLPointCloud2.jldat which via `Serialization.serialize` of a `Caesar._PCL.PCLPointCloud2` object, at JL 1.7.3, CJL v0.13.1+"
150169
pc2 = Serialization.deserialize(pandarfile)

0 commit comments

Comments
 (0)