Can not create an "offboard" plugin as a private class attribute


I want to write a generic C++ class which utilizes MavSdk C++ API. The user will not deal with details of MavSdk C++ API and just call generic methods. I followed the guidelines and examined the example code but I got stuck at some point.

I have an “Initialize()” method which makes the connection with the PX4, then discovers system and return system object". I can keep the “System” object as a private class attribute, so I can use the same system object anywhere within the class. I want to do the same with “telemetry”, “action” and “offboard” plugins but could not manage it.

I want to keep private variables for each of these plugins. Declare them at header file and initialize them in the “Initialize()” method just after initializing “system” object.

For example:

  • I define “std::shared_ptr systemObj” in class header.
  • I define “mavsdk::Offboard myOffboardObj” in class header.
  • Later, in Initilize() method, after filling the “systemObj” as following in the class implementation.
    this->system = this->;
  • I can create a plugin as “Offboard tempOffboard = Offboard{this->system};”
  • But i can not fill “myOffboardObj” the same way as:
    myOffboardObj = Offboard{this->system};
    The compiler says "Overload resolution selected deleted operator ‘=’ "

Can anyone help me about this issue?
Thanks in advance.

Hard to give proper answer with bullet point like this rather than code. But if that can helps, this is how I initialize an Offboard variable in my code;

std::shared_ptr<mavsdk::Offboard> offboard; // MAVSDK plugin to send offboard command
offboard = std::make_shared<mavsdk::Offboard>(system);

the system is a std::shared_ptr<mavsdk::System> system

Sorry for the style of code, i will try to change it with real code.
Thanks for your answer. When I did it the way you offered, my problem was solved.
Thank you so much for saving me a lot of time