Libvoxl_io with mavlink



  • Hi,

    Is it possible to use mavlink-inputs (from for example: voxl-vision-px4) for libvoxl_io functions?

    We are using the i2c functions from libvoxl_io and they work great. But we would like to use mavlink-inputs to control the i2c-outputs (in particular: mavlink_msg_rc_channels_get_chan8_raw and mavlink_msg_rc_channels_get_chan5_raw).

    I saw in a forumpost that libvoxl_io can not be run inside a docker, so I assume we can not use mavsdk.
    Is it possible to get a UDP connection from voxl-vision-px4 to libvoxl_io and how could we do that?
    Or should we add libvoxl_io to voxl-vision-px4 dependencies and put our code in the src folder?
    Or is there an other way?

    On the voxl SDK main page we saw this image, so what is the connection between voxl-vision-px4 and libvoxl_io exactly?
    c4b77510-704d-4884-94aa-04fe06e9a61c-image.png

    We are looking forward to your reply.


  • Dev Team

    I think you want to receive a mavlink packet, and have a custom action that uses libvoxl_io?

    If so, you could look at the voxl-mavlink-server, subscribe and parse all of the mavlink, and then perform your desired action



  • Thanks a lot, that is exactly what we are looking for. It says in the readme it is better to communicate through voxl-vision-px4 to not interfere with their processes.
    How can we do that using a C file?


  • Dev Team

    I think that comment is in reference to not sending new mavlink messages, which I do not think you are doing. I think if you are just snooping on the wire and performing your own tasks, you will be fine

    What you want to do definitely requires coding, you'll have to become familiar with creating your own MPA service and coding it. I would start by copying a simple existing one and go from there.



  • We were using lib/voxl-test-mavparser from the libvoxl_io library to get the mavlink-inputs and that worked well. But when we run it, voxl-vision-px4 stops working and we also need that.

    I think we are capturing the whole bus from voxl-vision-px4 (UART_J12, bus: 5) with voxl-test-mavparser. Is there a way we can snoop on the wire instead of taking the whole thing using voxl-test-mavparser (UART)? Do we need to use UDP instead? Or is there another way?

    Thanks in advance.


  • Dev Team

    Hi, voxl-mavlink-server handles the UART IO then breaks out the mavlink packets into MPA as a pipe so multiple services can subscribe and send data from/to PX4, you don't need to use the UART port directly.

    You can copy most of the code out of the voxl-vision-px4 module that handles mavlink IO to/from PX4 and use it in your own service alongside voxl-vision-px4 without interfering with it.

    https://gitlab.com/voxl-public/voxl-sdk/services/voxl-vision-px4/-/blob/master/src/px4_mavlink.c

    Best,
    James



  • Thank you, using px4-mavlink.c as example, we were able to open our own pipe:
    e5676eb8-5495-440c-bf2d-802685617251-image.png

    Mavlink doesn't raise an error, but the result is always 0.000
    7f96549c-fe71-428a-9dd5-a9701945c384-image.png

    Here are some screenshots from the script:
    6a6f6460-f02f-44a5-adf7-f64a289036de-image.png
    a4f2df1f-33bd-4645-b449-2b6b02be3b0a-image.png

    Do we need to use our own pipe or should we make a client that connects to voxl-vision-px4's pipe?
    Is there a mavlink connection because it doesn't raise an error?

    Thank in advance!


  • Dev Team

    @SHofmeester voxl-mavlink-server creates the server pipe(s). The example code that James pointed to shows how a client connects to it to receive Mavlink packets. In that example code it is the function _data_from_px4_helper_cb that gets called every time there is new Mavlink data available.



  • Thank you, we put the code in _data_from_px4_helper_cb and we are able to get specific mavlink messages now.

    1c0f9e73-9f66-4e90-9184-a2f9691b624a-image.png

    We added libapq8096_io to the install_build_deps.sh and the CMakeLists.txt file. When we #include <voxl_io.h> and add voxl_i2c_init(i2c_bus); to the script and try to build it, the following error is raised:
    2c9e379c-a0d0-49e3-b8ee-fc53692f8a83-image.png

    But when we add voxl_i2c_init(); without an argument, it says:
    41cf6159-ba8e-4b2a-bac5-7b826232d99c-image.png So the script seem to be connected to libapq8096_io.

    We tried to build it in voxl-cross, because voxl-vision-px4 is built in voxl-cross. But libapq8096_io is built in voxl-hexagon. Does the "undefined reference" problem have to do with the different compilers? If so, how can we change the compiler?


  • Dev Team

    Hi,

    Just want to make sure, the install build deps script will pull libapq8096-io but the CMakeLists need to link against libvoxl_io. Its a little confusing but the idea is to allow the build deps script to pull the right package (since it knows the platform it's building for) but the CMakeLists can remain the same.



  • Hi @Alex-Gardner,

    I'm not entirely getting what you are saying.

    In the build_deps file we only added the following line:
    1cbad36d-49b9-461b-aaf9-90c56f1138ec-image.png

    In CMakeLists.txt (from the same folder as the script) we added:
    find_library(LIBAPQ8096_IO libapq8096_io LIBVOXL_IO libvoxl_io HINTS /usr/lib64)
    and
    25182734-b160-4a27-b8bd-212490ded87b-image.png

    When we try to build these files in voxl-cross, we get the errors from the earlier post.

    Do we need to add anything else, or delete something?


  • Dev Team

    Hi,

    I did a little digging and found 2 things:

    First, the find_package looks like it shouldn't have "lib" in the name (so find_library(LIBVOXL_IO voxl_io HINTS /usr/lib64/)).

    Second and more importantly, there is no voxl_io lib in lib64 because on apq8096 we have to build it in 32 bit because the dsp libs are 32 bit only. So your process would either need to build/run 32 bit or, if you need it in 64 bit, have a 32 bit helper service do the io read/writes and communicate the data to the other process via some standard (like libmodal_pipe, that's why we built it)



  • Hi @Alex-Gardner,

    Thank you for your reply.

    We changed the find_library-line and now he is able to find the .so-file. It now says the .so-file is the wrong format, which is correct according to your second point.

    For your second point: which libraries below can be build/run 32bit and which ones can't?
    libmodal-json
    libmodal-pipe
    librc-math
    libmodal-cv
    voxl-mpa-tools
    voxl-mavlink

    For the 64bit with 32bit helper service solution: we already made a pipe where we receive mavlink messages from using pipe_validate_mavlink_message_t in _data_from_px4_helper_cb.
    Can we use this pipe for the writing with voxl_io, or do we need to make a new one?
    And how can we write through the pipe with voxl_io, because we checked libmodal_pipe but couldn't find anything for that?
    Do we need to make another script with voxl_io functionalities and run it at the same time as the current mavlink message receiving script and communicate between them using a pipe?

    We are looking at different types of solutions, so we looking forward to your reply.


  • Dev Team

    Hi,

    From that list the following already have 32 bit builds that are present when the package is installed:
    modal-json
    modal-pipe
    rc-math
    voxl-mpa-tools

    Additionally, the voxl-mavlink package is header-only and should work fine in a 32 bit project.

    The only one that's 64 bit only is modal-cv. Is there a reason that you need the computer vision library for what seems like should just be a mavlink translator service?

    If your service here is just reading a modal-pipe and writing the data out of voxl-io you should be able to do this just fine with your current setup. If you're attempting a computer vision task that depends on modal-cv it should most likely be broken out into it's own 64 bit service to run much faster.



  • Hi @Alex-Gardner,

    We switched from using voxl-cross and using adjusted .sh files from voxl-vision-px4, to placing our script inside libvoxl_io and adjusting the install_deps and CMakeLists.txt file. Then we can use the 32bit compilers from libvoxl_io, instead of the 64bit compiler from voxl-vision-px4 (we are not really using voxl-vision-px4 as a whole, we just copied some files for dependencies en building).

    We added the libraries to install-deps, except modal-cv (because we don't need it) and that works. (Libvoxl_io is not among the installed libraries, because we placed our script inside libvoxl_io itself)
    3a3c4a0b-8e8f-427e-8390-7a8881e8d6eb-image.png

    But when we try to build it, it raises the following error:
    f847627f-65ab-4918-909b-42cc143e89a8-image.png

    In /usr/include there is a file called modal_pipe_common.h, but the error remains.
    8f0338fa-b256-4fe8-b463-ef6d68f1c691-image.png

    I also don't understand why the path in the error is: usr/include/c_library_v2/../modal_pipe_server.h, and not: usr/include/modal_pipe_server.h

    Is placing our script inside libvoxl_io like this the right path?
    How can we fix the error?


Log in to reply