Is it possible to interact with Raspberry Pi over serial MAVLINK via Ardupilot?

Hi all, my situation is:

  1. I’m using Cube Orange running Plane with a UART connection to a Raspberry Pi (APSync) companion computer.
  2. I’m using an extreme long-range (400+ km) telemetry method.
  3. My telemetry method gives me a solid reliable (albeit low data rate) serial connection.
  4. My telemetry method unfortunately gives me a very flaky and unreliable IP connection.
  5. Therefore, I have a good MAVLINK connection between the GCS (Mission Planner) and the Ardupilot Cube Orange autopilot over serial, but my attempted SSH connection to the Raspberry Pi is just terrible and practically unusable.

I am looking for a way to send commands (ideally shell commands) to the Raspberry Pi using the serial MAVLINK connection, for example to re-start python scripts if they fail or hang, or to remotely reboot the Raspberry Pi, and similar actions.

At this stage I’d like to know if my intent is fundamentally possible, and what the general approach might be. Then more than likely (if it’s not simple enough for a dummy like me to sort out within a day or two), I’ll probably have to post a job request and pay someone to implement it.

You need to know a bit about MAVLink.
There will be some learning period though.
I think this can be done by sending STATUSTEXT from GCS to the remote end.
Send strings something like shell:"cd /home/m/pi" containerized as STATUSTEXT message from GCS to RPi and process in on RPi.

1 Like

Thanks @Mustafa_Gokce that sort of hints at some of what I’ve read elsewhere.

I’ve been through every page and every screen of Mission Planner GCS and I cannot find anything that offers me the ability to type in and send my own MAVLink messages. The MAVLink message structure is highly documented to great detail. But for whatever reason there seems to be no documentation on the process or mechanism of writing and sending a one-off custom/bespoke MAVLink message. I’ll keep searching through the documentation and forums, but if anyone can offer some clues to put me on the right path, that would be really helpful.

1 Like

You can create a proxy using MAVProxy on GCS.
With that proxy, mission planner and a custom code (for example a Python code with pymavlink library) can connect to the same vehicle simultaneously.

Okay I’m about 80% there.

I found Arming and Disarming — Dev documentation ( explains how to enter a MAVLink command into Mavproxy, and so I installed Mavproxy, got it to play nicely with Mission Planner, and then successfully used the example commands to arm and disarm the autopilot. That answers the first part - how to manually enter a one-off custom/bespoke MAVLink message.

The bit that’s not working is the shell. There are two issues:

  1. MAVProxy doesn’t like spaces in the text of STATUSTEXT - it sees the space as the end of the field.
  2. The whole shell:"pwd" construct doesn’t seem to work: it never recognises any text - it doesn’t recognise the word “shell”, or any basic one-word shell commands such as “pwd” or “ls”.

I’m curious. Where did you get the info about the shell: syntax? Is this published somewhere? Could you point me toward the source material?
Thanks again for your help with this.

1 Like

Sorry about that.
There is no shell command.
You need to implement it yourself.
I just thought that on the RPi, you could listen to STATUSTEXT messages.
If you receive a STATUSTEXT message and parse it in Python like if message["text"].startswith("shell"), then you can interpret this message as it is a system command message and you get the rest of the message and execute it.
It said so because other messages are sent from autopilot as STATUSTEXT messages should be interpreted as bad requests and should not be processed from your script.
That is my approach, you can solve it differently.
So send a STATUSTEXT message from GCS using MAVProxy to autopilot:
module load message

Yes, I see that too. For a workaround, you can fill it with a character you will never use and change it at the remote (for example _).

Ah, okay, got it. Yes I see that could work well as long as the Raspberry Pi is stable.

In my case, I only need to access the Raspberry Pi is if/when it’s not working properly, for example if a Python script crashes. If nothing goes wrong then I can leave it alone. Unfortunately, this means it’s not a very robust solution to rely on a Python script or program running on the Raspberry Pi in order to get my connection to work. I really want access at the OS shell level.

So firstly, many thanks for your considered and helpful reply, I will look further into it and use the ideas and principles that you’ve suggested.

However, what I’m really looking for is something like a serial data pipe through the Ardupilot to the Raspberry Pi. I note it’s possible to log into the Raspberry Pi and access a shell via serial/UART (if the RPi is configured for it). And it’s possible to send and receive serial data between the GCS and the Ardupilot, e.g. using MAVLink. And it’s also possible for the Ardupilot to communicate with the Raspberry Pi over serial (UART - TELEM). So… all the pieces are there. I’m just struggling to put them together.

Thanks again.

Hey, I’m looking for the same thing. Did you able to find a solution?