Skip to content

Commit

Permalink
Merge pull request #215 from NavAbility/23Q1/enh/minorfixes
Browse files Browse the repository at this point in the history
minor impr on addBlob
  • Loading branch information
dehann authored Mar 13, 2023
2 parents 1dbda05 + c2dba42 commit 294df08
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 81 deletions.
14 changes: 7 additions & 7 deletions docs/src/buildgraph.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ push!(
resultIds,
addFactor(
client, context, ["x0"],
NVA.PriorPose2(;
NvaSDK.PriorPose2(;
Z=FullNormal(
[0.0, 0.0, 0.0],
diagm([0.05, 0.05, 0.01].^2)
Expand Down Expand Up @@ -77,7 +77,7 @@ push!(resultIds,
push!(
resultIds,
addFactor(client, context, ["x0","x1"],
NVA.Pose2Pose2(;
NvaSDK.Pose2Pose2(;
Z=FullNormal(
[1.0, 0.0, pi/2],
diagm([0.1, 0.1, 0.01].^2)
Expand Down Expand Up @@ -106,26 +106,26 @@ end
# add landmark observation measurement and
push!(resultIds,
addFactor(client, context, ["x0","l1"],
NVA.Pose2Point2BearingRange(Normal(0, 0.03), Normal(0.5, 0.1))))
NvaSDK.Pose2Point2BearingRange(Normal(0, 0.03), Normal(0.5, 0.1))))

# odometry measurements between poses
push!(resultIds,
addFactor(client, context, ["x1","x2"],
NVA.Pose2Pose2(
NvaSDK.Pose2Pose2(
FullNormal(
[1.0, 0.0, pi/2],
diagm([0.1, 0.1, 0.01].^2)))))

push!(resultIds,
addFactor(client, context, ["x2","x3"],
NVA.Pose2Pose2(
NvaSDK.Pose2Pose2(
FullNormal(
[1.0, 0.0, pi/2],
diagm([0.1, 0.1, 0.01].^2)))))

push!(resultIds,
addFactor(client, context, ["x3","x4"],
NVA.Pose2Pose2(
NvaSDK.Pose2Pose2(
FullNormal(
[1.0, 0.0, pi/2],
diagm([0.1, 0.1, 0.01].^2)))))
Expand All @@ -145,7 +145,7 @@ push!(
addFactor(
client, context,
["x4","l1"],
NVA.Pose2Point2BearingRange(
NvaSDK.Pose2Point2BearingRange(
Normal(0, 0.03),
Normal(0.5, 0.1))
)
Expand Down
2 changes: 1 addition & 1 deletion src/Deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## =========================

@deprecate getDataEntry(w...;kw...) getBlobEntry(w...;kw...)
@deprecate getBlobEvent(w...;kw...) getBlobEvent(w...;kw...)
@deprecate getDataEvent(w...;kw...) getBlobEvent(w...;kw...)
@deprecate getData(client::NavAbilityClient, context::Client, fileId::AbstractString) getData(client, context, UUID(fileId))
@deprecate getData(w...;kw...) getBlob(w...;kw...)

Expand Down
4 changes: 2 additions & 2 deletions src/NavAbilitySDK.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module NavAbilitySDK

const NVA = NavAbilitySDK
export NVA
const NvaSDK = NavAbilitySDK
# export NVA

# Global imports
using Diana
Expand Down
2 changes: 1 addition & 1 deletion src/navability/entities/InferenceTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Macro to autogenerate factor type definitions. Used for common types such as `P
"""
macro nvaZInferenceType(inferencetype)
return esc(quote
Base.@__doc__ struct $inferencetype <: NVA.InferenceType
Base.@__doc__ struct $inferencetype <: InferenceType
Z::Distribution
end
$inferencetype(;Z) = $inferencetype(Z)
Expand Down
20 changes: 13 additions & 7 deletions src/navability/services/DataBlobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function getBlob(
(verbose && 1 < length(bles)) ? @warn("multiple matches on regex, fetching $(ble_.label), w/ regex: $(regex.pattern), $((s->s.label).(bles))") : nothing
datalabel[] = ble_.label
# get blob
return NVA.getBlob(client, context, ble_.id)
return NvaSDK.getBlob(client, context, ble_.id)
end
getBlob(
client::NavAbilityClient,
Expand Down Expand Up @@ -214,13 +214,13 @@ function addBlobEvent(
blob::AbstractVector{UInt8}
)
#
io = IOBuffer(blob)
# io = IOBuffer(blob)

filesize = length(blob)
# TODO: Use about a 50M file part here.
np = 1 # TODO: ceil(filesize / 50e6)
# create the upload url destination
d = NVA.createUploadEvent(client, blobLabel, filesize, np)
d = NvaSDK.createUploadEvent(client, blobLabel, filesize, np)

url = d["parts"][1]["url"]
uploadId = d["uploadId"]
Expand All @@ -245,13 +245,19 @@ function addBlobEvent(
eTag = match(r"[a-zA-Z0-9]+",resp["eTag"]).match

# close out the upload
res = NVA.completeUploadSingleEvent(client, blobId, uploadId, eTag)
res = NvaSDK.completeUploadSingleEvent(client, blobId, uploadId, eTag)

res == "Accepted" ? nothing : @error("Unable to upload blob, $res")

blobId
end

# convenience
addBlobEvent(
client::NavAbilityClient,
blobLabel::Symbol,
blob::AbstractVector{UInt8}
) = addBlobEvent(client, string(blobLabel), blob)

addBlob(w...) = @async addBlobEvent(w...)

Expand Down Expand Up @@ -415,13 +421,13 @@ If the blob label `thisisme_1` already exists, then this function will return th
DO NOT EXPORT, Duplicate functionality from DistributedFactorGraphs.jl.
"""
function incrDataLabelSuffix(
client::NVA.NavAbilityClient,
context::NVA.Client,
client::NvaSDK.NavAbilityClient,
context::NvaSDK.Client,
vla,
bllb::AbstractString;
datalabel=Ref("")
)
re_aH = NVA.getBlob(client, context, string(vla), Regex(bllb); datalabel) |> fetch
re_aH = NvaSDK.getBlob(client, context, string(vla), Regex(bllb); datalabel) |> fetch
# append latest count
count, hasund, len = if re_aH isa Nothing
1, string(bllb)[end] == '_', 0
Expand Down
2 changes: 1 addition & 1 deletion src/navability/services/StandardAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Add a variable to the NavAbility Platform service
Example
```julia
addVariable(client, context, "x0", NVA.Pose2)
addVariable(client, context, "x0", NvaSDK.Pose2)
```
"""
function addVariable(client,
Expand Down
18 changes: 9 additions & 9 deletions test/integration/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ append!(
addVariable(client, context3D, "x1", :Pose3)]
)

NVA.waitForCompletion(client, resultIds; maxSeconds=180, expectedStatuses=["Complete"] )
NvaSDK.waitForCompletion(client, resultIds; maxSeconds=180, expectedStatuses=["Complete"] )

resultIds = Task[]
append!(
resultIds,
[addFactor(client, context3D, ["x0"], NVA.PriorPose3(Z=NVA.FullNormal([0.,1.,0,0,0,0], diagm([0.1,0.1,0.1,0.01,0.01,0.01].^2)))),
addFactor(client, context3D, [:x0,:x1], NVA.Pose3Pose3Rotation(Z=NVA.FullNormal([0.1,0.,0], diagm([0.01,0.01,0.01].^2))))]
[addFactor(client, context3D, ["x0"], NvaSDK.PriorPose3(Z=NvaSDK.FullNormal([0.,1.,0,0,0,0], diagm([0.1,0.1,0.1,0.01,0.01,0.01].^2)))),
addFactor(client, context3D, [:x0,:x1], NvaSDK.Pose3Pose3Rotation(Z=NvaSDK.FullNormal([0.1,0.,0], diagm([0.01,0.01,0.01].^2))))]
)


NVA.waitForCompletion(client, resultIds; maxSeconds=180, expectedStatuses=["Complete"] )
NvaSDK.waitForCompletion(client, resultIds; maxSeconds=180, expectedStatuses=["Complete"] )

flabels = fetch(NVA.listFactors(client, context3D))
fac = fetch(NVA.getFactor(client, context3D, "x0x1f_4e37"))
flabels = fetch(NvaSDK.listFactors(client, context3D))
fac = fetch(NvaSDK.getFactor(client, context3D, "x0x1f_4e37"))

# r = fetch(NVA.solveSession(client, context3D))
# s = fetch(NVA.getStatusesLatest(client, [r]))
# v = fetch(NVA.getVariable(client, context3D, "x1"))
# r = fetch(NvaSDK.solveSession(client, context3D))
# s = fetch(NvaSDK.getStatusesLatest(client, [r]))
# v = fetch(NvaSDK.getVariable(client, context3D, "x1"))

end
24 changes: 12 additions & 12 deletions test/integration/testExportSession.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@


function testExportSession(
client = NVA.NavAbilityHttpsClient(;authorize=false),
context = NVA.Client(
client = NvaSDK.NavAbilityHttpsClient(;authorize=false),
context = NvaSDK.Client(
"[email protected]",
"TESTING",
"EXPORTSESSION_"*(string(NVA.uuid4())[1:4])
"EXPORTSESSION_"*(string(NvaSDK.uuid4())[1:4])
);
buildNewGraph::Bool=false
)
#
if buildNewGraph
# build a graph
resultId = NVA.addVariable(client, context, NVA.Variable("x0", :Pose2)) |> fetch
resultId = NvaSDK.addVariable(client, context, NvaSDK.Variable("x0", :Pose2)) |> fetch
# Wait for them to be done before proceeding.
@info "Wait on addVariable eventId" resultId
NVA.waitForCompletion(client, [resultId], expectedStatuses=["Complete"], maxSeconds=180)
NvaSDK.waitForCompletion(client, [resultId], expectedStatuses=["Complete"], maxSeconds=180)

eventId = NVA.addFactor(client, context,
NVA.Factor("x0f1", "PriorPose2", ["x0"], NVA.PriorPose2Data())
eventId = NvaSDK.addFactor(client, context,
NvaSDK.Factor("x0f1", "PriorPose2", ["x0"], NvaSDK.PriorPose2Data())
) |> fetch
@info "Wait on addFactor eventId" resultId

NVA.waitForCompletion(client, [eventId], expectedStatuses=["Complete"], maxSeconds=180)
NvaSDK.waitForCompletion(client, [eventId], expectedStatuses=["Complete"], maxSeconds=180)
end

# export the graph
# eventId = NVA.exportSession(client, context, "testexport.tar.gz",
# options=NVA.ExportSessionOptions(
# eventId = NvaSDK.exportSession(client, context, "testexport.tar.gz",
# options=NvaSDK.ExportSessionOptions(
# format="NVA" # TODO TARGZ
# )) |> fetch

# @info "waiting for export Session" eventId
# NVA.waitForCompletion2(client, eventId)
# blobId = NVA.getExportSessionBlobId(client, eventId)
# NvaSDK.waitForCompletion2(client, eventId)
# blobId = NvaSDK.getExportSessionBlobId(client, eventId)
# @info "Success: Here is the blobId you can use to download: $blobId"
end

Expand Down
2 changes: 1 addition & 1 deletion test/integration/testFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function testDeleteFactor(client, context, factorLabels)

@show resultId = fetch(deleteFactor(client, context, "x0x1f_oops"))

@test NVA.waitForCompletion2(client, resultId)
@test NvaSDK.waitForCompletion2(client, resultId)

@test setdiff(factorLabels, fetch( lsf(client, context) )) == []

Expand Down
24 changes: 12 additions & 12 deletions test/integration/testInitVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ using TensorCast


function runInitVariableTests(;
client = NVA.NavAbilityHttpsClient(;authorize=false),
client = NvaSDK.NavAbilityHttpsClient(;authorize=false),
userId = "[email protected]",
robotId = "TESTING",
sessionId = "INITVARIABLE_"*(string(NVA.uuid4())[1:4])
sessionId = "INITVARIABLE_"*(string(NvaSDK.uuid4())[1:4])
)
#
@testset "run initVariable tests" begin

##
# connections
@show context = NVA.Client(userId,robotId,sessionId)
@show context = NvaSDK.Client(userId,robotId,sessionId)

resultId = NVA.addVariable(client, context, NVA.Variable("x0", :Pose2)) |> fetch
resultId = NvaSDK.addVariable(client, context, NvaSDK.Variable("x0", :Pose2)) |> fetch
# Wait for them to be done before proceeding.
@info "Wait on addVariable eventId" resultId
NVA.waitForCompletion(client, [resultId], expectedStatuses=["Complete"], maxSeconds=180)
NvaSDK.waitForCompletion(client, [resultId], expectedStatuses=["Complete"], maxSeconds=180)

# init some value to variable x0
pts = [[-rand();rand();-0.1] for _ in 1:5]
points = Dict{String,Float64}[ NVA.CartesianPointInput(;x=pt[1],y=pt[2],rotz=pt[3]) for pt in pts ]
points = Dict{String,Float64}[ NvaSDK.CartesianPointInput(;x=pt[1],y=pt[2],rotz=pt[3]) for pt in pts ]

variableKey = NVA.VariableKey(userId,robotId,sessionId,"x0")
variableId = NVA.VariableId(variableKey)
variableKey = NvaSDK.VariableKey(userId,robotId,sessionId,"x0")
variableId = NvaSDK.VariableId(variableKey)
particleInput = Dict{String,Any}("points"=>points)
distributionInput = Dict{String,Any}("particle"=>particleInput)
initVarInp = NVA.InitVariableInput(variableId, NVA.POSE2, distributionInput)
initVarInp = NvaSDK.InitVariableInput(variableId, NvaSDK.POSE2, distributionInput)

eventId = NVA.initVariable(client, context, initVarInp) |> fetch
eventId = NvaSDK.initVariable(client, context, initVarInp) |> fetch
@info "waitForCompletion on initVariable" eventId
completedSuccessfully = NVA.waitForCompletion2(client, eventId) #, expectedStatuses=["Complete"], maxSeconds=180)
completedSuccessfully = NvaSDK.waitForCompletion2(client, eventId) #, expectedStatuses=["Complete"], maxSeconds=180)
@test completedSuccessfully
if completedSuccessfully
res = NVA.getVariable(client, context, "x0")
res = NvaSDK.getVariable(client, context, "x0")
x0 = fetch(res)
x0_vv = reshape(x0["solverData"][1]["vecval"],3,:)
@cast refvv[i][d] := x0_vv[d,i]
Expand Down
4 changes: 2 additions & 2 deletions test/integration/testSolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function testSolveSession(client, context, variableLabels; maxSeconds=180)
@info "solveSession" resultId
GraphVizApp(context)
# Wait for them to be done before proceeding.
# NVA.waitForCompletion2(client, resultId; maxSeconds)
NVA.waitForCompletion(client, [resultId;]; maxSeconds, expectedStatuses=["Complete"])
# NvaSDK.waitForCompletion2(client, resultId; maxSeconds)
NvaSDK.waitForCompletion(client, [resultId;]; maxSeconds, expectedStatuses=["Complete"])

# Get PPE's are there for the connected variables.
# TODO - complete the factor graph.
Expand Down
20 changes: 10 additions & 10 deletions test/integration/testStandardAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,33 @@ sessionId = get(ENV,"SESSION_ID","TestSession_"*string(uuid4())[1:8])
context = Client(userId,robotId,sessionId)

addVariable(client, context, "x0", :Pose2)
addFactor(client, context, ["x0"], NVA.PriorPose2(Z=FullNormal([0.,1.,0], diagm([1.,1,1]))))
addFactor(client, context, ["x0"], NvaSDK.PriorPose2(Z=FullNormal([0.,1.,0], diagm([1.,1,1]))))

addVariable(client, context, :x1, :Pose2)
addFactor(client, context, [:x0,:x1], NVA.Pose2Pose2(Z=FullNormal([1.,0.,0], diagm([1.,1,1]))))
addFactor(client, context, [:x0,:x1], NvaSDK.Pose2Pose2(Z=FullNormal([1.,0.,0], diagm([1.,1,1]))))

addFactor(client, context, [:x1], NVA.PriorPose2(Z=FullNormal([1.,0.,0], diagm([1.,1,1]))); nullhypo=0.1)
addFactor(client, context, [:x1], NvaSDK.PriorPose2(Z=FullNormal([1.,0.,0], diagm([1.,1,1]))); nullhypo=0.1)

addFactor(client, context, ["x0"], NVA.PriorPose2(Z=FullNormal([0.5,0.5,0], diagm([1.,1,1]))))
addFactor(client, context, ["x0"], NvaSDK.PriorPose2(Z=FullNormal([0.5,0.5,0], diagm([1.,1,1]))))

addVariable(client, context, :x2_a, :Pose2)
addVariable(client, context, :x2_b, :Pose2)
addFactor(client, context, ["x1", "x2_a", "x2_b"], NVA.PriorPose2(Z=FullNormal([0.5,0.5,0], diagm([1.,1,1]))); multihypo=[1,0.1,0.9])
addFactor(client, context, ["x1", "x2_a", "x2_b"], NvaSDK.PriorPose2(Z=FullNormal([0.5,0.5,0], diagm([1.,1,1]))); multihypo=[1,0.1,0.9])

addVariable(client, context, "y0", :Position1)
addFactor(client, context, ["y0"], NVA.Prior(Z=Normal(0.0, 1.0)))
addFactor(client, context, ["y0"], NvaSDK.Prior(Z=Normal(0.0, 1.0)))


addVariable(client, context, "z0", :Point2)
addFactor(client, context, ["z0"], NVA.PriorPoint2(Z=FullNormal([1.,0.], diagm([1.,1]))))
addFactor(client, context, ["z0"], NvaSDK.PriorPoint2(Z=FullNormal([1.,0.], diagm([1.,1]))))

addVariable(client, context, "z1", :Point2)
addFactor(client, context, ["z0", "z1"], NVA.Point2Point2(Z=FullNormal([1.,0.], diagm([1.,1]))))
addFactor(client, context, ["z0", "z1"], NvaSDK.Point2Point2(Z=FullNormal([1.,0.], diagm([1.,1]))))

addVariable(client, context, "p3_0", :Pose3)
addFactor(client, context, ["p3_0"], NVA.PriorPose3(Z=FullNormal([0.;1.;0;zeros(3)], diagm([1.;1;1;ones(3)]))))
addFactor(client, context, ["p3_0"], NvaSDK.PriorPose3(Z=FullNormal([0.;1.;0;zeros(3)], diagm([1.;1;1;ones(3)]))))

addVariable(client, context, :p3_1, :Pose3)
addFactor(client, context, [:p3_0,:p3_1], NVA.Pose3Pose3(Z=FullNormal([1.;0.;0;zeros(3)], diagm([1.;1;1;ones(3)]))))
addFactor(client, context, [:p3_0,:p3_1], NvaSDK.Pose3Pose3(Z=FullNormal([1.;0.;0;zeros(3)], diagm([1.;1;1;ones(3)]))))

end
6 changes: 3 additions & 3 deletions test/integration/testVariable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ function testAddVariable(client, context, variableLabels, variableTypes, variabl
end

# Wait for them to be done before proceeding.
# NVA.waitForCompletion2(client, resultIds; maxSeconds=180) # expectedStatuses=["Complete"]
NVA.waitForCompletion(client, resultIds; maxSeconds=180, expectedStatuses=["Complete"] )
# NvaSDK.waitForCompletion2(client, resultIds; maxSeconds=180) # expectedStatuses=["Complete"]
NvaSDK.waitForCompletion(client, resultIds; maxSeconds=180, expectedStatuses=["Complete"] )

return resultIds
end
Expand All @@ -19,7 +19,7 @@ function testUpdateVariable(client, context, variableLabels, variableTypes, vari
actualVariable = getVariable(client,context,variableLabels[i]) |> fetch
push!(actualVariable["tags"], "TEST")
eventId = updateVariablePacked(client, context, actualVariable) |> fetch
NVA.waitForCompletion(client, [eventId]; maxSeconds=180, expectedStatuses=["Complete"] )
NvaSDK.waitForCompletion(client, [eventId]; maxSeconds=180, expectedStatuses=["Complete"] )

actualVariable = getVariable(client,context,variableLabels[i]) |> fetch
@test "TEST" in actualVariable["tags"]
Expand Down
Loading

0 comments on commit 294df08

Please sign in to comment.