Skip to content

Commit 309932b

Browse files
authored
Merge pull request #588 from JuliaRobotics/bug/3Q20/560_timestamp_issue_2
Fix for non-millisecond timestamps
2 parents 21655bf + c4b0ca2 commit 309932b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/services/Serialization.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ function unpackVariable(dfg::G,
3030
unpackBigData::Bool=true)::DFGVariable where G <: AbstractDFG
3131
@debug "Unpacking variable:\r\n$packedProps"
3232
label = Symbol(packedProps["label"])
33+
# Make sure that the timestamp is correctly formatted with subseconds
34+
packedProps["timestamp"] = replace(packedProps["timestamp"], r":(\d)(\d)(Z|z|\+|-)" => s":\1\2.000\3")
35+
# Parse it
3336
timestamp = ZonedDateTime(packedProps["timestamp"])
3437
nstime = Nanosecond(get(packedProps, "nstime", 0))
3538
# Supporting string serialization using packVariable and CGDFG serialization (Vector{String})
@@ -166,6 +169,9 @@ end
166169

167170
function unpackFactor(dfg::G, packedProps::Dict{String, Any})::DFGFactor where G <: AbstractDFG
168171
label = packedProps["label"]
172+
# Make sure that the timestamp is correctly formatted with subseconds
173+
packedProps["timestamp"] = replace(packedProps["timestamp"], r":(\d)(\d)(Z|z|\+|-)" => s":\1\2.000\3")
174+
# Parse it
169175
timestamp = ZonedDateTime(packedProps["timestamp"])
170176
nstime = Nanosecond(get(packedProps, "nstime", 0))
171177
if packedProps["tags"] isa String

test/testBlocks.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function DFGVariableSCA()
245245
# Constructors
246246
v1 = DFGVariable(v1_lbl, TestSofttype1(), tags=v1_tags, solvable=0, solverDataDict=Dict(:default=>VariableNodeData{TestSofttype1}()))
247247
v2 = DFGVariable(:b, VariableNodeData{TestSofttype2}(), tags=Set([:VARIABLE, :LANDMARK]))
248-
v3 = DFGVariable(:c, VariableNodeData{TestSofttype2}())
248+
v3 = DFGVariable(:c, VariableNodeData{TestSofttype2}(), timestamp=ZonedDateTime("2020-08-11T00:12:03.000-05:00"))
249249

250250
vorphan = DFGVariable(:orphan, TestSofttype1(), tags=v1_tags, solvable=0, solverDataDict=Dict(:default=>VariableNodeData{TestSofttype1}()))
251251

@@ -327,7 +327,7 @@ function DFGFactorSCA()
327327
f1 = DFGFactor{TestCCW{TestFunctorInferenceType1}}(f1_lbl, [:a,:b])
328328
f1 = DFGFactor(f1_lbl, [:a,:b], gfnd, tags = f1_tags, solvable=0)
329329

330-
f2 = DFGFactor{TestCCW{TestFunctorInferenceType1}}(:bcf1, [:b, :c])
330+
f2 = DFGFactor{TestCCW{TestFunctorInferenceType1}}(:bcf1, [:b, :c], ZonedDateTime("2020-08-11T00:12:03.000-05:00"))
331331
#TODO add tests for mutating vos in updateFactor and orphan related checks.
332332
# we should perhaps prevent an empty vos
333333

0 commit comments

Comments
 (0)