Closed divyanshupundir closed 2 years ago
Looks nice! :rocket:
I'll have to go through the code again and try it myself, but that looks good! Thanks a lot!
@JonasVautherin, have you had a chance to go through the code and test it? I have been testing it extensively using SITL. But not as much as I would like on hardware. By the end of December, I would have done more thorough tests.
For now, I haven't been facing any issues.
I have been testing it on hardware for some time. I haven't been facing any issues.
Thanks for the review.
Problem
mavsdk-server
version0.11.0
blocks the calling thread while discovering a system. This creates a problem for Android as the UI thread cannot be blocked. Simply pushing themavsdk-server
to the background does not work because the plugins require thegRPC
server on themavsdk-server
to be running (which will happen only if a system is discovered). As a result, the users of the library need to implement tedious workarounds to make things work.The idea behind this PR is to make the library handle the initialization problems so that the users need to make minimal changes to their codebases which were written using the SDK version including and prior to
0.10.0
.Solution
This PR tackles the problem by:
mavsdk-event-queue
for initializing and disposing themavsdk-server
/plugins/infinite streams.For Android, the only change the users need to make is to execute
MavsdkServer.run()
method in themavsdk-event-queue
as follows:Internally, plugins are constructed lazily through the
io.mavsdk.System
instances. Upon their first call, their initialization commands are added to themavsdk-event-queue
. Notice that these executions will be blocked in themavsdk-event-queue
until the server discovers a system.Infinite streams (eg.
Telemetry.Position
) are handled similarly.One-shot calls like
takeoff
,land
andupload mission
are not added to themavsdk-event-queue
when the user subscribes to them. This is done to avoid their piling up while themavsdk-server
discovers a system. Instead, theonError
callback will be triggered after a 100ms delay indicating that no system was available for the command.Other additions
io.mavsdk.Plugin
interface, which is implemented by all the plugins.io.mavsdk.MavsdkException
to differentiate between exceptions thrown by MAVSDK and other components likeSocketException
which may be thrown bygRPC
.Update
protoc
codegen toolchain which resolves the duplicate class found problem mentioned in #79.