Skip to content
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

How can I use an older version of MAVLink with MAVSDK? #1946

Closed
eastman-bechamo opened this issue Dec 20, 2022 · 5 comments
Closed

How can I use an older version of MAVLink with MAVSDK? #1946

eastman-bechamo opened this issue Dec 20, 2022 · 5 comments

Comments

@eastman-bechamo
Copy link

eastman-bechamo commented Dec 20, 2022

I'm interfacing with a vehicle that's using MAVLink messages that are outdated when compared to the current definitions for some messages. I've compiled the outdated MAVLink definitions into headers, and pointed MAVSDK to the location for those headers so they would be used:

$(CMAKE) -B build/default -S . -DMAVLINK_DIALECT=all -DMAVLINK_HEADERS=../mavlink-headers

I get an error during compilation of the system_impl.cpp file telling me that enums that are being checked for don't exist:

MAVSDK/src/mavsdk/core/system_impl.cpp: In member function ‘std::pair<mavsdk::MavlinkCommandSender::Result, mavsdk::MavlinkCommandSender::CommandLong> mavsdk::SystemImpl::make_command_ardupilot_mode(mavsdk::SystemImpl::FlightMode, uint8_t)’:
MAVSDK/src/mavsdk/core/system_impl.cpp:914:24: error: ‘MAV_TYPE_VTOL_TAILSITTER_DUOROTOR’ is not a member of ‘MAV_TYPE’
         case MAV_TYPE::MAV_TYPE_VTOL_TAILSITTER_DUOROTOR:
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MAVSDK/src/mavsdk/core/system_impl.cpp:915:24: error: ‘MAV_TYPE_VTOL_TAILSITTER_QUADROTOR’ is not a member of ‘MAV_TYPE’
         case MAV_TYPE::MAV_TYPE_VTOL_TAILSITTER_QUADROTOR:
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MAVSDK/src/mavsdk/core/system_impl.cpp:917:24: error: ‘MAV_TYPE_VTOL_FIXEDROTOR’ is not a member of ‘MAV_TYPE’
         case MAV_TYPE::MAV_TYPE_VTOL_FIXEDROTOR:
                        ^~~~~~~~~~~~~~~~~~~~~~~~
MAVSDK/src/mavsdk/core/system_impl.cpp:918:24: error: ‘MAV_TYPE_VTOL_TAILSITTER’ is not a member of ‘MAV_TYPE’
         case MAV_TYPE::MAV_TYPE_VTOL_TAILSITTER:
                        ^~~~~~~~~~~~~~~~~~~~~~~~

These look like they're created / used by Ardupilot. Is there some way I could tell MAVSDK that I'm not using Ardupilot?

Or, is there another way around this problem? Conditional compilation? Compile-time static checks? Is there a 'hack' that I could use to get this working quickly?

CMake: v3.25.1
Ubuntu: 18.04
MAVSDK: v1.4.9

Thanks!

@JonasVautherin
Copy link
Collaborator

If you change the version of MAVLink, you change the generated headers. If those headers break the compilation, you have to fix it. So in this case you would have to fork MAVSDK and go fix system_impl.cpp, because apparently this older version of MAVLink you are using is not compatible with the MAVSDK sources you compile.

I think -DMAVLINK_HEADERS is more here to allow you to have an extended version of MAVLink, such that you can use your custom messages from mavlink_passthrough. But the other way (going back to an older version) is not guaranteed to work, as apparently you are showing here 🙂

@eastman-bechamo
Copy link
Author

I wonder if there's interest in allowing older versions of MAVLink? I don't think it would be too hard, except for the fact that MAVLink is maybe not very stringent with its versioning.

@JonasVautherin
Copy link
Collaborator

I don't think there is any kind of reliable versioning at all, is there? Other than v1/v2 🤔

@eastman-bechamo
Copy link
Author

I didn't think so either. I think it's something that MAVLink could do better. It would be useful for allowing tools to communicate with different protocols without changing source code.

@julianoes
Copy link
Collaborator

MAVLink broke the build here but not the protocol. So if you have an older MAVLink version where you use the "Reserved" enum it will be binary compatible.

We had a big discussion on the MAVLink call whether "reserved" enums/defines should have even been used in source or whether they are "reserved" and not to be used. There are pros and cons, it's not clear cut.

You can see the history here: mavlink/mavlink#1818

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

No branches or pull requests

3 participants