Hey gang,
Working on some C++ code to do things like send in a new mission, grab vehicle telemetry to feed into some other systems, etc.
Our code exactly follows the most recent version of the Offboard examples (such as MAVSDK/examples/offboard/offboard.cpp at d17def1dae469f637bc70972f474df05f0abe31e · mavlink/MAVSDK · GitHub) in terms of what we’re importing, and as far as our CMakeLists.txt. Note, this is for incorporation into a ROS-melodic (yes I know, it’s old, there’s reasons for us using it), but we’re using MavSDK to do the interfacing to the PX4. As such we’ve tried both the pre-built 1.4.16 libmavsdk-dev_1.4.16_ubuntu18.04_amd64.deb as well as built MavSDK from source, but running into the same issues whenever we try either.
In our CMakeLists.txt we have:
find_package(MAVSDK REQUIRED)
target_link_libraries(myapp
MAVSDK::mavsdk
)
We have our import statements in our .cpp as:
#include <mavsdk/mavsdk.h>
#include <mavsdk/system.h>
#include <mavsdk/plugins/action/action.h>
#include <mavsdk/plugins/offboard/offboard.h>
#include <mavsdk/plugins/telemetry/telemetry.h>
#include <mavsdk/plugins/mission/mission.h>
Every time I try to build, I’m getting a linker error on the Telemetry, Mission, Offboard and Action classes:
undefined reference to ‘mavsdk::Mission::Mission(mavsdk::Mission const&)’
related to these lines of code:
mavsdk::Telemetry telemetry{system_ptr};
telemetry_ptr = std::make_shared<mavsdk::Telemetry>(telemetry);
mavsdk::Action action{system_ptr};
action_ptr = std::make_shared<mavsdk::Action>(action);
mavsdk::Offboard offboard{system_ptr};
offboard_ptr = std::make_shared<mavsdk::Offboard>(offboard);
mavsdk::Mission mission {system_ptr};
mission_ptr = std::make_shared<mavsdk::Mission>(mission);
(Note, this is a bit different than how it’s done in the current offboard.cpp example, as when we tried to do it the way shown in the example we got a no constructor match error, and it says that passing in the system itself is deprecated now and we should pass the shared ptr instead.) So wondering if the example code is even correct anymore???
We’re doing this all inside docker containers, but I took out building of the module that’s giving us problems, built the container, started it and went into it via bash, and looking around I can see both the headers and the .so lib inside their respective /usr directory locations, so the .deb IS getting installed properly into the container.
For a while, we thought maybe we still needed to list: MAVSDK::mavsdk_mission. (or _action, _offboard, _telemetry) inside the target_link_libraries() as we saw that in some older examples, but apparently that’s all been pulled into 1 library with these newer versions, so that wasn’t it.
I’m really at a dead end here and everything we have tried (including manually stating where MAVSDK is inside the CMakeLists.txt) hasn’t worked.
Coming up on a huge deadline and really need to get this working.
Anyone have any ideas? Everyone in my office who has looked at it is equally stumped and by all accounts it SHOULD be working properly…
Any help is greatly appreciated!