-
Notifications
You must be signed in to change notification settings - Fork 237
[WIP] Implementation of the actual python bindings for DroneCore #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dronecore/backend.py
Outdated
@@ -0,0 +1,90 @@ | |||
""" Backend """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wording question: isn't this what we call Core
? What we call the "backend" is really just the gRPC server side (C++). So the Core
spins up a backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, Let's rename that to Core! :-)
- Testing Python 2.7, 3.5 and 3.6 - Tests therefore cover Ubuntu 16.04, 18.04 as well as legacy systems (including Ubuntu 14.04)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like good progress to me! :-)
dronecore/plugins/action.py
Outdated
""" | ||
Takeoff | ||
|
||
:returns: Ovservable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ovservable -> Observable :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I like it :-). Can we merge that in this state already?
I'd actually like to get streaming working properly before - also I have some changes that are not commited yet! Let me check this afternoon, maybe then we can merge! |
No worries, it's not urgent :) |
It's always urgent! 8). I'd love to move the PX4 CI over to this! |
dronecore/plugin_manager.py
Outdated
@@ -60,24 +59,19 @@ def _spinup_backend(self): | |||
""" | |||
Spinup a backend and connect to it | |||
""" | |||
#: backend is running on localhost | |||
self.port = "127.0.0.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the worgind here: default port is 50051, and address is localhost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's indeed wrong. I haven't tested the function yet as I am not sure how we will ship the backend with the python library!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Well, the simple assumption is "the backend is already running on an <IP:port> somewhere". And on top of that, we can provide an interface that starts a backend locally. But it may be that the backend runs on a different machine (e.g. directly on the drone), so at least one should be able to connect to <IP:port>.
In Swift, that's currently the only interface (e.g. let core = Core("localhost", 50051)
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is possible? Have a look at ``init`
import dronecore
# Connect to a backend
remote_backend = dronecore.connect(host="192.168.178.56", port=50051)
# Start a backend local and connect
local_backend = dronecore.connect()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I know :). I was just answering to your comment, but maybe I missed your point actually ;-).
… working, testing is @todo
@JonasVautherin FYI Basic calls and Streams are working just fine, I kept the code pretty consistent so we can build the auto generator ontop of it! @hamishwillee I don't think the interface will change - I haven't worked with the Swift bindings yet but tried to keet the API as close as possible, can you compare and give your OK? :-) |
dronecore/plugins/telemetry.py
Outdated
observable.on_completed() | ||
def _create_position_observable(self): | ||
""" | ||
Create the position ovservable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ovservable -> observable :). In all the other functions, too ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damnit! Thanks!
dronecore/plugins/telemetry.py
Outdated
from .._base import Base | ||
from ..generated import telemetry_pb2, telemetry_pb2_grpc | ||
|
||
|
||
class Position(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@JonasVautherin I propose we merge and take it as a baseline for the autogenerator - I can't think of anything that has to be changed. |
Sounds very reasonable and is definitely the right step before trying auto-generation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xvzf!
=> ERROR [ 9/21] RUN cd proto/pb_plugins && pip3 install -r requirements.txt && cd ../.. && pip3 install -r requirements.txt -r requirements-dev.t 7.4s ------ > [ 9/21] RUN cd proto/pb_plugins && pip3 install -r requirements.txt && cd ../.. && pip3 install -r requirements.txt -r requirements-dev.txt: mavlink#12 1.122 Requirement already satisfied: protobuf<=3.20.1,>=3.13 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 1)) (3.20.1) mavlink#12 1.124 Requirement already satisfied: jinja2>=2.11 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 2)) (3.1.2) mavlink#12 1.127 Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.8/dist-packages (from jinja2>=2.11->-r requirements.txt (line 2)) (2.1.3) mavlink#12 1.876 Requirement already satisfied: protobuf<=3.20.1 in /usr/local/lib/python3.8/dist-packages (from -r requirements.txt (line 1)) (3.20.1) mavlink#12 2.087 Collecting aiogrpc>=1.8 mavlink#12 2.254 Downloading aiogrpc-1.8-py3-none-any.whl (10 kB) mavlink#12 3.523 Collecting grpcio>=1.50.0 mavlink#12 3.576 Downloading grpcio-1.59.2.tar.gz (24.8 MB) mavlink#12 7.090 ERROR: Command errored out with exit status 1: mavlink#12 7.090 command: /usr/bin/python3 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘“’”‘/tmp/pip-install-nq2pboe3/grpcio/setup.py’“‘”’; __file__=‘“’”‘/tmp/pip-install-nq2pboe3/grpcio/setup.py’“‘”’;f=getattr(tokenize, ‘“’”‘open’“‘”’, open)(__file__);code=f.read().replace(‘“’”‘\r\n’“‘”’, ‘“’”‘\n’“‘”’);f.close();exec(compile(code, __file__, ‘“’”‘exec’“‘”’))' egg_info --egg-base /tmp/pip-install-nq2pboe3/grpcio/pip-egg-info mavlink#12 7.090 cwd: /tmp/pip-install-nq2pboe3/grpcio/ mavlink#12 7.090 Complete output (9 lines): mavlink#12 7.090 Traceback (most recent call last): mavlink#12 7.090 File “<string>“, line 1, in <module> mavlink#12 7.090 File “/tmp/pip-install-nq2pboe3/grpcio/setup.py”, line 95, in <module> mavlink#12 7.090 import commands mavlink#12 7.090 File “/tmp/pip-install-nq2pboe3/grpcio/src/python/grpcio/commands.py”, line 31, in <module> mavlink#12 7.090 import support mavlink#12 7.090 File “/tmp/pip-install-nq2pboe3/grpcio/src/python/grpcio/support.py”, line 111, in <module> mavlink#12 7.090 errors.CompileError: diagnose_compile_error, mavlink#12 7.090 AttributeError: module ‘setuptools.errors’ has no attribute ‘CompileError’ mavlink#12 7.090 ---------------------------------------- mavlink#12 7.284 ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ------ executor failed running [/bin/sh -c cd proto/pb_plugins && pip3 install -r requirements.txt && cd ../.. && pip3 install -r requirements.txt -r requirements-dev.txt]: exit code: 1
This is still a WIP!
Basic concept is using the bindings like this: