Blueprint API time out - airsim

Hi
We are using the plugin Airsim
We are trying to control the drone from ue4 blueprint via flying API.
What I did is I’ve created an actor that exposes msr::airlib::MultirotorRpcLibClient methods to BP. It works to some extent, drone can be armed and some other simple commands work but soon after there is a ‘API call timed out’ error and control is lost. Additionally functions taking max_wait_seconds parameter freeze the editor for duration of this value, others freeze editor altogether.
Can flying API be used that way or is it a totally wrong idea?

To start with: I don’t know the plugin and never tried it - but from your question there are couple of thoughts came to my mind.

It possibly can - but CPP tweaks are required, given the nature of RPC and a BPs with it’s time out stuff… I think the best way is to implement a QUEUE of commands.
That will be executed asynchronously (dispatched to main thread on timer or something like this).

That will allow BP to enqueue the commands without waiting - and then the commands will be dispatched without stalling the BP.

I don’t know if it will be acceptable for users (since the commands will possibly have some delays).
But I think it is the only way to go.

Well, how do i approach to implement the queue of commands and make them execute asyncronously?

Can your RPC commands be executed entirely on a background thread ?

If so: then it will be quite easy - Create a Background thread in your actor
that will hold an Array of commands and execute them.

This can get you started A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums

In thread creation and synchronization.

Take a look here https://github.com/Microsoft/AirSim/blob/master/AirLib/include/vehicles/multirotor/api/DroneApi.hpp

Please read the comment of the class…
The Api is meant to be executed on a Worker thread to not block your game.

From what it looks: you didnt have to expose RPCclient to blueprints
but you had to work with the DroneAPI which seems have done everything for you.

If this is not the case - then make your own thread and synchronizations.

Sorry for sharing and asking for so much, but im looking at it and unsure how to approach spesific these

Seems like your client should be of type DroneApi and not MultirotorRpcLibClient

Then fix the errors - if will be.

I cant figure the identifier tough!

edit: No need, just removed the client. identifier. So i changed it to the droneapi.hpp, get alot of functions that doesnt take a number of arguments…

Got this:

  1. Severity Code Description Project File Line Suppression
    State
    Error C2512 ‘msr::airlib::DroneApi’:
    no appropriate default constructor
    available TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Intermediate\Build\Win64\UE4Editor\Inc\AirSim\AirSim.generated.cpp 1793
    Error C2512 ‘msr::airlib::DroneApi’:
    no appropriate default constructor
    available TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 11
    Error C2660 ‘ALeController::moveByVelocity’:
    function does not take 6
    arguments TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 69
    Error C2660 ‘ALeController::moveByVelocityZ’:
    function does not take 6
    arguments TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 89
    Error C2664 ‘bool ALeController::moveOnPath(TArray<FVector,FDefaultAllocator>
    &,float,float,EDrivetrainType,FYawMode
    &,float,float)’: cannot convert
    argument 1 from
    ‘std::vector<msr::airlib::Vector3r,std::allocator<_Ty>>’
    to
    ‘TArray<FVector,FDefaultAllocator>
    &’ TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 106
    Error C2660 ‘ALeController::moveToPosition’:
    function does not take 9
    arguments TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 130
    Error C2660 ‘ALeController::moveToZ’:
    function does not take 6
    arguments TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 145
    Error C2660 ‘ALeController::moveByManual’:
    function does not take 6
    arguments TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 161
    Error C2660 ‘ALeController::rotateToYaw’:
    function does not take 3
    arguments TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 174
    Error C2440 ‘initializing’: cannot convert from ‘FVector’ to
    ‘Eigen::Matrix<float,3,1,0,3,1>’ TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 185
    Error C2440 ‘initializing’: cannot convert from ‘FVector’ to
    ‘Eigen::Matrix<float,3,1,0,3,1>’ TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 191
    Error C2440 ‘initializing’: cannot convert from ‘FQuat’ to
    ‘Eigen::Quaternion<float,2>’ TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 198
    Error C2440 ‘initializing’: cannot convert from ‘FVector’ to
    ‘msr::airlib::GeoPoint’ TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 205
    Error C2440 ‘initializing’: cannot convert from ‘FString’ to
    ‘std::basic_string<char,std::char_traits,std::allocator>’ TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 216
    Error C2678 binary ‘==’: no operator found which takes a
    left-hand operand of type ‘bool’ (or
    there is no acceptable
    conversion) TestingSimulator D:\Marius\AirSim\AirSim
    UE4 directory\TestingSimulator -
    Copy\Plugins\AirSim\Source\Private\LeController.cpp 222