Skip to content

Commit 29c5ead

Browse files
authored
Merge pull request #39 from NavAbility/33/async_calls
Documentation updates and version bump
2 parents a4c3654 + dac1607 commit 29c5ead

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,20 @@ pip install navabilitysdk
1616
- **Why is the SDK camel-cased?** True, Python code should be snake-cased. This was a design decision to align all the SDKS. All the functions and fields should look the same, so you can easily switch from one language to another without having to read documentation. This may change in the future as we grow the SDKs.
1717
- **Which user should I use?** The Guest user is open and free for everyone to use. We recommend testing with this user, because it doesn't require any authentication. Note though, that the data is cleared on a regular basis, and that everyone can see your test data (all Guest users are created equal), so don't put anything in there that that is sensitive.
1818
- **I have sensitive data, how do I create a user?** Great question, the NavAbility services completely isolate data per user and you can create a user at any point. At the moment we create users on demand because the services are changing as we develop them, and we want to make sure we can let everyone know as they do. Send us an email at [[email protected]](mailto:[email protected]) and we'll create a user for you right away.
19+
- **Why Asyncio?** We're working on integrating these into [Example Jupyter Notebooks](https://github.com/NavAbility/BinderNotebooks) which only support asynchronous GQL calls in the `gql` library. This design decision will be standardized in all our SDKs in the next release. Overally it's been a good call, and we'll expand on more asynchronous functionality as these SDKs develop.
1920
- Otherwise for any questions, comments, or feedback please feel free to email us at [[email protected]](mailto:[email protected]) or write an issue on the repo.
2021
# Example
2122

2223
This script will create variables and factors, list the graph, and solve the session for SLAM estimates.
2324

24-
NOTE: You'll need numpy to run it.
25+
> NOTES:
26+
> * You'll need to start Python using `python -m asyncio` to support the `await` command.
27+
> * You'll need numpy to run the example.
2528
2629
```python
2730
from uuid import uuid4
2831
import numpy as np
32+
import json
2933
from navability.entities import (
3034
Client,
3135
Factor,
@@ -96,23 +100,34 @@ factors = [
96100
]
97101

98102
# Get the result IDs so we can check on their completion
99-
result_ids = [addVariable(navability_client, client, v)["addVariable"] for v in variables] + [addFactor(navability_client, client, f)["addFactor"] for f in factors]
103+
print("Adding variables and factors..\r\n")
104+
variable_results = [await addVariable(navability_client, client, v) for v in variables]
105+
factor_results = [await addFactor(navability_client, client, f) for f in factors]
106+
result_ids = variable_results + factor_results
100107

101108
# Wait for them to be inserted if they havent already
102-
waitForCompletion(navability_client, result_ids, maxSeconds=60)
109+
print("Waiting for them to be loaded..\r\n")
110+
await waitForCompletion(navability_client, result_ids, maxSeconds=120)
103111

104112
# Interrogate the graph
105113
# Get the variables
106-
ls(navability_client, client)
114+
print("Listing all the variables and factors in the session:\r\n")
115+
vs = await ls(navability_client, client)
116+
print("Variables: " + json.dumps(vs, indent=4, sort_keys=True))
107117
# Get the factors
108-
lsf(navability_client, client)
118+
fs = await lsf(navability_client, client)
119+
print("Factors: " + json.dumps(fs, indent=4, sort_keys=True))
109120
# There's some pretty neat functionality with searching, but we'll save that for more comprehensive tutorials
110121

111122
# Request a SLAM multimodal solve and wait for the response
112123
# Note: Guest sessions solve a little slower than usual because they're using some small hardware we put down for community use. Feel free to reach out if you want faster solving.
113-
requestId = solveSession(navability_client, client)["solveSession"]
114-
waitForCompletion(navability_client, [requestId], maxSeconds=120)
124+
print("Requesting that the graph be solved to determine the positions of the variables (poses)...")
125+
request_id = await solveSession(navability_client, client)
126+
await waitForCompletion(navability_client, [request_id], maxSeconds=120)
115127

116128
# Get the solves positions of the variables (these are stores in the PPEs structure)
117-
estimates = {v.label: getVariable(navability_client, client, v.label).ppes['default'].suggested for v in variables}
129+
print("Getting the estimates of the variables (poses)...")
130+
estimates = {v.label: (await getVariable(navability_client, client, v.label)).ppes['default'].suggested for v in variables}
131+
print("Solved estimates for the positions:\r\n")
132+
print(json.dumps(estimates, indent=4, sort_keys=True))
118133
```

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"""
1212
)
1313

14-
_version = "0.3.0"
14+
_version = "0.4.0"
1515

1616
setup(
1717
name="navabilitysdk",

0 commit comments

Comments
 (0)