Integrate parts of libmav into MAVSDK and add MavlinkDirect plugin#2610
Integrate parts of libmav into MAVSDK and add MavlinkDirect plugin#2610
Conversation
b48a3b5 to
67dcac6
Compare
67dcac6 to
45e410c
Compare
JonasVautherin
left a comment
There was a problem hiding this comment.
Very nice to have this feature! 🚀 🚀
| set(MAVLINK_MINIMAL_XML "${DEPS_INSTALL_PATH}/include/mavlink/message_definitions/v1.0/minimal.xml") | ||
| set(MAVLINK_STANDARD_XML "${DEPS_INSTALL_PATH}/include/mavlink/message_definitions/v1.0/standard.xml") | ||
| set(MAVLINK_COMMON_XML "${DEPS_INSTALL_PATH}/include/mavlink/message_definitions/v1.0/common.xml") | ||
| set(MAVLINK_ARDUPILOTMEGA_XML "${DEPS_INSTALL_PATH}/include/mavlink/message_definitions/v1.0/ardupilotmega.xml") |
There was a problem hiding this comment.
I think this creates a hard dependency on the superbuild. Maybe it would be worth having the path as an option, e.g. MAVLINK_MSG_DEFINITIONS_PATH, and the superbuild would by default set it to ${DEPS_INSTALL_PATH}/include/mavlink or something?
There was a problem hiding this comment.
I thought that too but then it worked in CI...
| @@ -0,0 +1,35 @@ | |||
| cmake_minimum_required(VERSION 3.13) | |||
|
|
|||
| project(external-libmavlike) | |||
There was a problem hiding this comment.
I like the name, libmavlike 😬
There was a problem hiding this comment.
I might rename my fork as well.
| set(MAVLINK_ARDUPILOTMEGA_XML "${DEPS_INSTALL_PATH}/include/mavlink/message_definitions/v1.0/ardupilotmega.xml") | ||
| set(EMBEDDED_XML_HEADER "${CMAKE_CURRENT_BINARY_DIR}/embedded_mavlink_xml.h") | ||
|
|
||
| add_custom_command( |
There was a problem hiding this comment.
I am always nervous with add_custom_command. CMake is really not a super nice scripting language, and those always look cryptic to me. It took me way longer than I'm comfortable with to realise that this really just creates one header file called embedded_mavlink_xml.h that gets included later and that doesn't change unless we update the mavlink dependency.
The risk I see is going the road of the PX4 build system, which is so custom that I don't consider it to be CMake anymore, and it is always painful for me to read/use.
What about doing it like we do for the proto files, i.e. generate it once and version it? Just like you only need to run generate_from_protos.sh when you modify the protos, you would only have to run generate_embedded_mavlink.sh when you modify mavlink. And nobody should ever have to do it except those who update libmavlink in MAVSDK (so... pretty much the maintainers).
So that it keeps the CMakeLists readable, and I'm pretty sure that a shell script would be a lot more readable than this custom command 🙈.
What do you think?
There was a problem hiding this comment.
I agree in terms of readability but would you then check the generated header file in, or generate it each time?
There was a problem hiding this comment.
I would check it in, like we do with the protobuf files. Maybe in a generated/ folder, to be consistent?
There was a problem hiding this comment.
We could do that but I want to make it easy for users to swap this out as well. I guess we can make it, so you need to load "common" manually before using it.
There was a problem hiding this comment.
I thought, a script like ./tools/generate_mavlink_direct.sh that would generate the file and put it in the right place (something/generated/mavlink_embedded_headers.h). And that file is versioned. So that it doesn't require a change in the CMakeLists (except for installing the header), users don't have to care about it but they can always update libmavlink and regenerate the file with the ./tools/generate_mavlink_direct.sh script.
Exactly like we do now with the proto files.
Or does that sound to complicated?
There was a problem hiding this comment.
I'm somewhat tempted to leave it as is because it has the advantage that the MAVLink version included will match the one from the headers, and if someone changes the C headers, both change accordingly, and don't get out of sync.
There was a problem hiding this comment.
Sure, your call. I'm just always nervous when I see add_custom_command in CMake, but I guess it won't go as far as in did in PX4 anyway 🙈.
This will support something like MavlinkPassthrough for language wrappers.
This will bring MavlinkPassthrough to the language wrappers.
This was somewhat duplicate, we can just use a subscription with empty string to get all messages.
This is nice after auto-generation where a huge diff is just noise, especially for an LLM to parse.
This adds two examples: - One to show the GPS message JSON output - One to show stats about MAVLink messages arriving.
459971f to
fefa769
Compare
|



This is work towards MavlinkPassthrough for language wrappers called MavlinkDirect.
The work is based on a hard fork of libmav. The fork is required because:
The MavlinkDirect allows you to:
While this seems to be working end to end in system tests, most of the work is Claude Code generated slop, so I will have to review this properly myself.