From a1205263a5de664a04da797404044e2c1f874465 Mon Sep 17 00:00:00 2001 From: dehann Date: Fri, 22 Sep 2023 09:42:45 -0700 Subject: [PATCH 1/2] refactor and test LasIOExt --- Project.toml | 5 ++- ext/CaesarLasIOExt.jl | 10 +++++ ext/WeakdepsPrototypes.jl | 5 +++ .../_PCL => ext}/services/LasIOSupport.jl | 0 src/3rdParty/_PCL/_PCL.jl | 2 - test/pcl/testPointCloud2.jl | 37 ++++++++++++++----- 6 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 ext/CaesarLasIOExt.jl rename {src/3rdParty/_PCL => ext}/services/LasIOSupport.jl (100%) diff --git a/Project.toml b/Project.toml index eb9798310..ba5f97ab8 100644 --- a/Project.toml +++ b/Project.toml @@ -32,7 +32,6 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" KernelDensityEstimate = "2472808a-b354-52ea-a80e-1658a3c6056d" -LasIO = "570499db-eae3-5eb6-bdd5-a5326f375e68" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e" MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411" @@ -61,6 +60,7 @@ AprilTags = "f0fec3d5-a81e-5a6a-8c28-d2b34f3659de" ImageFeatures = "92ff4b2b-8094-53d3-b29d-97f740f06cef" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0" +LasIO = "570499db-eae3-5eb6-bdd5-a5326f375e68" ZMQ = "c2297ded-f4af-51ae-bb23-16f91089e4e1" [extensions] @@ -68,6 +68,7 @@ CaesarAprilTagsExt = "AprilTags" CaesarImageFeaturesExt = "ImageFeatures" CaesarImageMagickExt = "ImageMagick" CaesarImagesExt = "Images" +CaesarLasIOExt = "LasIO" CaesarZMQExt = "ZMQ" [compat] @@ -128,4 +129,4 @@ RobotOS = "22415677-39a4-5241-a37a-00beabbbdae8" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["AprilTags", "BSON", "DelimitedFiles", "Downloads", "GraphPlot", "Images", "PyCall", "Random", "RobotOS", "Test", "ZMQ"] +test = ["AprilTags", "BSON", "DelimitedFiles", "Downloads", "GraphPlot", "Images", "LasIO", "PyCall", "Random", "RobotOS", "Test", "ZMQ"] diff --git a/ext/CaesarLasIOExt.jl b/ext/CaesarLasIOExt.jl new file mode 100644 index 000000000..5dbc10fbd --- /dev/null +++ b/ext/CaesarLasIOExt.jl @@ -0,0 +1,10 @@ +module CaesarLasIOExt + +using LasIO +import Caesar._PCL as _PCL + +import Caesar: loadLAS, saveLLAS + +include("services/LasIOSupport.jl") + +end \ No newline at end of file diff --git a/ext/WeakdepsPrototypes.jl b/ext/WeakdepsPrototypes.jl index 84255f2da..36ea02fcd 100644 --- a/ext/WeakdepsPrototypes.jl +++ b/ext/WeakdepsPrototypes.jl @@ -94,6 +94,11 @@ export fetchDataImage function toFormat end function fetchDataImage end +## ============================================== +# LasIO + +function loadLAS end +function saveLAS end ## ============================================== # CaesarZMQExt prototypes diff --git a/src/3rdParty/_PCL/services/LasIOSupport.jl b/ext/services/LasIOSupport.jl similarity index 100% rename from src/3rdParty/_PCL/services/LasIOSupport.jl rename to ext/services/LasIOSupport.jl diff --git a/src/3rdParty/_PCL/_PCL.jl b/src/3rdParty/_PCL/_PCL.jl index 107366410..20b45718e 100644 --- a/src/3rdParty/_PCL/_PCL.jl +++ b/src/3rdParty/_PCL/_PCL.jl @@ -27,7 +27,6 @@ using DistributedFactorGraphs using TensorCast using UUIDs using MultivariateStats -using LasIO # FIXME REMOVE, only used for legacy getDataPointCloud using Serialization @@ -53,7 +52,6 @@ include("entities/PCLTypes.jl") # bring in further source code include("services/GeomBasicsUtils.jl") include("services/PointCloud.jl") -include("services/LasIOSupport.jl") include("services/PointCloudUtils.jl") include("services/ConsolidateRigidTransform.jl") include("services/ICP_Simple.jl") diff --git a/test/pcl/testPointCloud2.jl b/test/pcl/testPointCloud2.jl index 2a3618d1d..1a35bb2c7 100644 --- a/test/pcl/testPointCloud2.jl +++ b/test/pcl/testPointCloud2.jl @@ -18,7 +18,10 @@ using Pkg using Downloads using DelimitedFiles +using LasIO + # import Caesar._PCL: FieldMapper, createMapping, PointCloud, PointField, PCLPointCloud2, Header, asType, _PCL_POINTFIELD_FORMAT, FieldMapping, MsgFieldMap, FieldMatches + ## @info "download any necessary test data" @@ -32,16 +35,21 @@ function downloadTestData(datafile, url) return datafile end -testdatafolder = "/tmp/caesar/testdata/" +testdatafolder = joinpath(tempdir(), "caesar", "testdata") # "/tmp/caesar/testdata/" + +radarpclfile = joinpath( testdatafolder,"radar", "convertedRadar", "_PCLPointCloud2_15776.dat") +radarpcl_url = "https://github.com/JuliaRobotics/CaesarTestData.jl/raw/main/data/radar/convertedRadar/_PCLPointCloud2_15776.dat" +downloadTestData(radarpclfile,radarpcl_url) + +pandarfile = joinpath(testdatafolder,"lidar","simpleICP","_pandar_PCLPointCloud2.jldat") +pandar_url = "https://github.com/JuliaRobotics/CaesarTestData.jl/raw/main/data/lidar/pandar/_pandar_PCLPointCloud2.jldat" +downloadTestData(pandarfile,pandar_url) ## @testset "test Caesar._PCL.PCLPointCloud2 to Caesar._PCL.PointCloud converter." begin ## -radarpclfile = joinpath( testdatafolder,"radar", "convertedRadar", "_PCLPointCloud2_15776.dat") -radarpcl_url = "https://github.com/JuliaRobotics/CaesarTestData.jl/raw/main/data/radar/convertedRadar/_PCLPointCloud2_15776.dat" -downloadTestData(radarpclfile,radarpcl_url) # testdatafile = joinpath( pkgdir(Caesar), "test", "testdata", "_PCLPointCloud2.bson") # load presaved test data to test the coverter # BSON.@load testdatafile PointCloudRef PointCloudTest @@ -131,6 +139,22 @@ pc_ = Caesar._PCL.apply(M, rPc, pc) @test isapprox( [1-794.794,561.583,0], pc_.points[10].data[1:3], atol=5e-3) +## + +@testset "Test CaesarLasIOExt" begin +## + +testlaspath = joinpath(testdatafolder, "radar", "convertedRadar", "PointCloud_15776.las") + +Caesar.saveLAS(testlaspath, pc) + +pc_load = Caesar.loadLAS(testlaspath) + +show(pc_load) + +## +end + ## end @@ -140,11 +164,6 @@ if v"1.7" <= VERSION @testset "PandarXT test point cloud conversion test" begin ## -pandarfile = joinpath(testdatafolder,"lidar","simpleICP","_pandar_PCLPointCloud2.jldat") -pandar_url = "https://github.com/JuliaRobotics/CaesarTestData.jl/raw/main/data/lidar/pandar/_pandar_PCLPointCloud2.jldat" -downloadTestData(pandarfile,pandar_url) - - # Alternative approach, see more hardcoded test data example (only .data writen to binary) for _PCLPointCloud2_15776.dat" @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+" pc2 = Serialization.deserialize(pandarfile) From 5d6ad6612db74e366f3cfa506b6a40f4aa831757 Mon Sep 17 00:00:00 2001 From: dehann Date: Fri, 22 Sep 2023 12:25:16 -0700 Subject: [PATCH 2/2] lasio ext and new test --- ext/CaesarLasIOExt.jl | 6 +++++- ext/services/LasIOSupport.jl | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/CaesarLasIOExt.jl b/ext/CaesarLasIOExt.jl index 5dbc10fbd..4eb277596 100644 --- a/ext/CaesarLasIOExt.jl +++ b/ext/CaesarLasIOExt.jl @@ -1,9 +1,13 @@ module CaesarLasIOExt using LasIO +using FileIO +using Dates +using StaticArrays + import Caesar._PCL as _PCL -import Caesar: loadLAS, saveLLAS +import Caesar: loadLAS, saveLAS include("services/LasIOSupport.jl") diff --git a/ext/services/LasIOSupport.jl b/ext/services/LasIOSupport.jl index 37de0e56d..20ab56e41 100644 --- a/ext/services/LasIOSupport.jl +++ b/ext/services/LasIOSupport.jl @@ -25,15 +25,15 @@ function loadLAS( RGB(pnt.red, pnt.green, pnt.blue) end - colored_points = PointXYZ.(colors, pts) - return PointCloud(;points=colored_points, width=UInt32(length(colored_points)), height=UInt32(1)) + colored_points = _PCL.PointXYZ.(colors, pts) + return _PCL.PointCloud(;points=colored_points, width=UInt32(length(colored_points)), height=UInt32(1)) end # TODO, make save LAS function saveLAS( filepath::Union{<:AbstractString, <:Stream}, - pc::PointCloud; + pc::_PCL.PointCloud; scale=1000 )