Problems with MAVlink from Onboard Computer

I’m using the BlueOS BETA installed on a raspberry pi 3B+ so I’m expecting some issues but I hope there might be a known fix for this.

When connecting to the autopilot through the companion computer it often takes minutes to get a mavlink connection in qgroundcontrol if at all. I’m able to see the video feed while it shows ‘Disconnected’ but it rarely connects right away. However, if I wait with qgroundcontrol open for 2-5 minutes it usually connects.

Everything seems to work fine for a few minutes but the video begins to stutter and the mavlink update seems to slow down to 1-2Hz. Restarting qgroundcontrol generally fixes this but the issues then return after a few mins. Using a serial connection to the autopilot (Matek H743 V2) always works fine.

Thanks for your help!

UPDATE
I’ve done some more investigation today but still no luck. I updated to the BlueOS BETA version 11 and I now get the following error:
Screenshot 2022-02-05 150459
I’m sure it’s related to the problem but I’m not sure what to do about it.

It does seem to locate the autopilot board as ‘Pixhawk1’

I hope this additional information is helpful.

Hi, this seems to be realated to the mdns/zeroconf discoevery. qgc sometimes takes time to find and connect to it.

Make sure you have the GCS Client Link enabled, and that the IP address of your topside computer is set to 192.168.2.1
image

1 Like

Hi Willian,

Thanks for your help.

It looks like the GCS Client Link is always enabled at startup.
Screenshot 2022-02-05 215005

However, when powering up the system I only see a MAVlink heartbeat and nothing else.

If I reboot the companion computer 2-3 times while leaving the autopilot powered it will finally connect properly and all of the MAVlink data starts flowing:

I’ll keep troubleshooting but let me know if you think of anything else.

Thanks again!

Vehicle ID: 255 with Component ID: 190 is QGroundControl (you can look at the MAVLink Routing and MAV_COMPONENT docs if you want to better understand how the IDs correspond to different systems).

Given you’re seemingly always getting at least the QGroundControl connection, and other times also the vehicle connection, it seems your Companion computer is struggling to connect to the autopilot (or just taking a while to do so).

I’m curious - if you try turning on the vehicle without QGroundControl open on your computer, do you get Vehicle ID: 1 with Component ID: 1 showing up consistently? There will only be a few message types shown, because the other ones are normally requested by QGC (they don’t get sent by default). If you restart the autopilot via the web interface, how long does it take for the heartbeat to return in mavlink2rest (with a Pixhawk for me is < 10 seconds)?

Hi Eliot! Thanks for helping me out with this.

Here’s what I’m seeing. UPDATE Further testing has shown the following not to be true all of the time–> The following start up process is repeatable for me now 100% of the time.

1. Power up system. Raspberry Pi and Autopilot are both powered up simultaneously. Nothing is reported in mavlink2rest:

2. Restart system by clicking on the reboot button on the companion web interface. Autopilot remains powered. The following information is displayed in mavlink2rest:

3. Open QgroundControl and everything connects as expected.

It seems like the autopilot is not ready in time at first boot but I’m not really sure how that handshake works.

When I restart the autopilot the heartbeat usually returns in about 6-7 seconds.

I’ll check out the docs you linked. Hopefully I can get a better understanding of how it all works!

That seems odd, especially if it doesn’t end up coming online. As I understand it there’s supposed to be constant scanning for new mavlink devices (which is why QGC can be detected despite not being available on startup), but it’s possible the USB connections are only handled once on startup, in which case if your autopilot takes too long to start then it won’t be detected. I’ll confirm with the software team and raise an issue if relevant :slight_smile:

Thanks for all your help!

Hey yeclek, thanks for reporting this!

Could you open the terminal service (on the tools menu), access the autopilot tmux (ctrl+b s) and send us the terminal logging? It can be a screenshot. With this it will be more clear what is happening (and your point about startup delay is problably right).

Sorry for the not-so-straightforward way of sending the logs. We are working on improving that :smile:

1 Like

Hi Rafael. Is this the correct screen you’re looking for?

Screenshot 2022-02-07 224907

Let me know if you need anything else.

I think I’ve found the problem, but I have no idea what the solution is.

If the USB camera is not connected at start up, the connection to the autopilot and the mavlink2rest connection works perfectly every time.

If the USB camera is connected the mavlink connection only works about 10 - 20% of the time.

There is a clear relationship between the USB camera being connected and the ability to connect to the autopilot, but I’m not sure where to go from here.

Thanks again everyone for your help!

UPDATE This is not the issue either. Even though I was getting consistent success booting everything successfully about 10 times in a row last night, this doesn’t seem to be the case this morning. It still seems completely random at this point.

If you press 2 while on that screen it should take you to the autopilot window, which is the one he’s after.

That’s interesting. Perhaps the autopilot detector is mistaking the camera for an autopilot, and trying to connect to it. The variability might depend on which device it detects first on the USB bus. Most likely that’s something we’ll need to fix in BlueOS, although it may be helpful to organise a video call/team viewer session if the autopilot terminal logging doesn’t yield enough clues to resolve the issue.

@rafael.lehmkuhl I’m curious if this is a pure USB mixup issue, or if it could be a side-effect of the camera manager presenting the cameras as MAVLink devices (admittedly they shouldn’t be presented as autopilots, but the autopilot detector may not know the difference).

That’s very interesting! And strange.

We detect a USB device as an autopilot with UDEV rules. Basically, if a USB device has “3D robotics” or “ardupilot” in its manufacturer, or “PX4” on its product name, it will be detected as an autopilot.

About the screenshot of the autopilot service, as @EliotBR said, clicking “2” will open the autopilot terminal.

About the camera being detected as an autopilot, if it doesn’t appear in the previous screenshot, could you send a dmesg -w command, remove and reinsert the usb camera and send the result? The dmesg command should show the camera USB data (name, product name and manufacturer), which will help us see if that’s the case.

If you could do a call with us, I would be happy to help diagnosing this.

I have some more useful screenshots for you. Both of these are from an “unsuccessful” start up. in this case UDP video transmission is working fine but the mavlink is not.

Here’s the terminal logging:

and here’s the USB section of dmesg -w:

It looks to me like both the autopilot and camera are discovered correctly but in this case the mavlink data is just not flowing.

If a call would be helpful, I’m available most of the week. I’m also in PST which I believe is where you are, correct?

Thanks for the shots!

So it looks like it’s starting up correctly, and from the dmesg data it doesn’t seem like it is confusing the camera and the board.

One more thing I would like you to try: does the restart button on the autopilot/general page solves the problem (like the system reboot does)?

I’m wondering if the mavlink router is not connecting to the board bootloader.

No, as far as I can tell the restart button doesn’t seem to do anything. I’m not even sure it is rebooting the board. Do you know of any way to check if it’s actually restarting?

I have also noticed in QgroundControl in the MAVlink status in Application Settings shows a loss rate of 99%. When I connect to the autopilot via USB I see a loss rate of 0%. Is this an actual issue or just a difference in the way it’s reported?

Screenshot 2022-02-08 123840

It’s probably because the mavlink router on BlueOS is indeed not working.

I’m trying to reproduce the error here with a Pixhawk1. I will also create a dedicated image with some modifications to see if we can get more clear messages from the router.

Thank you so much. You guys are awesome!

After more testing I have found that if I remove the VBAT power to the autopilot and power it only from the USB on the raspberry pi, it will start successfully about 70 - 80% of the time. This is the most reliable configuration I have found so far. With the autopilot independently powered it would only connect about 25% of the time.

I’m not sure what that means but I hope it helps.

Thank you for the additional info!

I’ve created a new image that will make what is happening to mavlink-router more clear for us.

Could you try it? To download it, you just need to go to the version-chooser on BlueOS (menu/tools/version-chooser), replace the bluerobotics/companion-core (under “Remote Versions”) my repository (rafaellehmkuhl/companion-core). You can then click on Pull and Apply right after the fix-mavlink-manager-logging-simple image. After about a minute it should be running, and I would ask you to send a new screenshot from the autopilot startup. It will have the mavlink-router startup info.

Also, you can disable this “GCS Server Link” endpoint (pencil icon, bulb icon). I’m not entirely sure, but it can mess up things, as we already have the “GCS Client Link” connection to QGroundControl.