Skip to content

Commit

Permalink
Merge pull request #984 from JuliaRobotics/23Q3/refac/lasioext
Browse files Browse the repository at this point in the history
LasIOExt
  • Loading branch information
dehann authored Sep 22, 2023
2 parents 9ff48fe + 5d6ad66 commit fe28af9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 16 deletions.
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -61,13 +60,15 @@ 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]
CaesarAprilTagsExt = "AprilTags"
CaesarImageFeaturesExt = "ImageFeatures"
CaesarImageMagickExt = "ImageMagick"
CaesarImagesExt = "Images"
CaesarLasIOExt = "LasIO"
CaesarZMQExt = "ZMQ"

[compat]
Expand Down Expand Up @@ -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"]
14 changes: 14 additions & 0 deletions ext/CaesarLasIOExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module CaesarLasIOExt

using LasIO
using FileIO
using Dates
using StaticArrays

import Caesar._PCL as _PCL

import Caesar: loadLAS, saveLAS

include("services/LasIOSupport.jl")

end
5 changes: 5 additions & 0 deletions ext/WeakdepsPrototypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export fetchDataImage
function toFormat end
function fetchDataImage end

## ==============================================
# LasIO

function loadLAS end
function saveLAS end

## ==============================================
# CaesarZMQExt prototypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 0 additions & 2 deletions src/3rdParty/_PCL/_PCL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ using DistributedFactorGraphs
using TensorCast
using UUIDs
using MultivariateStats
using LasIO

# FIXME REMOVE, only used for legacy getDataPointCloud
using Serialization
Expand All @@ -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")
Expand Down
37 changes: 28 additions & 9 deletions test/pcl/testPointCloud2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit fe28af9

Please sign in to comment.