Skip to content

Commit

Permalink
Merge pull request #172 from NavAbility/main
Browse files Browse the repository at this point in the history
v0.4.8-rc1
  • Loading branch information
dehann authored Nov 2, 2022
2 parents 76b7b2b + 26441ba commit a604a31
Show file tree
Hide file tree
Showing 30 changed files with 881 additions and 67 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- release**
tags:
- v**
pull_request:
Expand All @@ -15,7 +16,7 @@ jobs:
matrix:
julia-version:
- '1.6'
- '1.7'
- '1.8'
julia-arch: [x64]
os: [ubuntu-latest]

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: test

test:
julia --project -e "using Pkg; Pkg.test()"
8 changes: 5 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "f3e6a059-199c-4ada-8143-fcefb97e6165"
keywords = ["navability", "navigation", "slam", "sdk", "robotics", "robots"]
desc = "NavAbility SDK: Access NavAbility Cloud factor graph features. Note that this SDK and the related API are still in development. Please let us know if you have any issues at [email protected]."
authors = ["NavAbility <[email protected]>"]
version = "0.4.7"
version = "0.4.8"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand All @@ -17,15 +17,17 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Diana = "0.2"
Diana = "0.2, 0.3"
DocStringExtensions = "0.8, 0.9"
Downloads = "1"
HTTP = "0.9, 1"
JSON = "0.21"
TensorCast = "0.4"
julia = "1.6"

[extras]
TensorCast = "02d47bb6-7ce6-556a-be16-bb1710789e2b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["TensorCast","Test"]
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# NavAbilitySDK.jl

[![Unit tests](https://github.com/NavAbility/NavAbilitySDK.jl/actions/workflows/tests.yml/badge.svg)](https://github.com/NavAbility/NavAbilitySDK.jl/actions/workflows/tests.yml)
[![Documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://navability.github.io/NavAbilitySDK.jl/dev/)

| Stable Release | Dev branch | Documentation |
|----------------|------------|---------------|
| [![Unit tests stb][sdkjl-ci-std-img]][sdkjl-ci-url] | [![Unit tests dev][sdkjl-ci-dev-img]][sdkjl-ci-url] | [![Documentation][sdkjl-docs-img]][sdkjl-docs-url] |

[sdkjl-ci-dev-img]: https://github.com/NavAbility/NavAbilitySDK.jl/actions/workflows/tests.yml/badge.svg?branch=main
[sdkjl-ci-std-img]: https://github.com/NavAbility/NavAbilitySDK.jl/actions/workflows/tests.yml/badge.svg?branch=release%2Fv0.4
[sdkjl-ci-url]: https://github.com/NavAbility/NavAbilitySDK.jl/actions/workflows/tests.yml
[sdkjl-docs-img]: https://img.shields.io/badge/docs-dev-blue.svg
[sdkjl-docs-url]: https://navability.github.io/NavAbilitySDK.jl/dev/

Access NavAbility Cloud factor graph features from Julia.

Expand Down
7 changes: 7 additions & 0 deletions src/Deprecated.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

## =========================
## Remove below before v0.6
## =========================

@deprecate getData(client::NavAbilityClient, context::Client, fileId::AbstractString) getData(client, context, UUID(fileId))
@deprecate getDataByLabel( client::NavAbilityClient, context::Client, vlbl::AbstractString, w...; kw...) getData(client, context, vlbl, w...; kw...)
14 changes: 13 additions & 1 deletion src/NavAbilitySDK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const NVA = NavAbilitySDK
export NVA

# Global imports
using Diana
using DocStringExtensions
using LinearAlgebra
using JSON
Expand All @@ -25,8 +26,11 @@ include("./navability/graphql/Factor.jl")
include("./navability/graphql/Status.jl")
include("./navability/graphql/Variable.jl")
include("./navability/graphql/DataBlobs.jl")
include("./navability/graphql/Session.jl")


include("./navability/graphql/QueriesDeprecated.jl")
# TODO remove GQL exports, since users can easily just use NVA.QUERY___
export QUERY_VARIABLE_LABELS
export QUERY_FILES, QUERY_CALIBRATION
export MUTATION_ADDVARIABLE, MUTATION_ADDFACTOR, MUTATION_ADDSESSIONDATA
Expand All @@ -45,6 +49,7 @@ include("./navability/entities/Variable.jl")
include("./navability/entities/InferenceTypes.jl")
include("./navability/entities/Factor.jl")
include("./navability/entities/Solve.jl")
include("./navability/entities/Session.jl")
export NavAbilityClient, NavAbilityWebsocketClient, NavAbilityHttpsClient, QueryOptions, MutationOptions
export Client, Scope
export QueryDetail, LABEL, SKELETON, SUMMARY, FULL
Expand All @@ -56,6 +61,7 @@ export PriorPose3, Pose3Pose3
export ScatterAlignPose2Data
export FactorType, Factor
export SolveOptions
export SessionKey, SessionId, ExportSessionInput, ExportSessionOptions

# Services
include("./navability/services/Variable.jl")
Expand All @@ -65,14 +71,20 @@ include("./navability/services/Status.jl")
include("./navability/services/Utils.jl")
include("./navability/services/StandardAPI.jl")
include("./navability/services/DataBlobs.jl")
include("./navability/services/Session.jl")
export getVariable, getVariables, listVariables, ls
export addVariable, addPackedVariable
export getFactor, getFactors, listFactors, lsf
export addFactor, addPackedFactor
export addFactor, addPackedFactor, deleteFactor
export initVariable
export listDataEntries
export getDataEntry, getData
export solveSession, solveFederated
export getStatusMessages, getStatusLatest, getStatusesLatest
export waitForCompletion
export exportSession, getExportSessionBlobId
export GraphVizApp, MapVizApp

include("Deprecated.jl")

end
5 changes: 4 additions & 1 deletion src/navability/entities/Client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ $(TYPEDEF)
The context for a session, made from a user, robot, and session.
Users can have multiple robots and robots can have multiple sessions.
So this indicates a unique session.
DevNotes
- Rename to [`SessionKey`](@ref)
"""
struct Client
Base.@kwdef struct Client
userId::String
robotId::String
sessionId::String
Expand Down
14 changes: 13 additions & 1 deletion src/navability/entities/Factor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,19 @@ between the variables, e.g. `FullNormal([1;zeros(5)], diagm(0.01*ones(6)))`.
Default value of Z = `FullNormal(zeros(6), diagm(0.01*ones(6)))`.
"""
function Pose3Pose3Data(;Z::Distribution = FullNormal(zeros(6), diagm(0.01*ones(6))), kwargs...)::FactorData
data = FactorData(;fnc = ZInferenceType(Z), certainhypo = [1], kwargs...)
data = FactorData(;fnc = ZInferenceType(Z), certainhypo = [1,2], kwargs...)
return data
end

"""
$(SIGNATURES)
Create a partial factor on Rotation only on Pose3->Pose3 with a distribution Z representing the relationship
between the variables.
Default value of Z = `FullNormal(zeros(3), diagm(0.01*ones(3)))`.
"""
function Pose3Pose3RotationData(;Z::Distribution = FullNormal(zeros(3), diagm(0.01*ones(3))), kwargs...)
data = FactorData(;fnc = ZInferenceType(Z), certainhypo = [1,2], kwargs...)
return data
end

Expand Down
1 change: 1 addition & 0 deletions src/navability/entities/InferenceTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ end

@nvaZInferenceType PriorPose3
@nvaZInferenceType Pose3Pose3
@nvaZInferenceType Pose3Pose3Rotation


"""
Expand Down
64 changes: 50 additions & 14 deletions src/navability/entities/NavAbilityClient.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Diana

struct QueryOptions
name::String
Expand All @@ -22,33 +21,70 @@ function NavAbilityWebsocketClient( apiUrl::String="wss://api.navability.io/grap
end

function NavAbilityHttpsClient(
apiUrl::String="https://api.navability.io";
authorize::Bool=false
apiUrl::String = "https://api.navability.io";
auth_token::String = "",
authorize::Bool = 0!==length(auth_token)
)::NavAbilityClient
#
dianaClient = GraphQLClient(apiUrl)

# auth
if authorize
# FIXME, use Base.getpass instead of readline once VSCode supports getpass.
# st = Base.getpass("Copy-paste auth token")
# seekstart(st)
# tok = read(st, String)
# Base.shred!(st)
println(" > VSCode ONLY WORKAROUND, input issue, see https://github.com/julia-vscode/julia-vscode/issues/785")
println(" > Workaround: first press 0 then enter, and then paste the token and hit enter a second time.")
println("Copy-paste auth token: ")
tok = readline(stdin)
tok = if 0===length(auth_token)
# FIXME, use Base.getpass instead of readline once VSCode supports getpass.
# st = Base.getpass("Copy-paste auth token")
# seekstart(st)
# tok = read(st, String)
# Base.shred!(st)
println(" > VSCode ONLY WORKAROUND, input issue, see https://github.com/julia-vscode/julia-vscode/issues/785")
println(" > Workaround: first press 0 then enter, and then paste the token and hit enter a second time.")
println("Copy-paste auth token: ")
readline(stdin)
else
auth_token
end
dianaClient.serverAuth("Bearer "*tok)
end

function query(options::QueryOptions)
# NOTE, the query client library used is synchronous, locally converted to async for package consistency
@async dianaClient.Query(options.query, operationName=options.name, vars=options.variables)
@async begin
attempts = 0
while true
try
return dianaClient.Query(options.query, operationName=options.name, vars=options.variables)
catch err
if attempts < 3
@warn "[Test Client] WARN Client saw an exception. Retrying!" exception=(err, catch_backtrace())
sleep(2)
attempts += 1
else
rethrow()
end
end
end
end
end

function mutate(options::MutationOptions)
# NOTE, the query client library used is synchronous, locally converted to async for package consistency
@async dianaClient.Query(options.mutation, operationName=options.name, vars=options.variables)
@async begin
attempts = 0
while true
try
return dianaClient.Query(options.mutation, operationName=options.name, vars=options.variables)
catch err
if attempts < 3
@warn "[Test Client] WARN Client saw an exception. Retrying!" exception=(err, catch_backtrace())
sleep(2)
attempts += 1
else
rethrow()
end
end
end
end
end

return NavAbilityClient(query, mutate)
end
49 changes: 49 additions & 0 deletions src/navability/entities/Session.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

# @enum BagFormat begin
# NVA # FIXME TARGZ
# ROS1BAG
# MCAP
# end


Base.@kwdef struct SessionKey
userId::String
robotId::String
sessionId::String
end

# dictionary since either fields can be used
function SessionId(;
id::Union{<:AbstractString,Nothing}=nothing,
key::Union{SessionKey,Nothing}=nothing
)
#
_idorkeys = id isa Nothing
Dict(
(_idorkeys ? () : ("id"=>id,))...,
(!_idorkeys ? () : ("key"=>key,))...
)
end


# function SessionKey(
# userId::AbstractString,
# robotId::AbstractString,
# sessionId::AbstractString
# )
# #
# Dict{String,String}(
# "userId" => userId,
# "robotId" => robotId,
# "sessionId" => sessionId,
# )
# end

Base.@kwdef struct ExportSessionInput
id::Dict
filename::String
end

Base.@kwdef struct ExportSessionOptions
format::String
end
2 changes: 1 addition & 1 deletion src/navability/entities/Solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Solver options including the solve key and whether the
parametric solver should be used.
"""
Base.@kwdef struct SolveOptions
key::Union{String, Nothing}
key::Union{String, Nothing} = nothing
useParametric::Bool = false
end

Loading

0 comments on commit a604a31

Please sign in to comment.