You can find a basic introduction about the Mavlink protocol in this page of the Skyward Wiki: http://wiki.skywarder.eu/index.php?title=Tutorial_Mavlink.
Here you will find an explanation about how our implementation works and how the repositories involved are structured.
Code generation
Basically: the Mavlink protocol defines some messages, and this is done in an XML file. From that, you can implement the protocol using whatever language you like, using the messages you defined in the XML file.
In our case, from the XML we generate plain C code through a generator called pymavlink
. Here's the typical workflow:
(XML) (C)
define --> generate --> include in
messages code your project
A. In the Mavlink_editor repository you can find two tools:
- a browser editor for reading and modifying the messages, which are defined in
mavlink_skyward_lib/messages_definition
folder - the codegenerator, which is imported as a submodule. See the repo's README for more information on how to use them.
B.
The generated C structures and helper functions are located in mavlink_skyward_lib/mavlink_lib
.
C.
mavlink_skyward_lib
is a repository on its own too! So you can simply use it by including it as a submodule in your project.
To keep updated with the newest version of the messages, you should run
git submodule update
git commit
See Working with submodules for more info.
Roadmap
Brief content of the files.
protocol.h
:
some general function declarations and defines
mavlink_helpers.h
:
mavlink_msg_to_send_buffer: converts a mavlink_message_t into a uit8_t[]
skyward/version
:
version of file
mavlink types.h & coversion.h
:
quaternion/angles stuff
skyward/skyward.h
:
enums and includes of the messages headers
Each message is defined with its own structure. There is also a generic structure that is called mavlink_message_t
which contains the sequence id, component id an type id of the message and the payload not structured.
The single messages structures and helpers are defined in dedicated header files called mavlink_msg_XXX_t where XXX is the name of the message.
mavlink_msg_XXX_.h
MAVLINK_MSG_ID_XXX: code which identifies the type id of this message(used in mavlink_message_t.id).
encode(): converts mavlink_msg_XXX_t to mavlink_message_t
decode(): converts mavlink_msg_t to mavlink_msg_XXX_t
mavlink_msg_XXX_get_YYY: returns the YYY field of the message XXX