Skip to content

Commit d3d8ab3

Browse files
committed
some code cleanup
1 parent dbe8e3f commit d3d8ab3

4 files changed

Lines changed: 54 additions & 19 deletions

File tree

src/beamforming/SASBearing2D.jl

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,45 @@ mutable struct PackedSASBearing2D <: DFG.AbstractPackedFactor
227227
waveformsInReal::Vector{Float64}
228228
waveformsInIm::Vector{Float64}
229229
PackedSASBearing2D() = new()
230-
PackedSASBearing2D(rangemodel::String, tp::Int, wavedataRawV::Vector{Float64}, wavedataRawV_dim::Int, cfgJson::String, cfgTotal::String, cfgLIE::String, waveformsInReal::Vector{Float64}, waveformsInIm::Vector{Float64}) = new(rangemodel, tp, wavedataRawV, wavedataRawV_dim, cfgJson, cfgTotal, cfgLIE, waveformsInReal, waveformsInIm)
231-
PackedSASBearing2D(rangemodel::String, tp::Int, wd::Array{Float64,2}, cf::Dict, cfgTotal::String, cfgLIE::String, waveformsInReal::Vector{Float64}, waveformsInIm::Vector{Float64}) = new(rangemodel, tp, wd[:], size(wd,1), JSON2.write(cf), cfgTotal, cfgLIE, waveformsInReal, waveformsInIm)
230+
PackedSASBearing2D(
231+
rangemodel::String,
232+
tp::Int,
233+
wavedataRawV::Vector{Float64},
234+
wavedataRawV_dim::Int,
235+
cfgJson::String,
236+
cfgTotal::String,
237+
cfgLIE::String,
238+
waveformsInReal::Vector{Float64},
239+
waveformsInIm::Vector{Float64}) = new(
240+
rangemodel,
241+
tp,
242+
wavedataRawV,
243+
wavedataRawV_dim,
244+
cfgJson,
245+
cfgTotal,
246+
cfgLIE,
247+
waveformsInReal,
248+
waveformsInIm
249+
)
250+
PackedSASBearing2D(
251+
rangemodel::String,
252+
tp::Int,
253+
wd::Array{Float64,2},
254+
cf::Dict,
255+
cfgTotal::String,
256+
cfgLIE::String,
257+
waveformsInReal::Vector{Float64},
258+
waveformsInIm::Vector{Float64}) = new(
259+
rangemodel,
260+
tp,
261+
wd[:],
262+
size(wd,1),
263+
JSON2.write(cf),
264+
cfgTotal,
265+
cfgLIE,
266+
waveformsInReal,
267+
waveformsInIm
268+
)
232269
end
233270

234271
# Note: Need this otherwise it uses a default converter and causes type conversion issues.

test/ICRA2022_tests/insufficient_data.jl

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
using RoME
44
using Test
5-
using JSON, JSON2
5+
using JSON3
66

77

88
##
@@ -30,17 +30,16 @@ refFdr = joinpath(@__DIR__, "test_data", "tut3")
3030

3131
function storeDistribution(file::AbstractString, bel::MKD)
3232
bel_ = packDistribution(bel)
33-
bel_s = JSON.json(bel_)
34-
fid = open(file, "w")
35-
println(fid, bel_s)
36-
close(fid)
33+
# write to file
34+
open(file, "w") do f
35+
JSON3.write(f, bel_)
36+
println(f)
37+
end
3738
end
3839

3940
function loadDistribution(file::AbstractString)
40-
fid = open(file, "r")
41-
# bel_s = read(fid)
42-
bel_s = JSON2.read(fid, PackedManifoldKernelDensity)
43-
close(fid)
41+
jstr = read(file, String)
42+
bel_s = JSON3.read(jstr, PackedManifoldKernelDensity)
4443
unpackDistribution(bel_s)
4544
end
4645

test/testScatterAlignParched.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using Downloads
66
using DelimitedFiles
77
using TensorCast
88
using Images
9-
using JSON
9+
using JSON3
1010

1111
##
1212

@@ -66,7 +66,7 @@ deb0 = addData!(
6666
:default_folder_store,
6767
:x0,
6868
:pointcloud,
69-
Vector{UInt8}(JSON.json( data )),
69+
Vector{UInt8}(JSON3.write( data )),
7070
mimeType="application/json/octet-stream"
7171
)
7272
data = packDistribution(bel_m)
@@ -75,7 +75,7 @@ deb1 = addData!(
7575
:default_folder_store,
7676
:x1,
7777
:pointcloud,
78-
Vector{UInt8}(JSON.json( data )),
78+
Vector{UInt8}(JSON3.write( data )),
7979
mimeType="application/json/octet-stream"
8080
)
8181

@@ -101,7 +101,7 @@ meas = sampleFactor(fg, getLabel(f1), 1)
101101

102102
pf = DFG.packFactor(fg, getFactor(fg, getLabel(f1)))
103103

104-
jpf = JSON.json(pf)
104+
jpf = JSON3.write(pf)
105105

106106
# check that the massive point clouds are not stored in the packed factor object
107107
@test length(jpf) < 1500

test/testStashing_SAP.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
using Test
44
using Caesar
5-
using JSON, JSON2
65
using Images
76
using Manifolds
87
import Rotations as _Rot
@@ -99,11 +98,11 @@ sap = ScatterAlignPose2(bIM1, bIM2, (x,y);
9998

10099
de, db_ = getData(fg, :x0, :hgd_stash_x0)
101100

102-
# myData = JSON2.read(IOBuffer(db), PackedHeatmapGridDensity)
101+
# myData = JSON3.read(String(db), PackedHeatmapGridDensity)
103102

104-
# JSON.parse(String(take!(IOBuffer(db))))["_type"] |> DFG.getTypeFromSerializationModule
103+
# JSON.parse(String(db))["_type"] |> DFG.getTypeFromSerializationModule
105104

106-
# convert(SamplableBelief, String(take!(IOBuffer(db))))
105+
# convert(SamplableBelief, String(db))
107106

108107

109108
##

0 commit comments

Comments
 (0)