Skip to content

[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

Merged
merged 20 commits into from
Jun 4, 2018

Conversation

xvzf
Copy link
Collaborator

@xvzf xvzf commented May 23, 2018

This is still a WIP!

Basic concept is using the bindings like this:

from dronecore import Backend, Action

# Connect to a dronecore backend running on the local machine
core = Core(host="127.0.0.1")

# Initialize the Action plugin
action = Action(core)

# E.g. arm the copter
action.arm().subscribe(on_completed=lambda: print("ARMED!"),
                       on_error=lambda _: print("Could not arm the system!"))

@xvzf xvzf changed the title Implementation of the actual python bindings for DroneCore [WIP] Implementation of the actual python bindings for DroneCore May 23, 2018
@@ -0,0 +1,90 @@
""" Backend """
Copy link
Collaborator

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.

Copy link
Collaborator Author

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! :-)

Copy link
Collaborator

@JonasVautherin JonasVautherin left a 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! :-)

"""
Takeoff

:returns: Ovservable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ovservable -> Observable :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Collaborator

@JonasVautherin JonasVautherin left a 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?

@xvzf
Copy link
Collaborator Author

xvzf commented May 30, 2018

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!

@JonasVautherin
Copy link
Collaborator

No worries, it's not urgent :)

@LorenzMeier
Copy link
Member

It's always urgent! 8). I'd love to move the PX4 CI over to this!

@@ -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"
Copy link
Collaborator

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.

Copy link
Collaborator Author

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!

Copy link
Collaborator

@JonasVautherin JonasVautherin May 30, 2018

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)).

Copy link
Collaborator Author

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()

Copy link
Collaborator

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 ;-).

@xvzf
Copy link
Collaborator Author

xvzf commented May 31, 2018

@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? :-)

observable.on_completed()
def _create_position_observable(self):
"""
Create the position ovservable
Copy link
Collaborator

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 ;-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damnit! Thanks!

from .._base import Base
from ..generated import telemetry_pb2, telemetry_pb2_grpc


class Position(object):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@xvzf
Copy link
Collaborator Author

xvzf commented Jun 4, 2018

@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.

@LorenzMeier
Copy link
Member

Sounds very reasonable and is definitely the right step before trying auto-generation.

Copy link
Collaborator

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @xvzf!

@JonasVautherin JonasVautherin merged commit 8173593 into mavlink:master Jun 4, 2018
neilvaltec added a commit to neilvaltec/MAVSDK-Python that referenced this pull request Nov 6, 2023
=> 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants